Skip to main content

Numbers API

The Numbers API allows you to manage phone numbers for your telephony operations.
Prerequisites: Make sure you have your API Token. See Authentication for details.

Get Telephony Numbers

Retrieve a list of all telephony numbers in the system along with their details and current status.
GET /api/v2/platform/telephony/numbers/

Headers

NameTypeRequiredDescription
AuthorizationstringYesAPI Key format: Token <token>
Org-HandlestringYesOrganization domain handle
You can get the Org-Handle by hitting the Get All Organizations API. The domain_handle field in the response is your Org-Handle.

Example Request

GET /api/v2/platform/telephony/numbers/
Headers:
  Authorization: Token your-api-token
  Org-Handle: your-org-handle

Success Response (200)

{
  "status_code": 200,
  "message": "Telephony numbers fetched successfully.",
  "data": [
    {
      "id": 183,
      "number": "+1234567890",
      "active": true
    }
  ]
}

Response Fields

FieldTypeDescription
status_codeintegerHTTP status code
messagestringResponse message
dataarrayArray of number objects

Number Object Fields

FieldTypeDescription
idintegerNumber unique identifier
numberstringPhone number in E.164 format
activebooleanWhether the number is active

Error Response (400 — Bad Request)

{
  "status_code": 400,
  "message": "Organization handle is required in Org-Handle header."
}

Error Response (401 — Unauthorized)

{
  "status_code": 401,
  "message": "Authentication credentials were not provided."
}

Common Error Codes

Status CodeDescription
200Success - Request completed successfully
400Bad Request - Org-Handle header missing
401Unauthorized - Invalid or missing API token
403Forbidden - Access denied to the resource
500Internal Server Error - Server-side error

Code Examples

const axios = require('axios');

const headers = {
  'Authorization': 'Token your-api-token',
  'Org-Handle': 'your-org-handle'
};

// Get all telephony numbers
const getNumbers = async () => {
  const response = await axios.get(
    'https://unpod.dev/api/v2/platform/telephony/numbers/',
    { headers }
  );
  console.log(`Total numbers: ${response.data.data.length}`);
  response.data.data.forEach(num => {
    console.log(`${num.number} - Active: ${num.active}`);
  });
  return response.data.data;
};

// Example usage
getnumbers();

Best Practices

  1. E.164 Format: Phone numbers are returned in E.164 format (e.g., +1234567890)
  2. Org-Handle Required: Always include the Org-Handle header in your requests
  3. Error Handling: Always handle potential errors and implement retry logic
  4. Security: Keep API tokens secure and rotate them regularly