Phone numbers
List, buy and release your numbers, and forward their calls. Each number is billed monthly at your price, first month up front, no setup fee: see Billing. Buying needs a card on file (Settings → Billing).
#The Phone number object
idinteger | null- The number’s id, the
phone_number_idfrom the purchase.nullfor an iMessage line. typestringsmsfor a phone number,imessagefor one of your iMessage lines. Lines show only in the unpaged List numbers; manage them with iMessage lines.phone_numberstring- The number, like
+14155550100. While it’s being set up it’s a placeholder like"Pending (415)", not a phone number. statusstring- Only
activecan send, and an active number sends only whilecampaign_idisn’tnullandrestingisfalse: a new number has nocampaign_iduntil Ready attaches it to a registration campaign, which usually takes 35 to 110 minutes. New values may be added: treat any value butactiveas not sendable.provider_rejectedandpayment_declinednever turnactiveby themselves: the values below say what to do.Possible values
status Meaning activeCan send. pending_provisioning,pendingBeing set up. No current number has pending: it is an older value kept so old code still matches.phone_numberis a placeholder like"Pending (415)", not a phone number.provider_rejected,payment_declinedFailed. Stop polling. For provider_rejected, pick a new area code with Replace a rejected number;payment_declinedis set up again once your card is charged.billing_suspended,suspendedCan’t send. billing_suspended: the number’s monthly charge lapsed. Click Reactivate on its row in Numbers (or callPOST /numbers/:id/reactivate) to pay the monthly fee and bring it back; adding a new card alone won’t.suspended: held for a review. It stays this way until the review clears, so email support.released,inactive,retired,cancelled,canceledNo longer in use. No current number has canceled(one l): it is an older spelling kept so old code still matches.deletedReleased. Hidden from the list. GET /v1/numbers/:idanswers eitherstatus: "deleted"or404 number_not_foundfor a released number; both mean released. created_atstring- When the number was added, ISO 8601.
webhook_urlstring or null- The number’s own webhook, or
nullwhen it uses your account webhook. See Set a number’s webhook. namestring | null- The number’s label. Set it with Rename a number.
forward_to_numberstring | null- Where its calls ring, or
null. See Forward calls. campaign_idstring | null- The id of the registration campaign it sends under, a long id like
"8f3c2a1e-5b7d-4e09-9c41-0a6e2d7b3f15"(not the short registry id that starts withC), ornullwhile it has none. See Move a number to another registration campaign. shared_registrationbooleantruewhencampaign_idis Ready’s shared registration campaign, which numbers of an account without its own approved campaign send under;falsewhen it is your own campaign ornull. A non-nullcampaign_idalone does not mean your own registration is live: check this field, orGET /v1/registration.daily_capinteger | null- The most texts it sends in a day, or
nullfor no cap. See Set a number’s daily cap. use_for_texting,use_for_callingboolean- Whether Ready picks it for texts and offers it as a caller ID. See Use a number for texting or calling.
restingbooleantruewhile it’s resting: Ready doesn’t pick it as a sender. See Rest a number.rested_untilstring | null- When the rest ends, ISO 8601, or
nullwhen it isn’t resting. A rest until you resume shows a date years away, and so does a rest Ready set because the number’s registration is full (NUMBER_CAMPAIGN_FULLon resume): treat a date more than a year out as open-ended. spamobject- Spam signals for the number.
Child attributes
spam.sms_flaggedboolean- Flagged by web spam reports.
spam.sms_reportsinteger- How many web spam reports.
spam.sms_checked_atstring | null- When the reports were last checked.
spam.caller_flaggedbooleantruewhen carriers label the number Spam Likely.spam.caller_flagged_atstring | null- When the latest check found the label. It moves forward on each recheck while the number stays flagged, and it is kept (not cleared) after the label goes, so read
caller_flaggedfor the current state.nullif the number was never flagged.
account_idinteger- The account that holds the number. Only with
include_sub_accounts=trueon List numbers.
#List numbers
Every number on the account, newest first, including pending and failed ones, so check status. Send limit to page it.
Parameters
include_sub_accountsstring · query- Send
trueto also list the numbers of your own other business accounts and of sub-accounts you pay for (billing agency). For an independent sub-account, call withX-Sub-Account-Id. Each number then hasaccount_id.Who gets extra numbers
Only an agency (an account that has sub-accounts) gets extra numbers. A sub-account or any other account gets its own numbers, withaccount_idadded. Any other value is ignored. limitinteger · query- Page size, up to 500. Without
limitandbefore_idyou get every number in one answer. With either, the answer is paged newest id first (id order is not purchase order: a number from Ready’s ready stock keeps an older id, so readcreated_atto find the newest) and carrieshas_moreandnext_before_id. before_idinteger · query- Send the
next_before_idfrom the previous page to get the next one. Loop untilhas_moreisfalse.
Returns a list of Phone number objects in data.
Returns
has_moreboolean- Only when you send
limitorbefore_id.truewhen there’s another page. next_before_idinteger- Only when you send
limitorbefore_id. Send it asbefore_idfor the next page.nullon an empty page.
Errors
| HTTP | Code | When |
|---|---|---|
| 500 | internal_error | Read failed. Safe to retry. |
curl "https://api.tryready.com/v1/numbers" \
-H "X-API-Key: $READY_API_KEY"
const res = await fetch('https://api.tryready.com/v1/numbers', {
headers: {
'X-API-Key': process.env.READY_API_KEY,
},
signal: AbortSignal.timeout(95 * 1000),
});
const json = await res.json().catch(() => ({}));
if (!res.ok || json.success === false) {
throw new Error(`${res.status}${json.error_code || json.code ? ' ' + (json.error_code || json.code) : ''}: ${json.error || json.message || res.statusText} (request ${res.headers.get('x-request-id')})`);
}
import os, requests
r = requests.get(
"https://api.tryready.com/v1/numbers",
headers={"X-API-Key": os.environ["READY_API_KEY"]},
timeout=95,
)
data = r.json() if r.headers.get("content-type", "").startswith("application/json") else {}
if not r.ok or data.get("success") is False:
raise RuntimeError(f'{r.status_code} {data.get("error_code") or data.get("code") or ""}: {data.get("error") or data.get("message") or r.reason} (request {r.headers.get("x-request-id")})')
{
"success": true,
"data": [
{
"id": 2648,
"phone_number": "Pending (415)",
"status": "pending_provisioning",
"created_at": "2026-10-01T19:02:44.310Z",
"webhook_url": null,
"spam": {
"sms_flagged": false,
"sms_reports": 0,
"sms_checked_at": null,
"caller_flagged": false,
"caller_flagged_at": null
}
},
{
"id": 2647,
"phone_number": "+14155550100",
"status": "active",
"created_at": "2026-07-29T00:12:04.512Z",
"webhook_url": "https://app-b.example.com/ready-webhook",
"spam": {
"sms_flagged": false,
"sms_reports": 0,
"sms_checked_at": "2026-10-30T08:00:12.004Z",
"caller_flagged": false,
"caller_flagged_at": null
}
}
]
}
#Get a number
One number. The number_active and number_rejected webhooks tell you when a purchase settles; if you can’t take webhooks, poll this after a purchase until it’s ready, and stop if it becomes provider_rejected or payment_declined. If a buy answer was lost, read the number here before you buy again. It answers for any number your key could release, so a team member’s key also reads the numbers held by the account owner it works for. After you release a number this returns status: "deleted" or a 404.
Parameters
idinteger · pathRequired- The
phone_number_idfrom the purchase.
Returns a Phone number object in data.
Errors
| HTTP | Code | When |
|---|---|---|
| 404 | number_not_found | Not on this account. The other number pages answer the same case as NUMBER_NOT_FOUND; both spellings are stable, so compare codes without regard to case. |
curl "https://api.tryready.com/v1/numbers/2647" \
-H "X-API-Key: $READY_API_KEY"
const res = await fetch('https://api.tryready.com/v1/numbers/2647', {
headers: {
'X-API-Key': process.env.READY_API_KEY,
},
signal: AbortSignal.timeout(95 * 1000),
});
const json = await res.json().catch(() => ({}));
if (!res.ok || json.success === false) {
throw new Error(`${res.status}${json.error_code || json.code ? ' ' + (json.error_code || json.code) : ''}: ${json.error || json.message || res.statusText} (request ${res.headers.get('x-request-id')})`);
}
import os, requests
r = requests.get(
"https://api.tryready.com/v1/numbers/2647",
headers={"X-API-Key": os.environ["READY_API_KEY"]},
timeout=95,
)
data = r.json() if r.headers.get("content-type", "").startswith("application/json") else {}
if not r.ok or data.get("success") is False:
raise RuntimeError(f'{r.status_code} {data.get("error_code") or data.get("code") or ""}: {data.get("error") or data.get("message") or r.reason} (request {r.headers.get("x-request-id")})')
{
"success": true,
"data": {
"id": 2647,
"phone_number": "+14155550100",
"status": "active",
"created_at": "2026-07-29T00:12:04.512Z",
"spam": {
"sms_flagged": false,
"sms_reports": 0,
"sms_checked_at": "2026-10-30T08:00:12.004Z",
"caller_flagged": false,
"caller_flagged_at": null
}
}
}
{
"success": false,
"error": "We can't find that number on this account. Get its id from GET /v1/numbers.",
"error_code": "number_not_found",
"code": "number_not_found"
}
#Start a number purchase
Check an area code, start a purchase, then buy with its payment_intent_id. This pays the first month on your saved card and returns the payment to buy with. Checkouts share a ceiling of 20 a minute. Needs the manage_phones permission.
Parameters
Idempotency-Keystring · header- Recommended. Retry safely without paying twice. A retry with the same key gets the first answer back, even if the body changed.
area_codestring- Required for a US number. The 3-digit area code to buy in. For another country, leave it out; only
CAreads it, as a Canadian area code. checkout_idstring- Your own id for this purchase, a UUID. A retry with the same UUID gets the same checkout back, so it never charges twice. Anything that isn’t a UUID is refused with
400checkout_id_invalid. Leave it out and the retry is covered only by theIdempotency-Key(or, with neither, a two-minute window). countrystringAU,CAorGBbuys a number in Australia, Canada or United Kingdom where Ready has opened that country; one not open yet answers400country_unavailable. ForCA,area_codemay name a Canadian area code; any other code answers400area_code_invalid(“Pick a Canadian area code.”). Without one we pick the number. The UK and Australia have no area code, and it is ignored. Leave it out for a US number.replaces_phone_idinteger- The id of one of your numbers this purchase replaces. Send the same value to Buy a number. When the new number can text, Ready moves sends off the old one and releases it. Leave it out for an ordinary buy.
Returns
reusedboolean- Beside
data, only when it istrue: this was a retry of the samecheckout_id, answered with its first payment instead of a new one. Nothing was charged again. data.payment_intent_idstring- Pass it to Buy a number. Treat it as an opaque string: it starts with
pi_when a card was charged, but a test key or an account that isn’t charged gets an id that doesn’t (a test key’s starts withtest-). When nothing is owed the response ischarged: falsewithexemptandincludedflags. Don’t check for api_prefix. data.charged, data.authorizedboolean- Checkout either charges or holds the first month. If the number can’t be provisioned, the hold is released or the charge refunded.
data.card_brand, data.card_last4string- The card used.
data.client_secret, data.has_cardstring, boolean- Instead of the above when there’s no card on file. The API can’t finish that payment: add a card in Settings → Billing and call again.
data.bank_check, data.payment_method_idboolean, string- When your bank wants your saved card confirmed (3-D Secure),
bank_checkistrue,chargedandauthorizedarefalse, and there’s nopayment_intent_id. Nothing is charged. The API can’t open the bank’s window: buy the number in the app, where you confirm it with your bank.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | area_code_invalid | Missing, not 3 digits, or starts with 0 or 1. For country: "CA", a code that is not Canadian. |
| 400 | country_unavailable | Ready doesn’t sell numbers in that country yet. |
| 400 | checkout_id_invalid | checkout_id isn’t a UUID. Nothing was charged. |
| 402 | card_declined | Card refused. Also card_authentication_required. |
| 402 | PURCHASE_BLOCKED | Unpaid bill or account review. |
| 409 | area_code_unavailable | No stock; see alternatives. |
| 409 | purchase_in_progress | Another purchase is running, or this checkout_id’s payment is still going through: retry in a minute with the same checkout_id. Also campaign_number_limit (your registration is full, see Buy a number). |
| 409 | checkout_id_in_use | That checkout_id belongs to another account’s purchase. Nothing was charged. Start a new checkout with a new UUID. |
| 409 | checkout_finished | That checkout_id already ran to its end (it bought a number, its payment was returned, or the card or bank check didn’t go through). Nothing was charged again. The error sentence says which; start a new checkout with a new UUID. |
| 409 | country_sold_out | A Canadian order with no stock right now. Nothing was charged. |
| 502 | checkout_unconfirmed | Your card may have been charged or held. Check Billing or contact support before you start another checkout; a retry with the same checkout_id never charges twice. |
| 503 | checkout_unavailable | Nothing charged. Also availability_check_unavailable, cap_check_unavailable, billing_check_unavailable, billing_account_unavailable, number_price_unavailable, payments_unavailable. |
curl -X POST "https://api.tryready.com/v1/numbers/checkout" \
-H "X-API-Key: $READY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"area_code": "415"
}'
const res = await fetch('https://api.tryready.com/v1/numbers/checkout', {
method: 'POST',
headers: {
'X-API-Key': process.env.READY_API_KEY,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
"area_code": "415"
}),
});
const json = await res.json().catch(() => ({}));
if (!res.ok || json.success === false) {
throw new Error(`${res.status}${json.error_code || json.code ? ' ' + (json.error_code || json.code) : ''}: ${json.error || json.message || res.statusText} (request ${res.headers.get('x-request-id')})`);
}
import os, uuid, requests
key = str(uuid.uuid4()) # make it once; reuse it if you retry
r = requests.post(
"https://api.tryready.com/v1/numbers/checkout",
headers={"X-API-Key": os.environ["READY_API_KEY"], "Idempotency-Key": key},
json={
"area_code": "415"
},
timeout=95, # 5 s past the request deadline
)
data = r.json() if r.headers.get("content-type", "").startswith("application/json") else {}
if not r.ok or data.get("success") is False:
raise RuntimeError(f'{r.status_code} {data.get("error_code") or data.get("code") or ""}: {data.get("error") or data.get("message") or r.reason} (request {r.headers.get("x-request-id")})')
{
"success": true,
"data": {
"charged": true,
"authorized": false,
"card_brand": "visa",
"card_last4": "4242",
"payment_intent_id": "pi_3Q8aZx2eZvKYlo2C0a1b2c3d"
}
}
{
"success": true,
"data": {
"client_secret": "pi_3Q8aZx2eZvKYlo2C0a1b2c3d_secret_x8Y",
"has_card": false
}
}
#Buy a number
Provisions the number you paid for at checkout. Buys share a ceiling of 20 a minute. Needs the manage_phones permission.
Parameters
Idempotency-Keystring · header- Recommended. Retry safely. Use a new key for each new purchase.
area_codestring- Required for a US number. The area code you checked out with. The number comes from this one. Leave it out for an overseas number; only
CAreads it, as a Canadian area code. countrystring- The same
countryyou checked out with, for a number in Australia, Canada or United Kingdom. replaces_phone_idinteger- The id of one of your numbers this purchase replaces. Send the same value at checkout and when you buy. When the new number can text, Ready moves sends off the old one and releases it; the answer’s
replaced_phone_idechoes it. Leave it out for an ordinary buy. payment_intent_idstringRequireddata.payment_intent_idfrom checkout. Each one provisions exactly one number.
Returns
phone_number_idinteger- The number’s id; store it.
idis the same value. Poll it withGET /v1/numbers/:id, and send from the number withfrom. instantbooleantrue: the number is ready now andphone_numberis real.false: Ready ordered it from the carrier; there’s nophone_numberyet.pending_provisioningbooleantrue: being set up, usually within a few minutes; poll untilactive.pending_campaign_approvalbooleantrue: your own registration isn’t approved yet.can_send_nowboolean- On an instant buy of a US number.
false: the number can’t text until your registration is approved (usually 2 to 7 days). A number on Ready’s shared registration can text now, and so can a new account sending its first 500 texts (see Sending caps). replaced_phone_id, noteinteger | null, string- The number replaced, if any (instant buy only), and a sentence on what happens next.
overflow_registration_startedboolean- Present, and
true, only when your registration already held the most numbers carriers allow, so Ready started a second one for you at no cost.notesays so. The number texts on Ready’s shared registration until the new one is approved, then moves onto it by itself.
Errors
A refusal after you paid carries charge_returned. true: your payment was returned. false: Ready couldn’t confirm it was returned, so contact support before you buy again, or you could pay twice. It’s left out when you weren’t charged.
| HTTP | Code | When |
|---|---|---|
| 400 | area_code_invalid | Missing, not 3 digits, or starts with 0 or 1. For country: "CA", a code that is not Canadian. |
| 400 | payment_intent_required | Also payment_not_confirmed, payment_not_for_number, payment_not_taken, payment_not_expected. |
| 400 | payment_unverified | We couldn’t confirm the payment, so no number was added. charge_returned says whether the payment was returned: true, try again in a minute; false, contact support before you try again. |
| 400 | invalid_field | A field has the wrong type. |
| 400 | no_campaign | Your account has no registration and Ready’s shared one isn’t available. |
| 400 | payment_order_mismatch | The payment was for a number in a different country. Nothing was added and the payment is unchanged. |
| 400 | payment_refunded | The payment was already returned. Nothing was added; start the purchase again. |
| 402 | PURCHASE_BLOCKED | Account under review. An unpaid bill doesn’t block a buy already paid at checkout. |
| 403 | payment_not_owned | Another account’s payment. |
| 409 | payment_intent_already_used | This payment already bought one. |
| 409 | purchase_in_progress | The purchase is still going through. Wait and check GET /v1/numbers; don’t buy again. |
| 409 | campaign_number_limit | Your registration already has the most numbers carriers allow on one, and Ready can’t open a second one for you (the registration is an agency’s, or no shared registration is available), or the second one is still in review with that many numbers already waiting for it. Release a number you no longer use, or try again once the second registration is approved. |
| 409 | area_code_unavailable | Sold out between checkout and buy. |
| 500 | buy_incomplete | Not finished. Don’t buy again: check GET /v1/numbers. |
| 500 | buy_failed | The buy failed. Try again in a minute. If charge_returned is true, your payment was returned, so start a new checkout. If it is false, contact support before you buy again. |
| 502 | carrier_submit_failed | The carrier refused the order. Try another area code, with a new checkout unless charge_returned is false; then contact support first. |
| 502 | order_unconfirmed | The carrier didn’t confirm the order, so it may have gone through. Don’t buy again: check GET /v1/numbers, then contact support. Your payment was kept, not returned. |
| 503 | payment_check_unavailable | We couldn’t check the payment, so nothing was added or changed. Try again in a minute. |
| 503 | payment_claim_unavailable | We couldn’t safely start the purchase. Contact support before buying again. |
| 503 | provision_cap | Ready has paused new number orders for the rest of today. Nothing was ordered. Try again tomorrow; a number in a different area code may work now. |
| 503 | availability_check_unavailable | Ready couldn’t check where to add your number, so none was added. Retry in a minute. |
| 503 | order_not_started | Ready was restarting, so no carrier order was placed. Try again in a minute; charge_returned says whether your payment went back. |
| 503 | billing_check_unavailable | Retry. Also payments_unavailable. |
curl -X POST "https://api.tryready.com/v1/numbers" \
-H "X-API-Key: $READY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"area_code": "415",
"payment_intent_id": "pi_3Q8aZx2eZvKYlo2C0a1b2c3d"
}'
const res = await fetch('https://api.tryready.com/v1/numbers', {
method: 'POST',
headers: {
'X-API-Key': process.env.READY_API_KEY,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
"area_code": "415",
"payment_intent_id": "pi_3Q8aZx2eZvKYlo2C0a1b2c3d"
}),
});
const json = await res.json().catch(() => ({}));
if (!res.ok || json.success === false) {
throw new Error(`${res.status}${json.error_code || json.code ? ' ' + (json.error_code || json.code) : ''}: ${json.error || json.message || res.statusText} (request ${res.headers.get('x-request-id')})`);
}
import os, uuid, requests
key = str(uuid.uuid4()) # make it once; reuse it if you retry
r = requests.post(
"https://api.tryready.com/v1/numbers",
headers={"X-API-Key": os.environ["READY_API_KEY"], "Idempotency-Key": key},
json={
"area_code": "415",
"payment_intent_id": "pi_3Q8aZx2eZvKYlo2C0a1b2c3d"
},
timeout=95, # 5 s past the request deadline
)
data = r.json() if r.headers.get("content-type", "").startswith("application/json") else {}
if not r.ok or data.get("success") is False:
raise RuntimeError(f'{r.status_code} {data.get("error_code") or data.get("code") or ""}: {data.get("error") or data.get("message") or r.reason} (request {r.headers.get("x-request-id")})')
{
"success": true,
"instant": true,
"id": 2647,
"phone_number_id": 2647,
"phone_number": "+14155550100",
"pending_provisioning": false,
"pending_campaign_approval": false,
"replaced_phone_id": null,
"can_send_now": true,
"note": "Your number is ready now. You can start texting immediately."
}
#Replace a rejected number
Orders a new number in another area code for a number the carrier rejected (status provider_rejected). There’s no charge: you paid when you bought it. The number keeps its id and goes back to pending_provisioning; poll Get a number until it’s active. US numbers only. Needs the manage_phones permission.
Path parameters
idintegerRequired- The number id.
Body parameters
area_codestringRequired- A 3-digit US area code. Check it first with Check an area code.
Returns
pending_provisioningbooleantrue: the order is in.phone_number_idinteger- The same number id.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | area_code_invalid | Not a 3-digit US area code. |
| 400 | no_campaign | Register your business first. |
| 404 | NUMBER_NOT_FOUND | No rejected number with this id on your account. A second call after a replacement was ordered also answers this. |
| 409 | reprovision_not_available | The number is for another country. Contact support. |
| 409 | campaign_number_limit | Your registration already has the most numbers carriers allow on one. Release a number you no longer use, or contact support about a second registration. |
| 503 | provision_cap | Ready has paused new number orders for the rest of today. Nothing was ordered. Try again tomorrow; a number in a different area code may work now. |
| 409 | reprovision_in_progress | A replacement for this number is already being ordered. Wait; don’t send it again. |
| 409 | number_released | The number was released while its replacement was being ordered, so it stays released. |
| 502 | reprovision_failed | Ready couldn’t get a number in that area code right now. Try a different area code, or try again later. |
| 502 | reprovision_unconfirmed | Ready couldn’t confirm whether the carrier took the order. Do not retry: a second order may be placed. Ready staff have been alerted and will finish it; the number shows as being set up until then. |
| 500 | reprovision_incomplete | The carrier took the order but Ready couldn’t save it. Do not retry: a second order would be placed. Contact support. |
| 503 | reprovision_claim_unconfirmed | Ready couldn’t confirm the replacement’s status. Refresh in a minute with GET /v1/numbers/:id before trying again. |
| 503 | number_owner_unavailable | Ready couldn’t check the number’s account. Nothing was ordered; try again. |
| 503 | campaign_check_unavailable | Ready couldn’t check your registration. Nothing was ordered; try again in a minute. |
| 503 | availability_check_unavailable | Ready couldn’t check where to add the number. Nothing was ordered; try again in a minute. |
| 503 | number_check_unavailable | Ready couldn’t check the number or your campaign. Nothing was ordered; try again in a minute. |
curl -X POST "https://api.tryready.com/v1/numbers/2647/reprovision" \
-H "X-API-Key: $READY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"area_code": "303"
}'
const res = await fetch('https://api.tryready.com/v1/numbers/2647/reprovision', {
method: 'POST',
headers: {
'X-API-Key': process.env.READY_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"area_code": "303"
}),
signal: AbortSignal.timeout(95 * 1000),
});
const json = await res.json().catch(() => ({}));
if (!res.ok || json.success === false) {
throw new Error(`${res.status}${json.error_code || json.code ? ' ' + (json.error_code || json.code) : ''}: ${json.error || json.message || res.statusText} (request ${res.headers.get('x-request-id')})`);
}
import os, requests
r = requests.post(
"https://api.tryready.com/v1/numbers/2647/reprovision",
headers={"X-API-Key": os.environ["READY_API_KEY"]},
json={
"area_code": "303"
},
timeout=95,
)
data = r.json() if r.headers.get("content-type", "").startswith("application/json") else {}
if not r.ok or data.get("success") is False:
raise RuntimeError(f'{r.status_code} {data.get("error_code") or data.get("code") or ""}: {data.get("error") or data.get("message") or r.reason} (request {r.headers.get("x-request-id")})')
{
"success": true,
"pending_provisioning": true,
"phone_number_id": 2647
}
See also: the guide to doing this in the app.