curl --request POST \
--url "https://api.nixflex.com/v1/phone-numbers" \
--header "Authorization: Bearer $NIXFLEX_API_KEY" \
--header "Content-Type: application/json" \
--data-binary @import.json
import Nixflex from 'nixflex';
import { readFileSync } from 'node:fs';
const baseUrl = 'https://api.nixflex.com';
const client = new Nixflex({apiKey:process.env.NIXFLEX_API_KEY,baseUrl,maxRetries:0});
const result = await client.phoneNumbers.import(JSON.parse(readFileSync("import.json","utf8")));
// Handle result privately; do not log secrets or call content.
import os, json
from pathlib import Path
from nixflex import Nixflex
base_url = "https://api.nixflex.com"
with Nixflex(os.environ["NIXFLEX_API_KEY"], base_url=base_url,max_retries=0) as client:
result = client.phone_numbers.import_(**json.loads(Path("import.json").read_text()))
# AsyncNixflex supports the same calls with await (and async with).
nixflex numbers import --body @import.json --base-url https://api.nixflex.com --json
{
"phone_number": {
"phone_number": "+12025550100",
"agent_id": "agent_0123456789abcdef",
"inbound_enabled": true,
"outbound_enabled": true
}
}
Phone numbers
Import a phone number
Import a phone number you own into Nixflex and assign it to an active agent. Review existing routing before changing the number configuration.
POST
/
phone-numbers
curl --request POST \
--url "https://api.nixflex.com/v1/phone-numbers" \
--header "Authorization: Bearer $NIXFLEX_API_KEY" \
--header "Content-Type: application/json" \
--data-binary @import.json
import Nixflex from 'nixflex';
import { readFileSync } from 'node:fs';
const baseUrl = 'https://api.nixflex.com';
const client = new Nixflex({apiKey:process.env.NIXFLEX_API_KEY,baseUrl,maxRetries:0});
const result = await client.phoneNumbers.import(JSON.parse(readFileSync("import.json","utf8")));
// Handle result privately; do not log secrets or call content.
import os, json
from pathlib import Path
from nixflex import Nixflex
base_url = "https://api.nixflex.com"
with Nixflex(os.environ["NIXFLEX_API_KEY"], base_url=base_url,max_retries=0) as client:
result = client.phone_numbers.import_(**json.loads(Path("import.json").read_text()))
# AsyncNixflex supports the same calls with await (and async with).
nixflex numbers import --body @import.json --base-url https://api.nixflex.com --json
{
"phone_number": {
"phone_number": "+12025550100",
"agent_id": "agent_0123456789abcdef",
"inbound_enabled": true,
"outbound_enabled": true
}
}
FIXED · account A number belongs to an account and agent. On a shared agent always pass that customer’s eligible from_number.
NOT OFFERED → do this instead · number Fixed welcome_message, language, general timezone and pickup delay belong to the agent. Use Dynamic greeting and the number’s custom_prompt for its opening. Split agents for different fixed settings.
YOU CAN CHANGE · number PATCH fields below. Clearing depends on the field. Null record_call or require_booking_confirmation inherits. Use the number’s voicemail controls.
Use the real values only in your private server request. For example, a Twilio import needs four fields:
calcom_timezone_override, custom_prompt, voice_id, sms_reply_enabled, sms_prompt, web_prompt, speaking_rate, dtmf_enabled, require_booking_confirmation, record_call, recording_source, voicemail_leave_enabled, voicemail_message.
SCOPE · number Import an owned carrier number, assign an agent, edit its channels or remove its Nixflex connection.
For a different greeting per business, keep Dynamic greeting on (the default) and put the opening line in that number’s custom_prompt. For example, “Start every call with: Thank you for calling Oak and Stone”.
Read the compact AI rules
Connect a number you already own to an active agent on the same account. Import can replace existing number routing, so another application using that routing can stop receiving calls or texts.
Method: POST ·
Success: 201 ·
Scope: Owning account
The important part
Import requires an owned number and carrier credentials authorised to manage it. Send international E.164 format with 7–15 digits. Passing the format check does not establish country, voice or SMS coverage. Check the number’s capabilities with the carrier. Twilio trial accounts can restrict outbound calls to verified destinations (carrier error 21219). Send the Account SID (starts with -
Server-side import is supported. Send
POST /v1/phone-numberswith exactly one carrier credential set. Import can replace the number’s existing routing. Confirm the customer owns the number and authorises that change. - This connects an existing supported number to the account.
- A pending import is not permission to send; wait for a usable state.
AC) and Auth Token of the carrier account or subaccount that holds the number; API key SIDs (SK…) are rejected with a 400 error.
Authentication
SendAuthorization: Bearer KEY_ID:KEY_SECRET using the owning account’s server-side credential. Send Content-Type: application/json.
Request fields
Send the owned phone number, its active agent and one carrier credential set from your server. The number and agent are the public identifiers. Those neutral fields alone are not a successful import. Add credentials for the carrier account that holds the number.| Field | Type | Required | Default | Limits and meaning |
|---|---|---|---|---|
phone_number | string | Yes | None | Business number. Up to 64 input characters; spaces, hyphens, parentheses and dots are removed before E.164 validation. Maximum 64 characters. |
agent_id | string | Yes | None | Owned active agent identifier; trimmed, nonblank, at most 200 characters. Maximum 200 characters. |
twilio_sid | string | Twilio | None | Account SID beginning with AC followed by 32 hexadecimal characters. |
twilio_token | string | Twilio | None | Private auth token for that carrier account. |
telnyx_api_key | string | Telnyx | None | Private API key for the carrier account. |
telnyx_connection_id | string | Telnyx | None | Connection ID for the number’s voice application. |
telnyx_public_key | string | Optional for Telnyx | Omitted | Public callback verification key. Use canonical base64 for exactly 32 bytes. |
custom_prompt | string or null | No | null | Optional number-specific prompt, at most 8,000 characters. Maximum 8000 characters. |
phone_number, agent_id, twilio_sid and twilio_token. For Telnyx, replace the last two with telnyx_api_key and telnyx_connection_id.
Unknown import fields are refused. Use only one connection credential set; do not mix it with another. custom_prompt does not configure the remaining per-number switches. If custom_prompt is omitted, it is saved as null; import does not copy the agent instructions. A later prompt update is a separate request that must be checked independently.
Response fields
201 Created returns the shape below. Nullable fields can be unknown or unset; do not turn null into zero or false.
| Field | Type | Meaning |
|---|---|---|
phone_number | object | Neutral fields from the imported number. Legacy identifier fields may also be present. |
phone_number.phone_number | string | Imported business number. |
phone_number.agent_id | string | Agent to which the number is attached. |
phone_number.inbound_enabled | boolean | Inbound calls are enabled on successful import. |
phone_number.outbound_enabled | boolean | Outbound calls are enabled on successful import. |
Example request
Prepare the request body as a privateimport.json file using the table above. The examples send it from your server using NIXFLEX_API_KEY. Keep the file out of logs and source control. SDK and CLI examples require Node/CLI 0.11.0 or later and Python 0.4.0 or later.
curl --request POST \
--url "https://api.nixflex.com/v1/phone-numbers" \
--header "Authorization: Bearer $NIXFLEX_API_KEY" \
--header "Content-Type: application/json" \
--data-binary @import.json
import Nixflex from 'nixflex';
import { readFileSync } from 'node:fs';
const baseUrl = 'https://api.nixflex.com';
const client = new Nixflex({apiKey:process.env.NIXFLEX_API_KEY,baseUrl,maxRetries:0});
const result = await client.phoneNumbers.import(JSON.parse(readFileSync("import.json","utf8")));
// Handle result privately; do not log secrets or call content.
import os, json
from pathlib import Path
from nixflex import Nixflex
base_url = "https://api.nixflex.com"
with Nixflex(os.environ["NIXFLEX_API_KEY"], base_url=base_url,max_retries=0) as client:
result = client.phone_numbers.import_(**json.loads(Path("import.json").read_text()))
# AsyncNixflex supports the same calls with await (and async with).
nixflex numbers import --body @import.json --base-url https://api.nixflex.com --json
Example response
Illustrative201 response. Identifiers and values are examples; some optional or compatibility fields are omitted.
{
"phone_number": {
"phone_number": "+12025550100",
"agent_id": "agent_0123456789abcdef",
"inbound_enabled": true,
"outbound_enabled": true
}
}
Errors
Failures return anerror object with code, message, doc_url and optional details. Each code links to the shared error catalog. Read the message and details before deciding whether to resend.
| Status | Code | Meaning | What to do |
|---|---|---|---|
| 400 | invalid_phone_format | The number format is invalid. | Use a complete E.164 number. |
| 403 | account_unavailable | The account is not active. | Resolve account access before attempting another number operation. |
| 409 | number_operation_pending | Another import or removal is pending. | Read the current number and wait; do not change its routing. |
| 409 | number_cleanup_uncertain | A previous routing change is unconfirmed. | Contact support to reconcile it before importing or removing again. |
| 503 | number_cleanup_uncertain | The routing outcome from this attempt is unconfirmed. | Do not resend or change routing; reconcile through support. |
| 503 | number_save_pending | Routing changed but local completion could not be confirmed. | Read current state and contact support; never replay automatically. |
| 503 | number_operation_unavailable | The operation could not be confirmed. | Reconcile the number before another write. |
| 400 | missing_field | A required number, agent or connection value is missing. | Complete the privately prepared import payload; do not invent credential aliases. |
| 400 | unknown_field | An unsupported import field was supplied. | Use PATCH separately for other number settings. |
| 400 | conflicting_fields | Two aliases supplied conflicting values. | Supply each value once. |
| 400 | mixed_provider_credentials | More than one connection credential set was supplied. | Use the single connection that owns this number. |
| 400 | custom_prompt_too_long | The prompt exceeds 8,000 characters. | Shorten the number-specific prompt. |
| 403 | agent_not_owned | The target agent belongs to another account. | Choose an agent owned by the authenticated account. |
| 404 | agent_not_found | The target agent does not exist. | Use a returned agent ID. |
| 409 | agent_unavailable | The target agent is not active. | Choose an active owned agent. |
| 409 | number_already_imported | The number is already imported. | Read the existing number; use PATCH for a deliberate move or settings change. |
| 409 | number_release_pending | A prior release needs reconciliation. | Wait for its outcome to be resolved. |
| 401 | unauthorized | The credential is missing or invalid. | Check the full account credential. |
| 429 | rate_limit_exceeded | The account request limit was reached. | Wait for Retry-After. Reconcile uncertain writes before resending. |
Retry and idempotency
Never automatically retry an import. Save any returned operation_id from safe error details. A pending completion may allow an exact, deliberate reconciliation request after state is checked; an uncertain routing outcome needs support. Do not re-import to work around number_cleanup_uncertain.Related endpoints
Authorizations
Body
application/json
Send the number and its active owned agent with exactly one complete carrier credential set. Keep credentials on your server.
- Option 1
- Option 2
Send the number and its active owned agent with exactly one complete carrier credential set. Keep credentials on your server.