API Docs

Orders API

Last updated

Rent a US phone number, poll for its SMS code, and cancel or re-rent.

Limits: Maximum 100 concurrent active rentals per account; a completed order whose window_ends_at is set counts until then. Orders cannot be cancelled within 60 seconds of purchase.

Order lifecycle

Every order is in one of four states, returned as status:

  • active: waiting for the SMS code. expires_at is the deadline.
  • completed: the code arrived. sms_code is set; this happens on its own, without any call from you.
  • expired: no code arrived. The order expires when its code window ends and its price is credited back to your balance automatically. If a service has a very short code_window_seconds, no code arrives after it, but the order still expires, and is credited back, a few minutes after purchase.
  • cancelled: you cancelled it, at least 60 seconds after purchase. The price is credited back to your balance.

More than one SMS on the same order

On some services the number stays yours after the code arrives, until the order's window_ends_at (set on the order; null otherwise). Every SMS sent to it in that time is added to the same order, in followup_codes and messages, at no extra cost. This is not guaranteed. On a re-rent, window_ends_at can be hours away: until the number leaves the pool (re_rent_until), at most 30 hours. Until window_ends_at the order counts toward your active rental limit, and its re_rent_status is window_open. The service's multiple_sms says whether it can send more than one SMS.

Tip: Best practice: call complete as soon as you have the code you need. It closes the number and frees the slot. After that, re-rent the number to get more codes.
{
  "order": {
    "id": 202,
    "service": "instagram",
    "service_display_name": "Instagram",
    "phone_number": "2025551234",
    "status": "completed",
    "price": 1.30,
    "carrier": null,
    "requested_carrier": null,
    "sms_code": "482913",
    "sms_message": "482913 is your Instagram code.",
    "messages": [
      {
        "code": "482913",
        "text": "482913 is your Instagram code.",
        "received_at": "2026-02-26T22:41:10Z"
      },
      {
        "code": "730155",
        "text": "730155 is your Instagram code.",
        "received_at": "2026-02-26T22:47:31Z"
      }
    ],
    "expires_at": "2026-02-26T22:59:00Z",
    "created_at": "2026-02-26T22:40:00Z",
    "completed_at": "2026-02-26T22:41:10Z",
    "re_rent_until": "2026-02-27T03:00:00Z",
    "re_rent_status": "window_open",
    "window_ends_at": "2026-02-26T23:00:00Z",
    "followup_codes": ["730155"]
  }
}

The order object

Every order endpoint returns orders with these fields.

FieldTypeDescription
idintegerUnique order ID
servicestringService identifier
service_display_namestringHuman-readable service name
phone_numberstringThe rented US number as 10 digits, with no +1 country code and no formatting (e.g. "2025551234"). Add +1 yourself if a form needs E.164.
statusstringOne of: active, completed, cancelled, expired
pricenumberAmount charged in USD
carrierstring or nullThe carrier of the number ("at&t" or "tmobile") when you chose one, or null when you got whichever carrier was available
requested_carrierstring or nullThe carrier you asked for. Equals carrier, except when carrier_fallback "any" bought a number on whichever carrier was available, at the normal price: then carrier is null and this keeps your choice.
sms_codestring or nullReceived SMS code (null until received). Digits come without spaces. For a few services the code is a link plus an ID rather than digits.
sms_messagestring or nullThe full SMS text the code came in, as plain text (null until received). It may contain a link: treat it as untrusted text. Set to null 30 days after the SMS arrived; sms_code stays.
messagesobject[]Every SMS received on the order, oldest first: the one with sms_code, then any follow-up codes. Each item has code, text (the full SMS, or null) and received_at (ISO 8601). Empty until the code arrives. text becomes null 30 days after the SMS arrived; code stays.
expires_atstringDeadline for the SMS code: no code arrives after it. An order with no code expires and is credited back at this time or, for a service whose code window is shorter than most, a few minutes later. ISO 8601.
created_atstringISO 8601 creation timestamp
completed_atstring or nullISO 8601 completion timestamp
re_rent_untilstring or nullThe last moment this phone number can be rented again with POST /v1/orders/{order_id}/re-rent, in UTC (ISO 8601). A limit, not a promise: the number can be taken before then. null when no limit is known.
re_rent_statusstringWhether a re-rent of this order can be tried now. "available": it can (it may still fail if the number was taken). "expired": re_rent_until has passed, and a re-rent is refused with 409 RERENT_EXPIRED, nothing charged. "not_rerentable": the order still holds its number (active or pending) or never got one. "window_open": the order is completed but the number is still yours on it until window_ends_at; a re-rent is refused with 409 RERENT_WINDOW_OPEN, nothing charged. Treat any other value as "available".
window_ends_atstring or nullOn some services the number stays yours after the code arrives, until the order's window_ends_at. Every SMS sent to it in that time is added to the same order, in followup_codes and messages, at no extra cost. This is not guaranteed. On a re-rent it can be hours away: until the number leaves the pool (re_rent_until), at most 30 hours. Until then the order counts toward your active rental limit. POST /v1/orders/{order_id}/complete ends it early. UTC (ISO 8601). null otherwise.
followup_codesstring[]Additional codes received after the order completed. Only present when a follow-up code has actually arrived; the key is omitted from every other response. Available on some services: during the order's rental time (until window_ends_at), and for a small number of services that send another message to the same number later; codes may be alphanumeric. Best effort, no guarantee: delivery depends on the number remaining active. Re-fetch this endpoint later to check. Each follow-up code is also in messages, with its full text.

