---
title: "Order status callback"
method: POST
path: "orderStatus"
---

# Order status callback

`POST orderStatus` (webhook)

When an order reaches a terminal status (`delivered`, `failed`,
`reversed`, `expired`) we `POST` this event to your `callback_url`.
Nothing is sent for `cancelled` (the cancel answer is the
confirmation), for the older `completed` status, or while an order is
`held` (not terminal).

Verify authenticity with the `X-Faas-Signature` header — it's the
hex `HMAC-SHA256` of the **exact raw request body** under your webhook
secret (the standard Stripe/GitHub signing scheme). The HMAC key is the
secret exactly as you were shown it, as text (its UTF-8 bytes): do not
hex-decode it. Compute over the bytes you received, before any JSON
parsing, and compare in constant time. Respond `2xx` to
acknowledge. The body (and signature) are stable across every attempt,
so a receiver that deduplicates on either sees one logical event.

**Retries.** A `5xx`, a `3xx` (redirects are not followed), a timeout or
a connection error gets up to 5 immediate attempts with exponential
backoff (pauses of about 7.5 seconds in all between them; each attempt
can itself take up to 10 seconds), then up to 10 further replays, about
one a minute — roughly **10 minutes** from the first attempt to the last.
A slow endpoint or a busy replay queue can stretch that window. After that the event is abandoned and
not redelivered automatically: an endpoint that is down for longer misses
it. Poll `GET /v1/orders/{id}` (or `GET /v1/orders?status=…`) for any
order that has not reached a terminal status in your records — the order
status is always authoritative, the callback is a notification. A `4xx` stops the
immediate burst — it is your endpoint's verdict, and repeating the same
request seconds later cannot change it — but the event is still queued,
and a `4xx` on a replay abandons it there and then.

Two `4xx` codes are the exception. `408 Request Timeout` and `429 Too
Many Requests` mean "not now" rather than "not ever", so they keep the
full set of spaced replays instead of being abandoned. They still get no
immediate retries: the burst completes in about 7.5 seconds, and
hammering an endpoint that just asked us to slow down only spends your
rate limit faster.

**Delivery constraints.** Your endpoint must respond within **5 seconds**
(connect + headers + body timeout each), and each attempt ends after **10
seconds** in total. The status code is the verdict: a status received in
time stands even if the response body is still arriving (it is cut off);
no status within the deadline counts as a timeout. HTTP redirects are not followed —
the `callback_url` must be the final destination. Retrying never blocks
order processing. Every `POST` carries
`User-Agent: MyStars-FaaS-Webhook/1.0 (+https://mystars.tg)` — allowlist
it if a bot-protection rule sits in front of your endpoint.

**Secret rotation (rollover).** During the grace window after you rotate
your webhook secret, this header may carry **multiple comma-separated
signatures** (the new and the previous secret). Treat the header as a
comma-separated list and accept the request if **any** entry matches your
secret — so you can switch from the old secret to the new one at any point
in the window without dropping a webhook. Outside a rotation it is a single
signature, so naive single-value verification keeps working day to day.
You rotate with `/api_rotate_webhook` in the bot; the previous secret keeps
signing for 24 hours, and a new rotation is refused until that window has
closed (contact support if a secret leaked inside it).

**Signature V2 and event identity (additive).** Every callback also
carries `X-Faas-Signature-V2` — the same HMAC computed over the send time
and the body, so a receiver can refuse a replayed capture — plus
`X-Faas-Event-Id` (stable across attempts) and `X-Faas-Event-Type`
(`order.delivered` and so on). The body gains `id`, `type` and
`created_at` after the existing fields. Existing `X-Faas-Signature`
verifiers keep working unchanged.

## Headers

- `X-Faas-Signature` string, required
- `X-Faas-Signature-V2` string, required
- `X-Faas-Event-Id` string, uuid, required
- `X-Faas-Event-Type` string, required

## Payload

- object
  - `order_id` string, uuid, required
  - `status` 'delivered' | 'failed' | 'reversed' | 'expired', required
  - `failure_reason` string, nullable: Why a non-`delivered` order ended where it did — `underpaid` / `overpaid` (amount mismatch → `failed`, funds reversed), `no_memo` / `wrong_memo` (no longer set: a payment with a missing / unrecognised memo is reversed to its sender and never changes an order; orders failed earlier may still carry them), `wrong_currency` (paid in the other asset than `payment_currency` → the payment reversed to the sender in the asset received, then `failed`), `undeliverable` (`reversed`, funds reversed), or `expired` (no payment within the window). Null on `delivered`. See **Reversals & delivery** above for the full meaning of each.
  - `purchase_tx` string, nullable
  - `reversal_tx` string, nullable: The reference (transaction hash) of the reversal that returned your payment, as it stands when the webhook is sent. On `order.failed` and `order.reversed` only (since 2.1.4); absent on `order.delivered` and `order.expired`. `null` while no reversal has gone out — for example one that is still being retried — or when it was confirmed without a reference we can show (contact support); never a placeholder. A reversal that goes out later sends no webhook: read it from `GET /v1/orders/{id}`.
  - `telegram_message` string, nullable: Fragment's verbatim text of the last refusal it gave for this order, present only on `failed` or `reversed` orders; `null` when Fragment never refused it. For example "You can buy a minimum of 12,500 stars". On `order.failed` and `order.reversed` only (since 2.3.0); absent on `order.delivered` and `order.expired`. The same text is in `telegram_message` of `GET /v1/orders/{id}`.
  - `id` string, uuid: The event id, identical on every attempt (also in `X-Faas-Event-Id`). Added in 2.1.0.
  - `type` 'order.delivered' | 'order.failed' | 'order.reversed' | 'order.expired': The event type (also in `X-Faas-Event-Type`). Added in 2.1.0.
  - `created_at` string, date-time: When the event happened. Added in 2.1.0.

## Acknowledgement `200`

Acknowledged. Any 2xx stops retries.

---

[API](https://skmtc.dev/mystars/apis/mystars-faas-fulfilment-api.md) - [All operations](https://skmtc.dev/mystars/apis/mystars-faas-fulfilment-api/llms.txt) - [OpenAPI document](https://skmtc.dev/mystars/apis/mystars-faas-fulfilment-api/revisions/b6cdc8aff8c2?raw)
