Documentation Index
Fetch the complete documentation index at: https://docs.nixflex.com/llms.txt
Use this file to discover all available pages before exploring further.
Imports an existing Twilio number under one of your agents. Configures all webhooks (voice, SMS, recording status) to point at Nixflex automatically.
Request
curl -X POST https://api.nixflex.com/v1/phone-numbers \
-H "Authorization: Bearer KEY_ID:KEY_SECRET" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "+447446466847",
"twilio_sid": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"twilio_token": "your_twilio_auth_token",
"agent_id": "agent_125207e452f8714a"
}'
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:
{
"phone_number": {
"phone_number": "+447446466847",
"agent_id": "agent_125207e452f8714a",
"twilio_number_sid": "PN451e0ddf654327e36baab58dfbcd30d6",
"inbound_enabled": true,
"outbound_enabled": true
}
}
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_numbers row linking number → agent → API key
Importing replaces all existing webhooks on the Twilio number. If you have other systems using this number, they will stop receiving calls or SMS.
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 |
Use case: reseller onboarding
// 1. Buy a Twilio number from your Twilio account
const twilio = require('twilio')(YOUR_TWILIO_SID, YOUR_TWILIO_TOKEN);
const available = await twilio.availablePhoneNumbers('GB').local.list({ limit: 1 });
const purchased = await twilio.incomingPhoneNumbers.create({
phoneNumber: available[0].phoneNumber
});
// 2. Attach it to your Nixflex agent
await fetch('https://api.nixflex.com/v1/phone-numbers', {
method: 'POST',
headers: {
'Authorization': `Bearer ${NIXFLEX_KEY_ID}:${NIXFLEX_KEY_SECRET}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
phone_number: purchased.phoneNumber,
twilio_sid: YOUR_TWILIO_SID,
twilio_token: YOUR_TWILIO_TOKEN,
agent_id: 'agent_your_template'
})
});