Order status callback

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.

postWebhookorderStatus

Headers

X-Faas-Signaturestring required

Hex HMAC-SHA256 of the raw body under your webhook secret. May be a comma-separated list of signatures during a secret-rotation rollover — accept if ANY matches your secret.

X-Faas-Signature-V2string required
Example:t=1767225600,v1=e1f32ca4e1313c2f4f319d7d7499fcf5ac41714d2a995aa06f066b6607c47e65

t=TIMESTAMP,v1=SIGNATURE: TIMESTAMP is the send time in unix seconds (re-stamped on every attempt) and SIGNATURE the hex HMAC-SHA256, under your webhook secret, of the string TIMESTAMP + "." + raw body. The HMAC key is the secret as text (its UTF-8 bytes, not hex-decoded) and the body is the exact bytes received, before any JSON parsing. One v1 per active secret (current first) during a rotation. Accept when any v1 matches (constant-time compare) and TIMESTAMP is within 5 minutes of your clock. The example is the developer guide's test vector (secret whsec_vector_one, TIMESTAMP 1767225600).

X-Faas-Event-Idstring uuid required

The event id, identical on every attempt — the dedup key (equals the body id).

X-Faas-Event-Typestring required

The event type, for example campaign.paid or order.delivered (equals the body type).

Payload

order_idstring uuid required
status'delivered' | 'failed' | 'reversed' | 'expired' required
failure_reasonstring 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_txstring nullable
reversal_txstring 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_messagestring 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}.

idstring 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_atstring date-time

When the event happened. Added in 2.1.0.

Example payload

{
  "failure_reason": "undeliverable"
}

Response

Acknowledged. Any 2xx stops retries.

Changes

Webhooks have no change history: a webhook is keyed by its event name rather than a path and method, so no recorded change can name it.