POST /v1/orders

Rent a US phone number for a service

Request body for buying a number

NameTypeRequiredDescription
servicestringYesService name from GET /v1/services (e.g. "google")
carrierstringNoOptional: choose "at&t" or "tmobile", for about 20% more. You get a number on exactly that carrier; if it has none, the purchase fails with 409 OUT_OF_STOCK (scope "carrier") and nothing is charged. Omit to get whichever carrier is available.
carrier_fallbackstringNoOnly with carrier. "none" (default): fail when that carrier has no numbers. "any": buy a number on whichever carrier is available instead, at the normal price; the order then has carrier null and requested_carrier set to the carrier you asked for.
curl -X POST https://api.diddysms.com/v1/orders \
  -H "Authorization: Bearer dsk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"service": "google", "carrier": "at&t"}'
resp = requests.post(
    "https://api.diddysms.com/v1/orders",
    headers={"Authorization": "Bearer dsk_your_api_key_here"},
    json={"service": "google", "carrier": "at&t"},
)
order = resp.json()["order"]

Response (201 Created)

{
  "order": {
    "id": 200,
    "service": "google",
    "service_display_name": "Google",
    "phone_number": "2025551234",
    "status": "active",
    "price": 1.80,
    "carrier": "at&t",
    "requested_carrier": "at&t",
    "sms_code": null,
    "sms_message": null,
    "messages": [],
    "expires_at": "2026-02-26T22:49:00Z",
    "created_at": "2026-02-26T22:40:00Z",
    "completed_at": null,
    "re_rent_until": "2026-02-27T03:00:00Z",
    "re_rent_status": "not_rerentable",
    "window_ends_at": null
  }
}

If that carrier has no numbers (409 Conflict)

Nothing is charged.

{
  "detail": {
    "error": {
      "code": "OUT_OF_STOCK",
      "message": "T-Mobile numbers for Google are out of stock right now: choose Any as the carrier, or try again in a few minutes.",
      "scope": "carrier"
    }
  }
}

Fall back to whichever carrier is available, at the normal price

Send "carrier_fallback": "any". The order then has carrier: null and requested_carrier keeps your choice.

curl -X POST https://api.diddysms.com/v1/orders \
  -H "Authorization: Bearer dsk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"service": "google", "carrier": "tmobile", "carrier_fallback": "any"}'
{
  "order": {
    "id": 201,
    "service": "google",
    "service_display_name": "Google",
    "phone_number": "2025551234",
    "status": "active",
    "price": 1.50,
    "carrier": null,
    "requested_carrier": "tmobile",
    "sms_code": null,
    "sms_message": null,
    "messages": [],
    "expires_at": "2026-02-26T22:49:00Z",
    "created_at": "2026-02-26T22:40:00Z",
    "completed_at": null,
    "re_rent_until": "2026-02-27T03:00:00Z",
    "re_rent_status": "not_rerentable",
    "window_ends_at": null
  }
}

Error responses

