Webhooks
Instead of polling the order methods, you can have GTS Shop call your service when an order item moves. Send us your endpoint URL and a key — until they are configured, no calls are made.
The request
We POST to your URL with Content-Type: application/json and your key in the
Authorization header, verbatim — no Bearer or other prefix.
{
"service": "webhooks",
"method": "webhooks_handle",
"payload": {
"sign": "8f14e45fceea167a5a36dedd4bea2543",
"data": {
"topic": "orders.items",
"event": "purchase_started",
"payload": {
"number": "693741",
"items": [{ "id": "4234787" }, { "id": "4234788" }]
}
}
}
}
number— the order number you passed when creating the order.items[].id— yourprovider_idvalues. An item created without one arrives with our internal identifier instead.itemslists every item of the order, not just the changed one. Treat the call as "something moved in this order" and re-read the order.
Events
event is <step>_<stage> from the Order Status model —
purchase_started, acceptence_finished, delivery_idle. The one exception is
updated, sent when an item is edited or split rather than moved.
New steps and stages may appear. Match the events you need and ignore the rest.
Signature
sign is the MD5 of the serialised data object concatenated with your key:
sign = md5(json(data) + api_key)
Compute it over the raw data exactly as received — re-serialising may reorder
keys and change the digest.
const { sign, data } = req.body.payload;
const expected = crypto.createHash('md5')
.update(JSON.stringify(data) + process.env.GTS_API_KEY)
.digest('hex');
if (expected !== sign) return res.sendStatus(401);
Responding
Answer 2xx once accepted; anything else counts as a failure. Process
asynchronously and reply fast — we hold the connection open until you do.
Delivery is at-least-once: a failed call is retried, so the same event may arrive twice. Keep your handler idempotent.
Events of one order arrive in order — they are keyed by order id, so they share a partition and are delivered sequentially. No such guarantee holds between different orders.