API ve webhook'lar
Bir Mozanza mağazasının ürünlerini, stoğunu ve siparişlerini oku ve değiştir; her değişiklikte bir mesaj al. Kasalar, ERP'ler, depolar ve entegrasyon platformları için.
Hızlı başlangıç
- İşletme, Panel › Mağaza › API ve webhook'lar'da (Shop Pro veya Business) bir API anahtarı oluşturur ve yetkileri seçer.
- Anahtarı her çağrıda Authorization: Bearer olarak gönder.
- Tutarlar KDV dahil, en küçük para biriminde tam sayılardır. Zamanlar UTC'de ISO 8601 biçimindedir.
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"}]}'Anahtar başına yetkiler
Her anahtarın kendi yetkileri vardır. Değiştirme yetkisi okuma yetkisini de içerir. İptal edilen bir anahtar hemen çalışmayı durdurur.
products:read— Ürünleri okumaproducts:write— Ürünleri okuma ve değiştirmestock:read— Stoğu okumastock:write— Stoğu okuma ve değiştirmeorders:read— Siparişleri okumaorders:write— Siparişleri okuma ve güncellemewebhooks— Webhook'ları yönetme
Sayfalar ve senkronizasyon
Listeler son değişikliğe göre sıralıdır. updated_since ile yalnızca değişenleri iste ve has_more false olana kadar next_cursor'ı izle. Böylece senkronizasyon hiçbir değişikliği kaçırmaz.
Idempotency
Yazma çağrılarında bir Idempotency-Key başlığı gönder. 24 saat içinde aynı anahtar, değişikliği tekrarlamadan aynı yanıtı döndürür; çağrın bir ağ hatasından sonra tekrarlansa bile.
Çağrı sınırı ve hatalar
Anahtar başına dakikada en fazla 120 çağrı; üstünde Retry-After ile 429 alırsın. Hatalar her zaman error.code, error.message ve error.status biçimindedir.
{ "error": { "code": "shop.stock.belowZero", "message": "…", "status": 409 } }Uç noktalar
Alanlarla birlikte tam genel bakış OpenAPI açıklamasındadır.
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'lar
Mozanza her olayı HMAC-SHA256 ile imzalanmış JSON olarak https adresine gönderir. 10 saniye içinde 2xx ile yanıt ver; aksi halde en fazla 3 gün boyunca tekrar deneriz. Tekrarlanan bir mesajı yok saymak için id alanını kullan.
Olaylar
order.created— Yeni siparişorder.paid— Sipariş ödendiorder.shipped— Sipariş gönderildiorder.delivered— Sipariş teslim edildiorder.cancelled— Sipariş iptal edildiorder.refunded— İadeproduct.created— Yeni ürünproduct.updated— Ürün değiştiproduct.deleted— Ürün silindistock.changed— Stok değişti
İmzayı doğrulama
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 ve n8n
Platformunun HTTP modülünü Authorization: Bearer başlığı ve bir anahtarla kullan. Tetikleyiciler için: platformunun webhook URL'sini panele yapıştır veya POST /api/v1/webhooks ile kaydet.