Create an order (buy a number)
Buys a temporary number for the given service and country. The order
stays pending until a number is allocated (usually within seconds),
then becomes active; when the SMS code arrives it becomes
completed.
Billing: your wallet is charged when the number is successfully
allocated, not at creation — while the order is pending,
amount_cents is 0 and no funds have moved. If allocation fails
(failed), you are never charged.
Price is resolved server-side — you cannot self-quote. The
resolved price is the same price_cents that GET /catalog/prices
shows for this service and country at that moment (default tier) —
or, when you pass channel_id, that channel's price_cents in
GET /catalog/channels. The create response returns it as
price_cents (omitted when an Idempotency-Key replay returns an
existing order).
Pass max_price_cents to protect against price moves between your
catalog read and the purchase: if the resolved price exceeds your
cap by more than 5%, a 412 PRICE_CHANGED is returned instead
of charging you. Note the 5% tolerance — with max_price_cents: 100
you may still be charged up to 105 cents; treat it as drift
protection, not an exact budget ceiling.
If you omit max_price_cents, the price locked at order time is
your cap (same 5% tolerance). You are normally charged exactly the
locked price; if the number can only be supplied at a higher price,
the charge can rise up to 5% above your cap. When no number can be
allocated within the cap, the order ends as failed with
NO_NUMBERS_AVAILABLE and you are not charged. Send a higher
max_price_cents if you prefer a higher fill rate over price.
Ordering a specific channel: pass a channel_id from
GET /catalog/channels. service_code, country_code and tier
may then be omitted; if you send them, they must match the channel.
The number comes only from that channel: if it cannot supply one,
the order ends as failed with NO_NUMBERS_AVAILABLE and you are
not charged — it is never moved to another channel. A channel that
is no longer available returns 422 CHANNEL_UNAVAILABLE and no order
is created.
Supports idempotency: pass a UUID in the Idempotency-Key header;
retrying with the same key returns the original order (with its
current live status) instead of buying twice.
Receive the allocated number and SMS code by polling
GET /orders / GET /orders/{id}, or through the
order.number_allocated and order.completed webhook events.
Accounts with polling disabled (abuse review) instead get a fixed
pending creation acknowledgement (amount_cents: 0) without
phone/SMS/live status — even on idempotent replay — and receive all
lifecycle updates through webhooks.
whatsapp. Required unless channel_id is sent; if sent with it, must match the channel.US. Required unless channel_id is sent; if sent with it, must match the channel.standard. With channel_id, optional and must match the channel if sent.channel_id from GET /catalog/channels. The order is placed
only on that channel, at its price_cents; if the channel cannot
supply a number the order fails and you are not charged.
412 PRICE_CHANGED instead of charging you — i.e. with a cap of
100 you may still be charged up to 105. Not an exact budget
ceiling. When omitted, the price locked at order time is used as
the cap (with the same 5% tolerance); do not send 0.
| Name | Type | Required | Description |
|---|---|---|---|
| Idempotency-Key | string (uuid) | Optional | UUID; retries with the same key return the original order. |
curl -X POST "https://api.dogesms.com/v1/orders" \ -H "Authorization: Bearer sk_live_…" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{"service_code":"whatsapp","country_code":"US"}'
Order accepted (pending). Track it by polling or webhooks. For accounts with polling disabled (abuse review) this is a fixed creation acknowledgement even on idempotent replay: no phone, SMS, live status, or settled amount is returned.
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 |
|---|---|---|
| 400 | VALIDATION_ERROR CURRENCY_MISMATCH | Validation error (VALIDATION_ERROR, CURRENCY_MISMATCH) — including a missing service_code / country_code without channel_id, an unknown channel_id, or service_code / country_code / tier that do not match it. |
| 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. |
| 412 | PRICE_CHANGED | PRICE_CHANGED — current price exceeds your max_price_cents; re-read the catalog and retry. |
| 422 | INSUFFICIENT_BALANCE WALLET_NOT_INITIALIZED SERVICE_NOT_AVAILABLE CHANNEL_UNAVAILABLE | INSUFFICIENT_BALANCE, WALLET_NOT_INITIALIZED, SERVICE_NOT_AVAILABLE, or CHANNEL_UNAVAILABLE (the channel_id is delisted, suspended, or temporarily unavailable — pick another channel from GET /catalog/channels). No order is created. |
| 429 | RATE_LIMITED RATE_LIMITED_DAILY TOO_MANY_ACTIVE_ORDERS | Branch on code and honour Retry-After:
- RATE_LIMITED / RATE_LIMITED_DAILY: wait until the indicated reset.
- TOO_MANY_ACTIVE_ORDERS: wait for current orders to finish.
|
Branch on code, not on the message. Full list: Errors.