Skip to main content
POST
/
api
/
v1
/
providers
/
twilio
/
{id}
/
import-numbers
Import phone numbers
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({phoneNumberSids: ['<string>']})
};

fetch('https://blackbox.dasha.ai/api/v1/providers/twilio/{id}/import-numbers', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "successCount": 123,
  "failedCount": 123,
  "errors": [
    {
      "phoneNumberSid": "<string>",
      "errorMessage": "<string>"
    }
  ]
}

Import Process

For each phone number SID provided:
  1. Validates the SID exists in your Twilio account
  2. Checks for duplicate imports (already imported numbers are skipped with error)
  3. Attaches the phone number to the provider’s SIP trunk in Twilio
  4. Creates a local phone number record linked to the provider

Partial Success

The import operation continues even if some numbers fail. The response includes:
FieldDescription
successCountNumber of successfully imported phone numbers
failedCountNumber of phone numbers that failed to import
errorsDetailed error information for each failure

Common Errors

ErrorCause
Not foundPhone number SID doesn’t exist in Twilio account
Already importedPhone number was previously imported for this provider
Trunk attachment failedTwilio API error when attaching to trunk

After Import

Imported phone numbers can be:
  • Listed via the phone numbers API
  • Linked to agents for inbound call handling
  • Used for outbound call caller ID

Path Parameters

id
string<uuid>
required

Provider identifier

Body

Phone number SIDs to import

Request DTO for importing phone numbers from a Twilio account into the system. Specifies which phone numbers to import by their Twilio Phone Number SIDs.

phoneNumberSids
string[]
required

List of Twilio Phone Number SIDs to import. Each SID must be a valid Twilio Phone Number SID starting with 'PN' followed by 32 lowercase hexadecimal characters. Format: PN[a-f0-9]{32} (e.g., PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).

Response

Import completed with detailed results (may include partial failures)

Result of a phone number import operation. Contains counts of successfully imported and failed phone numbers, along with detailed error information for any failures.

successCount
integer<int32>

Number of phone numbers successfully imported into the system.

failedCount
integer<int32>

Number of phone numbers that failed to import.

errors
object[] | null

Detailed error information for each phone number that failed to import. Empty if all phone numbers were imported successfully.