StatusCodeMeaning
400ORDER_ERRORThe purchase was rejected; the message says why. Any charge is credited back automatically.
402INSUFFICIENT_BALANCENot enough funds to purchase
404NOT_FOUNDService does not exist
409OUT_OF_STOCKNo numbers left right now. scope "carrier": none on the chosen carrier (retry without carrier, or send carrier_fallback "any"); scope "service": none for the service. Nothing is charged.
429MAX_RENTALSMaximum 100 concurrent active rentals reached. An order whose window_ends_at is set counts until then; call complete on orders you no longer need.
503SERVICE_UNAVAILABLEService temporarily unavailable. Please try again.

GET /v1/orders

List your orders, or only the active ones

Query parameters for listing orders

NameTypeRequiredDescription
statusstringNoFilter by "active" or omit for all orders
limitintegerNoMax results, 1-100 (default: 20)
offsetintegerNoResults offset (default: 0)
curl "https://api.diddysms.com/v1/orders?status=active" \
  -H "Authorization: Bearer dsk_your_api_key_here"

Response

{
  "orders": [
    {
      "id": 200,
      "service": "google",
      "service_display_name": "Google",
      "phone_number": "2025551234",
      "status": "active",
      "price": 1.50,
      "carrier": null,
      "requested_carrier": null,
      "sms_code": null,
      "sms_message": null,
      "messages": [],
      "expires_at": "2026-02-26T22:49:00Z",
      "created_at": "2026-02-26T22:40:00Z",
      "completed_at": null,
      "re_rent_until": "2026-02-27T03:00:00Z",
      "re_rent_status": "not_rerentable",
      "window_ends_at": null
    }
  ],
  "pagination": {
    "limit": 20,
    "offset": 0,
    "total": 1
  }
}

GET /v1/orders/{order_id}

Get one order, including its SMS code once it arrives

Order status updates in real time as soon as a message arrives.

Path parameter for fetching an order

NameTypeRequiredDescription
order_idintegerYesOrder ID
curl https://api.diddysms.com/v1/orders/200 \
  -H "Authorization: Bearer dsk_your_api_key_here"

Response (the code has arrived)

{
  "order": {
    "id": 200,
    "service": "google",
    "service_display_name": "Google",
    "phone_number": "2025551234",
    "status": "completed",
    "price": 1.50,
    "carrier": null,
    "requested_carrier": null,
    "sms_code": "123456",
    "sms_message": "123456 is your Google verification code.",
    "messages": [
      {
        "code": "123456",
        "text": "123456 is your Google verification code.",
        "received_at": "2026-02-26T22:40:48Z"
      }
    ],
    "expires_at": "2026-02-26T22:49:00Z",
    "created_at": "2026-02-26T22:40:00Z",
    "completed_at": "2026-02-26T22:40:48Z",
    "re_rent_until": "2026-02-27T03:00:00Z",
    "re_rent_status": "available",
    "window_ends_at": null
  }
}
Tip: Poll this endpoint every 3 seconds to check for incoming SMS codes. The sms_code field will be null until a code is received. Stop when status is no longer active.

Error responses

StatusCodeMeaning
404NOT_FOUNDOrder not found

POST /v1/orders/{order_id}/cancel

Cancel an active order and get its price credited back to your balance

Path parameter for cancelling an order

NameTypeRequiredDescription
order_idintegerYesOrder ID
curl -X POST https://api.diddysms.com/v1/orders/200/cancel \
  -H "Authorization: Bearer dsk_your_api_key_here"

Response (200 OK)

The updated order, with status "cancelled". Its price is credited back to your balance.

Recommended whenever you stop waiting for a code: the credit is immediate and the order stops counting toward your active rentals.

If the SMS code arrives while you cancel, the order completes instead: the response is 400 ORDER_ERROR with reason: "code_arrived", and the order is completed and charged like any order that got its code. Fetch the order to read sms_code. Any other ORDER_ERROR means the order is no longer active. It may already be completed with its code, so fetch the order and check sms_code.

If the code arrived while you cancelled (400 Bad Request)

{
  "detail": {
    "error": {
      "code": "ORDER_ERROR",
      "message": "An SMS code arrived for this order, so it was not cancelled.",
      "reason": "code_arrived"
    }
  }
}

Error responses

