Callback events
About 798 words
v1 draft
This page is part of the draft v1 integration contract; details may change along with the integration checklist, so rely on the official checklist published in the portal.
The platform pushes order and after-sales status changes to the callback URL configured for your shop via HTTP POST. Callbacks are notifications, not the only source of truth: any event can be verified with the order query endpoint.
Event list
| event_type | Trigger | What to do |
|---|---|---|
order.accepted | Order accepted | Record the order number and mark the storefront order as accepted |
order.fulfilled | Order fulfilled in full | Fetch the deliverables with get_orders (with_delivers=true) and fulfill |
order.completed | Order flow finished (charged, after-sales window closed) | Mark the storefront order as completed and archive the delivery records |
order.cancelled | Cancellation confirmed | Release the hold and mark the storefront order as cancelled |
order.rejected | Rejected for a business reason | Notify the end user and roll back |
Request format
正在加载交互式结构…
POST /your/callback HTTP/1.1
Content-Type: application/json; charset=utf-8
X-Xstock-Event: order.fulfilled
X-Xstock-Event-Id: evt_01J8Z3K4
X-Xstock-Timestamp: 1795000000
X-Xstock-Signature: 4b1d...{
"event_id": "evt_01J8Z3K4",
"event_type": "order.fulfilled",
"occurred_at": "2026-11-24T13:05:48Z",
"data": {
"order_id": 9001,
"order_no": "XS20261124000123",
"status": "delivered",
"req_id": "shop-a-20261124-0001",
"trace_id": "trace-7f3a9c",
"dstm_order_ref": "202611240001",
"fulfill_state": "full",
"fund_state": "captured",
"total": {
"amt": "19.00",
"ccy": "CNY"
},
"lines": [
{
"line_no": 1,
"sku_id": 1001,
"sku_guid": "5d8f2a6c9e1b4d3f8a7c0e2b5d9f1a3c",
"qty": 1,
"unit_price": {
"amt": "19.00",
"ccy": "CNY"
}
}
],
"delivers": [
{
"line_no": 1,
"sku_id": 1001,
"sku_guid": "5d8f2a6c9e1b4d3f8a7c0e2b5d9f1a3c",
"artifact_id": "art_01",
"kind": "acct_bundle",
"logical_unit_cnt": 1,
"content": {
"username": "demo_user_01",
"password": "demo_pass_01"
}
}
]
}
}| Field | Description |
|---|---|
event_id | Unique event identifier; the idempotency key |
event_type | Event type |
occurred_at | Time the business event occurred (UTC) |
data.order_id | Numeric order identifier; refers to the same order as order_no |
data.status | Aggregate status; values as in Query orders |
data.req_id | The idempotency key you submitted, returned unchanged |
data.trace_id | The trace identifier you submitted, returned unchanged |
data.lines | Order lines: line_no, sku_id, sku_guid, qty, unit_price; identical to the order response |
data.delivers | Array of deliverables; each element maps to one order line and SKU (line_no + sku_id / sku_guid), and appears only in fulfillment events |
Verifying signatures
Structurally the same as request signing, but the string to sign differs:
body_digest = SHA256(raw_body) 十六进制小写
string_to_sign = timestamp + "\n" + event_id + "\n" + body_digest
signature = HMAC_SHA256(secret, string_to_sign) 十六进制小写- Verify with the shop's currently valid Secret; during rotation both old and new keys may appear, so stay compatible with both key versions for a while.
- Reject timestamps that deviate by more than 300 seconds, to prevent replay.
- A failed verification returns 401 and the platform retries.
Responses
The receiver must return a 2xx within 5 seconds:
{ "code": "OK", "msg": "" }200withcode=OK: treated as delivered;msgmay be an empty string or your own note.- Any other status code or business code: treated as a failure and retried.
- Process asynchronously after receiving an event; do not perform long-running work inside the callback.
Retry policy
| Item | Rule |
|---|---|
| Retries after the first failure | 6, for 7 attempts in total including the first |
| Retry intervals (seconds) | 300, 600, 1800, 3600, 7200, 14400 |
| Timing start | When the previous delivery attempt finished failing |
| Termination | Stops at the limit; compensate with the order query endpoint |
| Retry destination | Always delivered to the original shop's address for that order; an address change never redirects it to another shop |
Do not treat retries as a message queue
Callback retries cover only a limited time window. Back up critical states (especially fulfillment) with order queries or active reconciliation; do not make "wait for the callback" your only path.
Idempotent handling
The same event_id may be delivered more than once:
- Deduplicate by
event_id; if it was already processed, return{"code":"OK","msg":""}directly. - Events for the same order may arrive out of order; judge by
occurred_atand your state machine, and do not overwrite by arrival order. - If a delivered order receives an older "in progress" notification, do not roll back the delivery state.
URLs and security
- The callback URL must use HTTPS and pass platform verification before any delivery starts.
- A changed URL takes effect immediately and the old URL stops receiving deliveries; a URL that fails verification is never enabled.
- Callbacks go only to the address of the shop that owns the order, never across shops.
- Verify the source IP, or accept only requests carrying a valid signature.
Troubleshooting
| Symptom | Check |
|---|---|
| Nothing arrives at all | Whether the URL passed verification, whether a firewall blocks POST, and whether DNS resolves correctly |
| Received but retried repeatedly | Whether you return 2xx within 5 seconds and whether the body is {"code":"OK","msg":""} |
| Duplicate processing | Whether you deduplicate by event_id |
| Corrupted state | Whether you merge by occurred_at rather than arrival order |