Fatrina REST API v1 and webhooks
For merchants and their developers: read orders, products and customers, update order status, add order notes, ship orders, change prices and stock at each location, manage collections and discount codes, and receive signed webhooks when things happen in the store.
Base URL and host
https://app.fatrina.store/api/v1The API lives on the dashboard host (app.<base>), the same host merchants sign in on, but it does
not use the dashboard session: no cookies, no CSRF token. Both approved base domains serve the same
application; fatrina.site is an alias, not a separate sandbox.
The store is chosen by the key, never by the host or the URL.
Download the OpenAPI 3.1 contract to import into Postman or your API client. The contract includes every operation, its required scope, input schemas and response examples.
Getting started
Use a key created by the owner of a disposable demonstration store. Give it only products:read
for this first call. Replace the example value with that store's actual key; the value here is dummy data.
export FATRINA_API_TOKEN='ftk_your_demo_store_key'
curl --fail-with-body --silent --show-error \
'https://app.fatrina.store/api/v1/products?limit=1' \
--header "Authorization: Bearer $FATRINA_API_TOKEN" \
--header 'Accept: application/json'The result has data and meta keys. A fresh store may have an empty data array.
Use a separate key and store for real customer data. Keep keys out of source control and browser JavaScript.
Authentication
Create a key in Settings > Developers (owners and admins). The key is shown once:
Authorization: Bearer ftk_9mQ2... (ftk_ followed by 40 letters and digits)- Fatrina stores only the SHA-256 of the key and its first 12 characters (to tell keys apart).
- A key acts for the team member who created it, limited to its scopes. It stops working when it
is revoked, or when that member leaves the store or loses the
manage_settingspermission (owner or admin role). - A suspended or closed store answers
403 store_unavailable.
Scopes
| Scope | Allows | The creator also needs |
|---|---|---|
orders:read |
GET /orders, GET /orders/{id}, GET /returns, GET /returns/{id} |
view orders (returns only) |
orders:write |
PATCH /orders/{id}, POST /orders/{id}/notes |
order or notes permission |
fulfillments:read |
GET /orders/{id}/fulfillments |
view orders |
fulfillments:write |
Ship order lines; change a shipment's tracking | fulfil orders |
products:read |
GET /products, GET /products/{id} |
|
products:write |
Create products; update metadata, tax class, prices and stock | catalogue (and inventory for stock) |
inventory:read |
GET /locations, GET /inventory_levels |
view inventory |
inventory:write |
Adjust or set stock at a location | adjust inventory |
collections:read |
GET /collections, GET /collections/{id} and its products |
catalogue |
collections:write |
Create, update and delete collections; add and remove products | catalogue |
discounts:read |
GET /discounts, GET /discounts/{id} |
catalogue |
discounts:write |
Create and update discount codes; deactivate any discount | catalogue |
customers:read |
GET /customers, GET /customers/{id} |
|
webhooks:write |
Manage this key’s connector subscriptions |
A write scope does not include its read scope (a write still returns the updated resource).
Besides the scope, a key acts with its creator's own permissions: if the creator's role cannot do
something in the dashboard (for example adjust stock), the API answers 403 forbidden. Existing
keys keep exactly the scopes they were created with; new scopes are never added to them.
Rate limit
120 requests per minute per key. Every response to an authenticated request carries
X-RateLimit-Limit and X-RateLimit-Remaining; over the limit you get 429 rate_limited with
Retry-After (seconds) and the same two headers. A store holds up to 20 active keys.
Errors
Every error has the same shape:
{"error": {"code": "validation_failed", "message": "The request is invalid.", "fields": {"price": ["The price field must be an integer."]}}}| Status | code |
When |
|---|---|---|
| 401 | unauthenticated |
missing, malformed, unknown or revoked key; creator lost access (the response carries WWW-Authenticate: Bearer) |
| 403 | missing_scope |
the key lacks the route's scope |
| 403 | forbidden |
the creator's role may not do this (e.g. adjust stock) |
| 403 | store_unavailable |
the store is suspended or closed |
| 403 | plan_feature_unavailable |
the store's plan does not include the feature this route belongs to (the API itself, or the resource's feature) |
| 404 | not_found |
no such id in this store (another store's id is a 404, also inside a body or a filter) |
| 409 | idempotency_in_progress |
a request with the same Idempotency-Key is still running |
| 409 | stock_changed |
POST /inventory_levels/set with an expected_on_hand that no longer matches |
| 422 | validation_failed, invalid_state |
bad input (including a field the endpoint does not accept, an unknown filter value or a bad limit), or a state change the resource does not allow |
| 422 | idempotency_key_reused |
an Idempotency-Key already used for a different request |
| 422 | stock_managed_by_pos, stock_managed_by_codes |
the stock at that location is owned by Narmar POS, or is a digital code pool (also on PATCH /products/{id}/variants/{variant} with inventory) |
| 429 | rate_limited |
too many requests |
| other | http_<status> |
any other HTTP error, such as http_405 for a method the route does not allow |
Pagination
Lists are newest first and use cursors:
GET /api/v1/orders?limit=50&cursor=eyJpZCI6MTIzLCJfcG9pbnRzVG9OZXh0SXRlbXMiOnRydWV9{"data": [...], "meta": {"limit": 50, "next_cursor": "eyJ...", "prev_cursor": null}}limit is 1 to 100 (default 25). Pass next_cursor back as cursor until it is null. Filters that
take a time (updated_since) accept a date (2026-11-01) or a date and time in ISO 8601.
Money, dates, languages
- Money uses the current ledger's integer hundredths of the store currency:
19950+EGP= 199.50 EGP. This scale also applies to existing KWD stores. Storefront display currencies do not change stored or API amounts. - Dates are ISO 8601 in UTC.
- Product and line titles are objects by language:
{"ar": "قميص", "en": "Shirt"}.
Orders
GET /orders filters: status (open, closed, cancelled), financial_status (pending,
authorized, paid, partially_refunded, refunded, voided), fulfillment_status
(unfulfilled, partial, fulfilled) and updated_since. An unknown value is a 422.
{
"id": 812, "number": 1042, "status": "open", "financial_status": "pending",
"fulfillment_status": "unfulfilled", "confirmation_status": "confirmed", "source": "web",
"payment_method": "cod", "currency": "EGP",
"subtotal": 39900, "discount_total": 0, "shipping_total": 5000, "tax_total": 0, "payment_fee_total": 0, "total": 44900,
"customer_id": 77, "contact_email": null,
"shipping_address": {"name": "Mona", "phone": "+201001234567", "governorate_code": "cairo", "city": "Nasr City", "area": null, "street": "Abbas El Akkad", "building": "12", "floor": "3", "apartment": "7", "landmark": null},
"note": null, "tags": [], "cancel_reason": null, "cancelled_at": null,
"created_at": "2026-11-09T10:00:00+00:00", "updated_at": "2026-11-09T10:05:00+00:00",
"line_items": [{"id": 1, "variant_id": 55, "title": {"ar": "قميص", "en": "Shirt"}, "variant_title": {"ar": "M", "en": "M"}, "sku": "SH-M", "quantity": 2, "unit_price": 19950, "discount": 0, "tax": 0, "line_total": 39900, "fulfilled_quantity": 0}]
}Not exposed: COD risk scores, phone hashes, attribution and visit data, confirmation-call claims, line costs.
Change status
PATCH /orders/{id}
{"status": "closed"}
{"status": "open"}
{"status": "cancelled", "reason": "customer_request", "note": "Asked by phone"}Open/closed go through the order state machine; a cancellation goes through the same cancellation
as the dashboard (stock released, customer notified per your notification settings, a paid COD
deposit refunded). A cancellation needs a reason: customer_request, out_of_stock, fraud or
other (other needs a note, up to 500 characters). Only status, reason and note are accepted.
A partially shipped order is closed for its unshipped remainder instead of
cancelled. A cancelled order cannot be reopened (422 invalid_state). Sending the current status
is a no-op.
Add a note
POST /orders/{id}/notes
{"body": "Customer asked for an evening delivery."}Adds an internal note (up to 1,000 characters) to the order timeline, by the key's creator. 201 with {"data": {"id", "order_id", "body", "created_at"}}.
Fulfilments
GET /orders/{id}/fulfillments
POST /orders/{id}/fulfillments
{"lines": [{"order_line_id": 1, "quantity": 2}], "carrier": "Aramex", "tracking_number": "AX123456789", "tracking_url": "https://tracking.example.com/AX123456789"}
PATCH /orders/{id}/fulfillments/{fulfillment}
{"tracking_number": "AX987654321"}GET lists every shipment of the order, oldest first, with its lines (fulfillments:read).
POST ships order lines exactly like the dashboard's Fulfil dialog (fulfillments:write and the
creator's fulfilment permission): only an open order, at most the quantity still unshipped per line,
stock taken from the order's reservation, the order's fulfilment status updated and the shopper
notified per your notification settings. It is refused (422) while the order's payment does not
allow shipping yet (there is no payment override through the API), while a cash-on-delivery order
waits for its confirmation, and for an imported order (403). carrier is a courier name (default:
your own delivery); couriers that book their own parcels (such as Bosta) are booked from the
dashboard. 201 with the new shipment. Send an Idempotency-Key so a retry can never ship twice.
PATCH changes only tracking_number and tracking_url (either may be null), while the shipment
is not yet delivered or returned and its carrier does not assign tracking itself (422 invalid_state
otherwise). Marking a shipment shipped or delivered stays in the dashboard and the carrier updates.
Returns
Read-only. Returns need orders:read and the creator's permission to see orders. Approving, receiving,
refunding and closing a return stay in the dashboard, because they move stock and money.
GET /returns?status=approved&order_id=812&updated_since=2026-12-01
GET /returns/{id}GET /returns filters: status (requested, info_requested, approved, rejected, received_partial,
received, refunded, exchanged, closed), order_id (another store's order is a 404) and
updated_since. It pages like orders, newest first. An unknown value is a 422.
{
"id": 9, "order_id": 812, "number": "R-1009", "status": "approved", "reason": "size_fit",
"lines": [{"order_line_item_id": 1, "quantity": 1}],
"exchange": {
"status": "reserved", "resolution": "exchange", "replacement_order_id": null, "credit": null, "difference": null, "collection": null,
"lines": [{"order_line_item_id": 1, "variant_id": 56, "quantity": 1, "unit_price": 19950}]
},
"created_at": "2026-12-01T09:00:00Z", "updated_at": "2026-12-01T09:30:00Z"
}This is also the data of the return.requested and return.updated webhooks. exchange is null for a
request without one. Once the replacement order exists, replacement_order_id, credit and difference
(the replacement's total minus the returned units' value, signed) are filled and GET /orders/{id} reads the
replacement order like any other. updated_at moves with every status change and every exchange change,
so updated_since finds both.
Products
GET /products filters: status (draft, active, archived), updated_since.
{
"id": 31, "handle": "linen-shirt", "status": "active",
"title": {"ar": "قميص كتان", "en": "Linen shirt"}, "description": {"ar": "...", "en": "..."},
"vendor": null, "type": null, "tags": ["summer"], "published_at": "...", "created_at": "...", "updated_at": "...",
"variants": [{
"id": 55, "product_id": 31, "sku": "SH-M", "barcode": null, "price": 19950, "compare_at_price": 24950,
"currency": "EGP", "weight_g": 300, "position": 0, "track_inventory": true, "allow_backorder": false,
"inventory": {"on_hand": 12, "reserved": 2, "available": 10},
"options": [{"name": {"ar": "المقاس", "en": "Size"}, "value": {"ar": "M", "en": "M"}}]
}]
}Cost prices are never returned, whatever the scopes: a variant's cost is the merchant's margin
(used by the profit report) and no integration this API serves needs it. If one ever does, it will
get its own scope rather than widening products:read.
Change price and stock
PATCH /products/{id}/variants/{variant}
{"price": 18950, "compare_at_price": 24950}
{"inventory": {"on_hand": 40}, "reason": "stocktake"}
{"inventory": {"adjust": -2}, "reason": "damaged"}- Prices: integers from 0 to 99,999,999,999;
compare_at_pricemust stay aboveprice(ornull). - Stock: set
on_hand(0 to 1,000,000) oradjustby a non-zero amount (up to 1,000,000 either way), never both. Send at least one ofprice,compare_at_priceorinventory; any other field is a422.reason(used withinventory) is one ofreceived,stocktake,damaged,lost,returned,correction(default),initial,other. Each change is written to the stock history like a dashboard adjustment. On-hand cannot fall below what is reserved for open orders; an untracked variant refuses stock changes. - Price changes need the creator to have catalogue permission; stock changes need inventory permission. Price and stock in one request are written together or not at all.
- A stock change lands at the store's default location and is refused exactly like
POST /inventory_levels/adjustand/set:422 stock_managed_by_poswhen Narmar POS owns the count at that location,422 stock_managed_by_codesfor a digital variant that sells codes. The refusal comes before any write, so a request that also carries apricechanges nothing. A request with onlypriceorcompare_at_priceis never refused for this. To work at a specific location, use the inventory endpoints below. - Returns the whole product.
Create a product and update its details
POST /products requires products:write and the current actor’s catalog permission and plan quota. It creates one default variant. Prices use the integer ledger units described above; stock is adjusted separately through the existing variant operation.
{"title":{"ar":"قميص كتان","en":"Linen shirt"},"handle":"linen-shirt","status":"draft","variant":{"price":25000,"sku":"LINEN-01","track_inventory":true}}PATCH /products/{id} accepts only title, description, SEO title/description, handle, status, vendor, type, tags and tax_class. Locale maps merge with existing translations. It preserves variants, prices and inventory; options, variants and cost are rejected. A supplied handle must be unique in this store. Send an Idempotency-Key with POST /products so a retry after a network error cannot create a second product.
tax_class (on POST /products and PATCH /products/{id}) sets the product's VAT class, the same value GET /products prints: standard for the store rate, or the key of one of your store's active tax classes (a reduced, zero-rated or exempt class from Settings > Tax classes). An unknown or archived key, or the key of another store's class, is a 422 validation_failed. A body with only tax_class changes nothing else on the product. The change reaches new carts only: orders already placed keep the class they were sold under. Each change is recorded in the activity log and the audit trail with the key's creator and its prefix, exactly like a change made in the dashboard; sending the class the product already has changes and records nothing.
{"tax_class": "standard"}Inventory
Stock per variant and location. Reading needs inventory:read (and the creator's view-inventory
permission); writing inventory:write (and adjust-inventory).
GET /locations
GET /inventory_levels?variant_id=55&location_id=3{"id": 3, "name": "Main warehouse", "is_default": true, "is_active": true, "sells_online": true, "created_at": "...", "updated_at": "..."}
{"id": 120, "variant_id": 55, "product_id": 31, "location_id": 3, "on_hand": 38, "reserved": 2, "available": 36, "updated_at": "..."}sells_online says whether the location's stock counts for online orders. GET /inventory_levels
filters: variant_id, location_id (another store's id is a 404) and updated_since. A level
exists for each tracked variant at each location that holds it; available is on-hand minus the
units reserved for open orders and checkouts.
Adjust and set stock
POST /inventory_levels/adjust
{"variant_id": 55, "location_id": 3, "delta": -2, "reason": "damaged", "note": "Two torn in transit"}
POST /inventory_levels/set
{"variant_id": 55, "on_hand": 40, "expected_on_hand": 38, "reason": "stocktake"}adjustadds or removes units (deltanon-zero, up to 1,000,000 either way);setmakes on-hand exactlyon_hand(0 to 1,000,000). Withoutlocation_id, the store's default location.expected_on_hand(optional,setonly) is a safety check for sync tools: the count is written only if on-hand still is that number, otherwise409 stock_changedand nothing changes. Read the level again and decide.reasonis one ofreceived,stocktake,damaged,lost,returned,correction(default),initial,other;note(up to 500 characters) appears in the stock history, which records every change like a dashboard adjustment. On-hand cannot fall below what is reserved for orders, and an untracked variant refuses stock changes (422).- Refused with
422 stock_managed_by_posat a location whose count Narmar POS owns (the store's POS connection is active and mapped to that location: change it in the POS), and with422 stock_managed_by_codesfor a digital variant that sells codes (its stock is its number of unused codes). - Answers
200with the level after the change. Send anIdempotency-Keywithadjust: repeating an adjustment without one applies it again.
Collections
collections:read / collections:write, and the creator's catalogue permission.
GET /collections?kind=manual
GET /collections/{id}
GET /collections/{id}/products{"id": 14, "handle": "new-arrivals", "kind": "manual", "title": {"ar": "وصل حديثا", "en": "New arrivals"}, "description": null, "seo_title": null, "seo_description": null, "sort_order": "manual", "published": true, "rules": null, "products_count": 2, "created_at": "...", "updated_at": "..."}GET /collections filters: kind (manual, automatic) and updated_since. GET /collections/{id}/products
pages through the members in display position order: {"data": [{"product_id": 31, "position": 0}], "meta": {...}}.
rules is an automatic collection's rule set, read-only through the API (rules are built in the
dashboard, with its live preview).
Create, update and delete
POST /collections
{"title": {"ar": "وصل حديثا", "en": "New arrivals"}, "handle": "new-arrivals", "published": true}
PATCH /collections/{id}
{"sort_order": "newest"}
DELETE /collections/{id}POST creates a manual collection; accepted fields are title (the store's default language
required), description, seo_title, seo_description, handle (unique in this store; generated from
the title when omitted), sort_order (manual default, newest, price_asc, price_desc,
title_asc, best_selling; automatic collections cannot use manual) and published (default
false). PATCH takes the same fields and changes only what is sent; language maps merge with the
stored ones. DELETE removes the collection, never its products: {"data": {"id": 14, "deleted": true}}.
Add and remove products
POST /collections/{id}/products
{"product_ids": [31, 32]}
DELETE /collections/{id}/products/{id}For a manual collection only (an automatic one answers 422 invalid_state). POST appends up to 50
products after the current members, in the order sent, skipping products already in it; a collection
holds up to 500. DELETE takes the collection id, then the product id; a product that is not a member
is a 404. Both answer with the collection. Any id of another store is a 404.
Discounts
discounts:read / discounts:write, and the creator's catalogue permission. Welcome and referral
rewards (one code per shopper, owned by those programmes) are never listed or changed here.
GET /discounts?status=active&kind=code
GET /discounts/{id}{"id": 7, "code": "SUMMER10", "kind": "code", "name": null, "method": "percent", "value": 1000, "min_subtotal": 0, "min_quantity": 0, "usage_limit": 500, "per_customer_limit": null, "status": "active", "starts_at": null, "ends_at": null, "product_ids": null, "collection_ids": null, "segment_ids": null, "combines_automatic": true, "combines_code": true, "combines_offers": true, "uses": 12, "created_at": "...", "updated_at": "..."}value is basis points for percent (1000 = 10%, at most 10000), minor units for fixed, and 0
for free_shipping. uses counts active redemptions; codes_count counts the discount's generated unique codes
(code batches; the codes themselves are not served). Automatic, buy-X-get-Y and tiered rules also
carry their own fields (buy_quantity, get_quantity, tiers, ...). Filters: status (draft,
active, expired, disabled), kind (code, automatic, bxgy, tiered), updated_since.
Create, update and deactivate
POST /discounts
{"code": "SUMMER10", "method": "percent", "value": 1000, "status": "active", "usage_limit": 500, "ends_at": "2026-12-31T21:59:59Z"}
PATCH /discounts/{id}
{"usage_limit": 1000}
POST /discounts/{id}/deactivatePOST creates a code discount with the dashboard's rules. Required: code (letters, digits, _ and
-, up to 64; stored in capitals and unique in this store), method, value and status. Optional:
name ({"ar", "en"}), min_subtotal, min_quantity, usage_limit, per_customer_limit, starts_at
and ends_at (ISO 8601 with a time zone, whole seconds), product_ids and collection_ids (limit the
discount to those), segment_ids (customer segments), combines_automatic, combines_code and
combines_offers (default true). PATCH changes only what is sent, on code discounts only; other
kinds are built in the dashboard. deactivate (no body) sets any discount to disabled; repeating it
changes nothing.
Customers
GET /customers filter: updated_since.
{"id": 77, "phone": "+201001234567", "email": null, "first_name": "Mona", "last_name": "Ali", "accepts_marketing": false, "tags": [], "created_at": "...", "updated_at": "..."}Staff notes and computed statistics are not exposed.
Webhooks
Add an endpoint in Settings > Developers > Webhooks: an https URL and the events to receive. A store
holds up to 10 endpoints. The signing secret (whsec_...) is shown once; you can make a new one at any time.
| Event | Sent when | data |
|---|---|---|
order.created |
an order is placed (checkout, quick order, payment link) | order |
order.updated |
anything new on the order timeline: status, payment, fulfilment, carrier, refunds, notes | order |
order.delivered |
a shipment is marked delivered | order |
order.cancelled |
an order is cancelled | order |
product.updated |
a product, a variant, a price or a stock level changes (also once for a new product) | product |
customer.created |
a new customer record | customer |
fulfillment.updated |
a fulfilment is prepared, shipped, delivered, returned or gets a carrier status update | public fulfilment status and tracking fields |
return.requested |
a shopper submits a new return request | return id, order id, reason and requested line quantities |
product.created |
a product is created (dashboard, import, API) | product |
product.deleted |
a product is deleted | {"id": ...} |
inventory_level.updated |
stock at a location changes (on-hand or reserved): once per level per operation | inventory level |
collection.created |
a collection is created | collection |
collection.updated |
a collection's details change, or products are added or removed through the API | collection |
collection.deleted |
a collection is deleted | {"id": ...} |
discount.created |
a discount is created | discount |
discount.updated |
a discount changes, including deactivation | discount |
fulfillment.created |
a shipment is created (fulfillment.updated is sent too) |
fulfilment with its lines |
refund.created |
a refund is recorded (any method; status may still be pending) |
refund id, order id, amount, currency, reason, status, method, restocked lines |
return.updated |
a return moves on: approved, rejected, information requested or provided, received, refunded, closed, or its exchange is chosen, changed, replaced or cancelled | return |
customer.updated |
a customer's phone, email, name, marketing consent or tags change | customer |
webhook.test |
you press Send test on the endpoint (always sent, whatever it subscribes to) | {"message": "..."} |
Each delivery is a POST with a JSON body and these headers:
Content-Type: application/json
User-Agent: Fatrina-Webhooks/1.0
Fatrina-Event: order.created
Fatrina-Event-Id: 01jcb6y3x4n0s8m2k7q5r9t1vw
Fatrina-Delivery: 9812
Fatrina-Signature: t=1731150000,v1=5f8c0e...{"id": "01jcb6y3x4n0s8m2k7q5r9t1vw", "event": "order.created", "created_at": "2026-11-09T10:00:00+00:00", "store": {"slug": "rikka"}, "data": { ...the order, as in the API... }}data is the resource as it was when the event was recorded, in the same shape as the API.
Several changes in one operation send one event. A new product or collection also sends product.updated
or collection.updated as its details are written, except to an endpoint that subscribes to the
matching *.created event, which receives only that one. The same Fatrina-Event-Id is sent on every retry
and on a manual resend: de-duplicate on it.
Verifying a webhook
Compute HMAC-SHA256 over <t>.<raw body> with your signing secret, compare it (constant time) with
v1, and refuse a t more than five minutes from your clock. Use the raw body bytes, not a re-encoded
JSON object.
function fatrinaWebhookIsValid(string $secret, string $header, string $body, int $tolerance = 300): bool
{
$parts = [];
foreach (explode(',', $header) as $piece) {
[$name, $value] = array_pad(explode('=', trim($piece), 2), 2, '');
$parts[$name] = $value;
}
$t = (int) ($parts['t'] ?? 0);
if ($t <= 0 || abs(time() - $t) > $tolerance || ! isset($parts['v1'])) {
return false;
}
return hash_equals(hash_hmac('sha256', $t.'.'.$body, $secret), $parts['v1']);
}
$ok = fatrinaWebhookIsValid(getenv('FATRINA_WEBHOOK_SECRET'), $_SERVER['HTTP_FATRINA_SIGNATURE'] ?? '', file_get_contents('php://input'));// Node (Express): app.post('/webhooks/fatrina', express.raw({ type: 'application/json' }), handler)
const crypto = require('crypto');
function isValid(secret, header, rawBody, tolerance = 300) {
const parts = Object.fromEntries(header.split(',').map((p) => p.trim().split('=')));
const t = Number(parts.t);
if (!Number.isSafeInteger(t) || t <= 0 || Math.abs(Date.now() / 1000 - t) > tolerance || !/^[a-f0-9]{64}$/.test(parts.v1 || '')) return false;
const expected = crypto.createHmac('sha256', secret).update(String(t) + '.').update(rawBody).digest('hex');
return crypto.timingSafeEqual(Buffer.from(expected, 'hex'), Buffer.from(parts.v1, 'hex'));
}import hashlib
import hmac
import re
import time
def fatrina_webhook_is_valid(secret, header, raw_body, tolerance=300):
parts = dict(piece.strip().split("=", 1) for piece in header.split(",") if "=" in piece)
timestamp = parts.get("t", "")
signature = parts.get("v1", "")
if not re.fullmatch(r"[0-9]+", timestamp) or not re.fullmatch(r"[a-f0-9]{64}", signature):
return False
timestamp = int(timestamp)
if timestamp <= 0 or abs(time.time() - timestamp) > tolerance:
return False
expected = hmac.new(secret.encode("utf-8"), str(timestamp).encode("ascii") + b"." + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)Pass bytes from the HTTP request to the Python function and a Buffer to the Node function. The documentation checks execute the samples against the same fixed signature vector, changed bytes, an incorrect secret, expired timestamps and malformed signatures.
Delivery, retries and switching off
- Answer with any
2xxwithin 10 seconds. Redirects are not followed (a3xxis a failure). - A failed attempt (no connection, timeout, non-2xx) is retried after 1 minute, 5 minutes,
30 minutes, 2 hours, 6 hours and 12 hours: seven attempts in all, then the delivery is
failed. - After 10 failed attempts in a row on an endpoint (any deliveries), the endpoint is switched off and Settings > Developers says so. Turning it back on resets the count.
- The delivery log keeps the last 30 days; any delivered or failed entry can be sent again (same body and event id).
Allowed addresses
https only (plain http is accepted outside production for local testing), the standard port, no
user name or password in the URL, never a Fatrina address. The host is resolved and every address
must be public: private, loopback, link-local (including the 169.254.169.254 metadata service),
CGNAT and similar ranges are refused, at save time and again before every attempt, and the
connection is pinned to the checked address.
Connector subscriptions
GET /webhooks, POST /webhooks and DELETE /webhooks/{endpoint} require webhooks:write. A key can list or remove only subscriptions created by that key, including within the same store. Existing dashboard endpoints and signing secrets cannot be read. Creating a subscription also requires its source read scope: orders:read for order, fulfilment, refund and return events, products:read for product events, inventory:read for stock events, collections:read for collection events, discounts:read for discount events, and customers:read for customer events. Stock, collection and discount events also need the creator's matching permission, checked again before every delivery.
Supply a public HTTPS callback URL, event names, and a connector-generated signing secret. The secret must be whsec_ followed by 40–128 random letters/numbers. The API never returns it; retain it in the connector’s secure subscription data before the request. Repeating the same key/URL/events/secret returns the same subscription; conflicting settings require removing the old subscription first. The existing public-address/DNS-pinning guard applies without provider exceptions. Revoking the key, losing its source scope or removing its creator stops queued deliveries too.
{"url":"https://hooks.example.com/fatrina","events":["order.created"],"secret":"whsec_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}The secret above is a dummy fixture. Use independent cryptographically random values in a real connection.
Private connector source and separate installation guides are available for Zapier, Make and n8n. Native provider import/validation and public review remain release steps; no marketplace publication is claimed.
Retrying writes and idempotency
GET requests can be retried after a network error. Wait for Retry-After when the API answers 429.
Do not retry 401, 403, 404 or 422 until their cause is corrected.
Every POST accepts an Idempotency-Key header: any string of 1 to 255 visible ASCII characters
that you choose per operation (a UUID works well). For 24 hours, repeating the same request with the
same key returns the first answer, with the header Idempotent-Replayed: true, and does nothing again.
POST /api/v1/inventory_levels/adjust
Idempotency-Key: 6f1c2b8e-4d4a-4b8f-9c55-0d3e2f1a7b90
{"variant_id": 55, "delta": -2, "reason": "damaged"}- The key belongs to your API key: another API key may use the same value independently.
- The same key with a different method, path or body is refused with
422 idempotency_key_reused. - While the first request still runs, a repeat gets
409 idempotency_in_progresswithRetry-After. - Only successful answers are kept. A request that failed changed nothing, so sending it again with the same key runs it again.
PATCH and DELETE are naturally repeatable: repeating an order's current status is a no-op, and
setting the same price, tracking or on-hand quantity has the same final value. Use the event ID to
deduplicate webhooks.
Versions and deprecation
The path fixes the major version at /api/v1. Clients must ignore additional response fields and
unknown webhook events. Existing fields and their types remain compatible within v1; breaking changes
require another major version and a published migration guide. Any retirement date will be announced
in this guide before an existing version is removed.
Changelog
-
2026-12-02: the variant update endpoint (
PATCH /products/{id}/variants/{variant}) refuses stock changes that Narmar POS or a code pool owns, like the inventory endpoints (422 stock_managed_by_pos/stock_managed_by_codes, before anything is written); read-onlyGET /returnsandGET /returns/{id}underorders:read(andupdated_aton the return);tax_classis writable on product create and update; exchange changes sendreturn.updated. -
2026-11-29: inventory (locations, stock levels, adjust and set with an optimistic check), collections, discount codes and fulfilments endpoints with eight new scopes; twelve new webhook events;
Idempotency-Keyon everyPOST; fulfilment payloads now include their lines. -
2026-11-15: downloadable OpenAPI contract; executable PHP, Node and Python webhook verification examples; explicit retry behavior and version policy. Both Fatrina domains use the retained application.