StatusCodeMeaning
400COOLDOWNCannot cancel within 60 seconds of purchase
400ORDER_ERROROrder is not in "active" status (it may already be completed with its code: check sms_code), or its SMS code arrived while the cancel was being processed: then reason is "code_arrived" and the order is completed with the code and charged
404NOT_FOUNDOrder not found
503SERVICE_UNAVAILABLECould not cancel right now. Please try again.

POST /v1/orders/{order_id}/complete

Check an active order for its SMS code right now, or close a number you no longer need

If the code has arrived, the order comes back completed with sms_code and completed_at set; if not, it comes back unchanged and still active. Orders complete on their own as soon as the code arrives, so polling the order is enough to get the code.

On a completed order whose window_ends_at is set (some services keep the number yours until then), this closes the number and frees its slot in your active rental limit: the order comes back with window_ends_at null. Recommended as soon as you have the code you need. Calling it again on that order answers 200 with the same order. On any other completed, cancelled or expired order it answers 400 ORDER_ERROR.

Path parameter for checking an order

NameTypeRequiredDescription
order_idintegerYesOrder ID
curl -X POST https://api.diddysms.com/v1/orders/200/complete \
  -H "Authorization: Bearer dsk_your_api_key_here"

Error responses

StatusCodeMeaning
400ORDER_ERROROrder is no longer active (already completed, cancelled or expired) and its number is no longer yours (window_ends_at is null)
404NOT_FOUNDOrder not found
503SERVICE_UNAVAILABLECould not check the order right now. Please try again.

POST /v1/orders/{order_id}/re-rent

Rent the phone number from a previous order again

The previous order's re_rent_until is the last moment the number can be rented again, and re_rent_status says whether a re-rent can be tried now. Until then a re-rent can still fail with 409 OUT_OF_STOCK if the number was taken. After it, the re-rent is refused with 409 RERENT_EXPIRED and nothing is charged: buy a new number instead. When re_rent_until is null, no limit is known and you can try. While re_rent_status is window_open, the number is still yours on that order until window_ends_at: a re-rent is refused with 409 RERENT_WINDOW_OPEN and nothing is charged. After it, re_rent_status says whether the number can be rented again. For a few seconds after window_ends_at, while the number is released, a re-rent can still get that answer: retry it a little later. A re-rent of a service with multiple_sms can keep the number on the new order for hours: its window_ends_at can reach re_rent_until, at most 30 hours, and SMS to it in that time are added to that order (not guaranteed). Call complete when you no longer need it, to free the slot.

Path parameter for re-renting a number

NameTypeRequiredDescription
order_idintegerYesOriginal order ID
curl -X POST https://api.diddysms.com/v1/orders/200/re-rent \
  -H "Authorization: Bearer dsk_your_api_key_here"

Response (201 Created)

Returns a new order object with a new ID but the same phone number.

If the re-rent period has ended (409 Conflict)

Nothing is charged.

{
  "detail": {
    "error": {
      "code": "RERENT_EXPIRED",
      "message": "The re-rent period for this number has ended.",
      "re_rent_until": "2026-02-27T03:00:00Z"
    }
  }
}

If the number is still yours on that order (409 Conflict)

Nothing is charged.

{
  "detail": {
    "error": {
      "code": "RERENT_WINDOW_OPEN",
      "message": "This number is still active on this order.",
      "window_ends_at": "2026-02-26T23:00:00Z"
    }
  }
}

Error responses

StatusCodeMeaning
400ORDER_ERRORCannot re-rent this order
402INSUFFICIENT_BALANCENot enough funds
404NOT_FOUNDOrder not found
409OUT_OF_STOCKThat number can't be rented again right now. Any charge is credited back automatically; buy a new number instead.
409RERENT_EXPIREDThe order's re_rent_until has passed, so the number can no longer be rented again. Nothing is charged; buy a new number instead.
409RERENT_WINDOW_OPENThe number is still yours on this order until its window_ends_at, which the error repeats. Nothing is charged. After it, re_rent_status says whether the number can be rented again.
429MAX_RENTALSMaximum 100 concurrent active rentals reached. An order whose window_ends_at is set counts until then; call complete on orders you no longer need.
503SERVICE_UNAVAILABLECould not re-rent right now. Please try again.