Skip to main content
POST
/
import-number
Import number
curl --request POST \
  --url https://app.phonely.ai/api/import-number \
  --header 'Content-Type: application/json' \
  --header 'X-Authorization: <api-key>' \
  --data '{
  "uid": "<string>",
  "agentId": "<string>",
  "source": "<string>",
  "twilioAccountSid": "<string>",
  "twilioAuthToken": "<string>",
  "phoneNumber": "<string>",
  "countryCode": "<string>"
}'
{
  "message": "<string>"
}
Imports a phone number from Twilio to use with an agent.

Request

Method: POST
Endpoint: /api/import-number
Headers:
  • X-Authorization: Your API key (required)
  • Content-Type: application/json
Request Body:
{
  "uid": "string",
  "agentId": "string",
  "source": "string",
  "twilioAccountSid": "string",
  "twilioAuthToken": "string",
  "phoneNumber": "string",
  "countryCode": "string"
}
Parameters:
  • uid (string, required): Your user ID
  • agentId (string, required): The ID of the agent to assign the phone number to
  • source (string, required): Must be “twilio” (only Twilio is currently supported)
  • twilioAccountSid (string, required): Your Twilio Account SID
  • twilioAuthToken (string, required): Your Twilio Auth Token
  • phoneNumber (string, required): The phone number to import
  • countryCode (string, required): The country code for the phone number

Response

Success Response (200):
{
  "message": "string"
}
Error Responses:
  • 400 Bad Request: Invalid request body, invalid source, or agent already has a phone number
  • 401 Unauthorized: Invalid or missing API key, or insufficient permissions
  • 500 Internal Server Error: Agent not found, user needs paid plan, or server error

Example

curl -X POST https://app.phonely.ai/api/import-number \
  -H "X-Authorization: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "uid": "user123",
    "agentId": "agent456",
    "source": "twilio",
    "twilioAccountSid": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "twilioAuthToken": "your-twilio-auth-token",
    "phoneNumber": "+1234567890",
    "countryCode": "US"
  }'

Notes

  • Only Twilio phone numbers are currently supported
  • The agent must be on a paid plan to import phone numbers
  • The agent cannot already have a business phone number assigned
  • This operation has a maximum duration of 60 seconds

Authorizations

X-Authorization
string
header
required

Body

application/json
uid
string
required

User ID

agentId
string
required

Agent ID (agent should not have a phone number assigned yet)

source
string
required

Phone number source (currently only supports 'twilio')

twilioAccountSid
string
required

Twilio account SID

twilioAuthToken
string
required

Twilio auth token

phoneNumber
string
required

Phone number to import, includes country code. i.e +10123456789

countryCode
string
required

Country code of the phone number, ISO 3166-1 alpha-2 format

Response

Successful response

message
string

Message indicating the result of the operation