Cancel an order (refund)
Cancels an order that has not received an SMS yet. If the number was
already allocated (order charged), the charge is refunded; a still
pending order was never charged. Allowed only after a 2-minute
cooldown from creation (422 CANCEL_TOO_EARLY before that).
Cancellation may be temporarily refused while the SMS could still be
in transit (409 CANCEL_DENIED_RETRY_LATER) — the order stays
active and keeps waiting for the SMS; retry in a few minutes or let
the order expire for an automatic refund.
Cancelling an order that is already terminal returns 200 with
the order's full current state (idempotent replay) — always check
status in the response: a completed order was charged and is
NOT refunded by this call; only status: cancelled means the charge
was released.
For accounts with polling disabled (abuse review), the terminal case
returns 409 ORDER_ALREADY_TERMINAL instead, and a successful
cancellation returns a fixed cancelled acknowledgement
(amount_cents: 0) without phone/SMS/live fields.
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | Required | — |
curl -X POST "https://api.dogesms.com/v1/orders/3f6c2a9e-8b1d-4c7a-9e2f-5d4b1a7c0e93/cancel" \ -H "Authorization: Bearer sk_live_…"
Cancellation accepted, or idempotent replay for an already-terminal order — branch on status: cancelled = charge released; completed = SMS was delivered and the charge stands. For accounts with polling disabled (abuse review), this is a fixed cancelled acknowledgement without phone, SMS, settled amount, or other live fields.
0 while pending — the wallet is charged on successful number allocation, not at creation.+ and country calling code (e.g. +12015550123). Numbers delivered in national format together with the calling code are completed to E.164 before being returned. In rare cases the number still does not start with the calling code of country_code; such a number is passed through exactly as received, which may lack the +. Present while the order is active and kept on completed. Omitted from the response once the order reaches a refunded terminal state (expired / cancelled / failed), same as before allocation — store it from the allocation response/webhook if you need it later.completed. Digit-group separators are removed: a code the sender formats as 123-456 or 123 456 is returned as 123456. sms_content always keeps the original text.completed.failed. NO_NUMBERS_AVAILABLE: no number could be allocated (never charged). SMS_NOT_RECEIVED: a number was allocated but was released before any SMS arrived (charge refunded). Orders whose activation window simply runs out end as expired, not failed.channel_id the order was placed with. Present only for orders placed by channel.POST /orders response that created the order (omitted on an idempotent replay and in order queries); the charge is amount_cents once the number is allocated, normally equal to this.| Status | Code | When |
|---|---|---|
| 401 | API_KEY_MISSING API_KEY_INVALID_FORMAT API_KEY_INVALID API_KEY_REVOKED | Missing or invalid API key (API_KEY_MISSING, API_KEY_INVALID_FORMAT, API_KEY_INVALID, API_KEY_REVOKED). Emitted by the auth layer before the handler — flat shape, no request_id. |
| 403 | ACCOUNT_BANNED EMAIL_NOT_VERIFIED ACCOUNT_NOT_ACTIVE | Key is valid but the account is not eligible (ACCOUNT_BANNED, EMAIL_NOT_VERIFIED, ACCOUNT_NOT_ACTIVE). Emitted by the auth layer — flat shape. |
| 404 | ORDER_NOT_FOUND | ORDER_NOT_FOUND — no such order under your account. |
| 409 | CANCEL_DENIED_RETRY_LATER ORDER_ALREADY_TERMINAL | CANCEL_DENIED_RETRY_LATER — cancellation temporarily unavailable (SMS may still arrive), order stays active, retry in a few minutes; or ORDER_ALREADY_TERMINAL — returned for the already-terminal case only when polling is disabled for the account (with polling enabled the terminal case replays 200 + current state instead). |
| 422 | CANCEL_TOO_EARLY | CANCEL_TOO_EARLY — wait out the 2-minute cooldown. |
Branch on code, not on the message. Full list: Errors.