Import phone number
Phone numbers
Import phone number
POST /v1/phone-numbers
POST
Import phone number
Imports an existing Twilio number under one of your agents. Configures all webhooks (voice, SMS, recording status) to point at Nixflex automatically.
Request
Body parameters
| Field | Type | Required | Notes |
|---|---|---|---|
phone_number | string | Yes | E.164 format (+44...). Must already exist in your Twilio account |
twilio_sid | string | Yes | Customer’s Twilio Account SID, format AC + 32 hex chars |
twilio_token | string | Yes | Customer’s Twilio Auth Token |
agent_id | string | Yes | Must be an agent you own |
camelCase versions also work:
phoneNumber, twilioSid, twilioToken, agentId.Response
201 Created:
What this does
- Validates phone format and Twilio SID format
- Verifies the number exists in your Twilio account using the credentials
- Confirms the agent belongs to your Nixflex account
- Overwrites Twilio’s webhooks on that number (voice, SMS, status callbacks) to point at Nixflex
- Inserts a
phone_numbersrow linking number → agent → API key
Errors
| Code | HTTP | Cause |
|---|---|---|
missing_field | 400 | One of the 4 required fields is empty |
invalid_phone_format | 400 | Phone number not in E.164 format |
invalid_twilio_sid | 400 | SID doesn’t match ^AC[a-f0-9]{32}$ |
agent_not_found | 404 | agent_id doesn’t exist |
agent_not_owned | 403 | Agent exists but belongs to a different API key |
number_not_in_twilio | 404 | Number not in customer’s Twilio account |
twilio_invalid_credentials | 401 | SID + token combination rejected by Twilio |
twilio_auth_failed | 401 | Twilio error code 20003 |
number_already_imported | 409 | Number already attached to another agent |