APIとWebhook
Mozanzaショップの商品・在庫・注文を読み取り・変更し、変化のたびにメッセージを受け取れます。レジ、ERP、倉庫、連携プラットフォーム向けです。
クイックスタート
- 事業者がダッシュボード › ネットショップ › APIとWebhook(Shop ProまたはBusiness)でAPIキーを作成し、権限を選びます。
- 呼び出しのたびにキーをAuthorization: Bearerとして送ってください。
- 金額は通貨の最小単位による税込みの整数です。日時はUTCのISO 8601です。
curl https://app.mozanza.com/api/v1/products?updated_since=2026-11-01T00:00:00Z \
-H "Authorization: Bearer mz_live_…"
curl -X POST https://app.mozanza.com/api/v1/stock \
-H "Authorization: Bearer mz_live_…" -H "Idempotency-Key: sale-4711" \
-H "Content-Type: application/json" \
-d '{"changes":[{"sku":"BO-1","delta":-1,"reason":"sale"}]}'キーごとの権限
キーごとに権限があります。変更権限には読み取り権限も含まれます。無効にしたキーはすぐに使えなくなります。
products:read— 商品の読み取りproducts:write— 商品の読み取りと変更stock:read— 在庫の読み取りstock:write— 在庫の読み取りと変更orders:read— 注文の読み取りorders:write— 注文の読み取りと更新webhooks— Webhookの管理
ページングと同期
一覧は最終更新順です。updated_sinceで変化した分だけを取得し、has_moreがfalseになるまでnext_cursorをたどってください。これで同期の取りこぼしが起きません。
冪等性
書き込みの呼び出しにはIdempotency-Keyヘッダーを付けてください。24時間以内の同じキーは、変更を繰り返さずに同じ応答を返します。ネットワークエラー後に呼び出しが再送されても同様です。
呼び出し上限とエラー
キーごとに1分あたり最大120回。超えるとRetry-After付きの429が返ります。エラーは常にerror.code、error.message、error.statusの形式です。
{ "error": { "code": "shop.stock.belowZero", "message": "…", "status": 409 } }エンドポイント
項目を含む全体の概要はOpenAPIの説明にあります。
GET | /api/v1/me | Business, plan and scopes of this key | |
GET | /api/v1/products | List products | products:read |
POST | /api/v1/products | Create a product (simple or with options and variants) | products:write |
GET | /api/v1/products/{id} | Get a product | products:read |
PATCH | /api/v1/products/{id} | Update a product | products:write |
DELETE | /api/v1/products/{id} | Archive a product (orders keep their history) | products:write |
GET | /api/v1/variants | List variants (find by SKU or EAN) | products:read |
PATCH | /api/v1/variants/{id} | Update a variant | products:write |
GET | /api/v1/categories | List categories | products:read |
GET | /api/v1/locations | List stock locations (stores, warehouses, suppliers) | stock:read |
GET | /api/v1/stock | Stock per variant and location | stock:read |
POST | /api/v1/stock | Change stock (up to 100 changes, all or nothing) | stock:write |
GET | /api/v1/orders | List orders | orders:read |
GET | /api/v1/orders/{id} | Get an order (by id or order number) | orders:read |
POST | /api/v1/orders/{id}/status | Move an order to processing, ready_for_pickup, shipped or delivered | orders:write |
POST | /api/v1/orders/{id}/paid | Mark as paid (e.g. paid at the till on pickup) | orders:write |
POST | /api/v1/orders/{id}/cancel | Cancel an unpaid order (stock is returned) | orders:write |
GET | /api/v1/webhooks | List webhook endpoints | webhooks |
POST | /api/v1/webhooks | Subscribe a URL to events (returns the signing secret once) | webhooks |
DELETE | /api/v1/webhooks/{id} | Unsubscribe | webhooks |
Webhook
Mozanzaは各イベントをHMAC-SHA256で署名したJSONとしてhttpsアドレスへ送ります。10秒以内に2xxで応答してください。応答がない場合は最長3日間再試行します。重複メッセージはidフィールドで無視してください。
イベント
order.created— 新しい注文order.paid— 注文の支払い完了order.shipped— 注文の発送order.delivered— 注文の配達完了order.cancelled— 注文のキャンセルorder.refunded— 返金product.created— 新しい商品product.updated— 商品の変更product.deleted— 商品の削除stock.changed— 在庫の変化
署名の確認
import { createHmac, timingSafeEqual } from 'node:crypto';
// header = req.headers['mozanza-signature'], body = de ruwe tekst van het verzoek
export function verify(header, body, secret) {
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const expected = createHmac('sha256', secret).update(parts.t + '.' + body).digest('hex');
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
return fresh && timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}Zapier、Make、n8n
プラットフォームのHTTPモジュールでAuthorization: Bearerヘッダーとキーを使ってください。トリガーには、プラットフォームのWebhook URLをダッシュボードに貼り付けるか、POST /api/v1/webhooksで登録します。