Rent a number
const url = 'https://api.clearance.rest/numbers/rent';const options = { method: 'POST', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"type":"temporary","country":"example","service":"example","operator":"example","phone_number":"example","line_type":"local","max_price":1,"metadata":{"additionalProperty":"example"}}'};
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/rent \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "type": "temporary", "country": "example", "service": "example", "operator": "example", "phone_number": "example", "line_type": "local", "max_price": 1, "metadata": { "additionalProperty": "example" } }'temporary: a short-lived number for receiving one verification SMS (service required); the price is held first (the cap, max_price or about twice the catalog price) and the hold is released when the rental fails; the amount charged is the actual rental price and the rest of the hold is returned. monthly: a number you keep for a month at a time; the first month is charged now and renewed every month.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”What to rent: a temporary number for a target service or a monthly number.
object
ISO 3166-1 alpha-2 country code (e.g. US).
Target service code (temporary).
Operator (temporary, optional).
A number from /numbers/catalog/available (monthly).
Line type to search when phone_number is omitted (monthly, default local).
Highest price in USD you accept; the request fails with 409 max_price_too_low when it is below the current catalog price. Temporary numbers: the catalog price is tried first and higher prices only up to this value; without it the limit is about twice the catalog price.
Free-form JSON object (at most 16 KB, 5 levels deep, keys up to 64 characters).
object
Responses
Section titled “Responses”Default Response
object
A number of the project with its status and metadata.
object
UTC timestamp (ISO 8601).
UTC timestamp (ISO 8601).
Increases on every change; use it in If-Match.
Amount charged in USD.
Available balance after the charge in USD.
Example
{ "success": true, "item": { "type": "temporary", "status": "ACTIVE" }}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}Default Response
Error envelope returned by every JSON endpoint.
object
object
Machine-readable error code (snake_case).
Human-readable message.
Extra context for the error.
object
Example
{ "success": false}