Rent Twilio numbers
const url = 'https://api.clearance.rest/numbers/providers/twilio/rent';const options = { method: 'POST', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"phone_number":"+14155550100"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.clearance.rest/numbers/providers/twilio/rent \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "phone_number": "+14155550100" }'Buys one or more numbers, points their SMS webhook at the service, and attaches them to your project.
Send phone_number to rent one number, or phone_numbers to rent several. If both are sent, phone_numbers wins and phone_number is ignored. Multiple numbers are rented in parallel and independently: one failing does not stop the others.
The response shape follows the request. phone_number returns a single number; phone_numbers returns a numbers array with one result per number.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
One number to rent, in E.164 format.
Several numbers to rent, in E.164 format.
Examples
{ "phone_number": "+14155550100"}{ "phone_numbers": [ "+14155550100", "+14155550101" ]}Responses
Section titled “Responses”Rented. The shape depends on which parameter you sent.
object
A freshly rented Twilio number.
object
The number’s id. Use it with POST /release.
Twilio’s own PN… SID.
What the number can do. Twilio returns these keys lower-case; mobile and Hero SMS numbers report the same keys.
object
object
object
A freshly rented Twilio number.
object
The number’s id. Use it with POST /release.
Twilio’s own PN… SID.
What the number can do. Twilio returns these keys lower-case; mobile and Hero SMS numbers report the same keys.
object
Examples
{ "success": true, "number": { "sid": "c1aaeac1-ec52-44e2-b00a-d1350fb6bee6", "providerSid": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "phoneNumber": "+14155550100", "friendlyName": "(415) 555-0100", "smsUrl": "https://api.clearance.rest/numbers/callbacks/twilio/sms", "voiceUrl": null, "capabilities": { "voice": true, "sms": true, "mms": true, "fax": false } }}{ "success": true, "numbers": [ { "success": true, "phoneNumber": "+14155550100", "number": { "sid": "c1aaeac1-ec52-44e2-b00a-d1350fb6bee6", "providerSid": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "phoneNumber": "+14155550100", "friendlyName": "(415) 555-0100", "smsUrl": "https://api.clearance.rest/numbers/callbacks/twilio/sms", "voiceUrl": null, "capabilities": { "voice": true, "sms": true, "mms": true, "fax": false } } }, { "success": false, "phoneNumber": "+14155550101", "error": "+14155550101 is not a valid number" } ]}Neither phone_number nor phone_numbers was sent.
Error envelope returned with a non-2xx status.
object
Human-readable error message.
Example
{ "success": false, "error": "phone_number veya phone_numbers zorunludur"}The X-API-Key header is missing or invalid.
Error envelope returned with a non-2xx status.
object
Human-readable error message.
Example
{ "success": false, "error": "geçersiz API anahtarı"}Renting a single number (phone_number) failed. With phone_numbers, failures are reported per number inside a 200.
Error envelope returned with a non-2xx status.
object
Human-readable error message.
Example
{ "success": false, "error": "invalid json body"}