Skip to main content
POST
This endpoint allows you to purchase a phone number from Twilio or Telnyx and automatically configure it for use with your AI assistants. The purchased number is immediately ready to receive calls and can be assigned to an assistant.

How It Works

  1. Number Selection: Use a phone number from the search results
  2. Provider Purchase: The system purchases the number from the specified provider
  3. Automatic Configuration: Webhooks are automatically configured for voice and SMS
  4. Database Registration: The number is added to your organization’s phone number inventory
  5. Assistant Assignment: Optionally assign the number to an assistant immediately
Instant Activation: Purchased numbers are immediately active and ready to receive calls and messages. No additional configuration required.

Request Body

The request body is a JSON object containing purchase details.
  • phone_number (string, required): The phone number to purchase in E.164 format
  • provider (string, required): Provider to use ("twilio" or "telnyx")
  • assistant_id (integer, optional): ID of the assistant to assign this number to
  • friendly_name (string, optional): Custom display name for the number
Request

Response

A successful request returns a 200 OK status with purchase confirmation.
Response

Response Fields

  • success (boolean): Whether the purchase completed successfully
  • phone_number (string): The purchased phone number
  • provider (string): Provider used for the purchase (“twilio” or “telnyx”)
  • purchase_details (object): Provider-specific purchase information
    • For Twilio:
      • sid (string): Twilio phone number SID
      • friendly_name (string): Display name
      • voice_url (string): Configured voice webhook URL
      • sms_url (string): Configured SMS webhook URL
      • capabilities (object): Number capabilities
      • date_created (string): Purchase timestamp
    • For Telnyx:
      • id (string): Telnyx order ID
      • status (string): Order status (“completed”, “pending”, etc.)
      • connection_id (string): Associated connection ID
      • date_created (string): Purchase timestamp
  • message (string): Human-readable confirmation message

Error Responses

400 Bad Request

Returned when the request contains invalid data.
Common causes:
  • Invalid provider value (must be “twilio” or “telnyx”)
  • Invalid phone number format (must start with ’+’)
  • Invalid assistant_id (assistant doesn’t exist)

404 Not Found

Returned when the specified assistant doesn’t exist.

500 Internal Server Error

Returned when the purchase fails at the provider level.
Common causes:
  • Number no longer available
  • Insufficient account balance
  • Provider API error
  • Invalid provider credentials

Purchase Workflow

Complete Purchase Flow

Provider Differences

Twilio Purchase

  • Immediate Activation: Number is instantly active
  • Webhook Configuration: Voice and SMS URLs automatically set
  • Billing: Charged to your Twilio account
  • Features: Full voice, SMS, MMS support

Telnyx Purchase

  • Order-Based: Purchase creates an order that typically completes instantly
  • Connection Assignment: Number assigned to specified connection ID
  • Billing: Charged to your Telnyx account
  • Features: Voice, SMS, MMS support with competitive pricing

Use Cases

Scaling Customer Support

Purchase numbers for different regions:

Multi-Brand Management

Assign different numbers to different assistants:

Geographic Expansion

Establish local presence in new markets:

Advanced Features

Automatic Assistant Assignment

When you provide an assistant_id, the system:
  1. Assigns Ownership: Links the number to the specified assistant
  2. Configures Provider: Uses the assistant’s configured telephony provider
  3. Sets Webhooks: Configures appropriate webhook URLs based on provider
  4. Enables Features: Activates voice and SMS capabilities

Webhook Configuration

Twilio Numbers: Automatically configured with:
  • Voice URL: https://yourdomain.com/twiml
  • SMS URL: https://yourdomain.com/twiml
Telnyx Numbers: Automatically configured with:
  • Webhook URL: https://yourdomain.com/telnyx-webhook
  • Connection ID from assistant or organization settings

Integration Examples

Node.js

Python

PHP

Best Practices

Pre-Purchase Validation

  1. Verify Availability: Always search before purchasing
  2. Check Pricing: Confirm costs, especially setup fees
  3. Assistant Readiness: Ensure the target assistant is properly configured
  4. Provider Selection: Choose the provider that best fits your needs

Error Handling

Implement robust error handling for common purchase failures:

Cost Management

  1. Monitor Spending: Track number purchases across providers
  2. Compare Costs: Evaluate monthly costs vs. setup fees
  3. Bulk Purchases: Consider purchasing multiple numbers for volume discounts
  4. Regular Audits: Review and release unused numbers

Security Considerations

  1. API Key Protection: Secure your API keys
  2. Purchase Validation: Validate purchases in your application
  3. Audit Logging: Log all purchase activities
  4. Access Control: Restrict purchase permissions to authorized users
Billing Impact: Phone number purchases result in immediate charges to your telephony provider account. Ensure you have sufficient account balance and proper billing alerts configured.

Troubleshooting

Common Issues

Provider-Specific Issues

Twilio:
  • Ensure account is verified for international numbers
  • Check geographic permissions for certain area codes
Telnyx:
  • Verify connection ID is correct
  • Ensure account has number purchasing enabled

Support

If you encounter persistent issues:
  1. Check provider account status
  2. Verify API credentials
  3. Contact provider support for account-specific issues
  4. Reach out to Burki support for integration help

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request model for purchasing a phone number.

phone_number
string
required

Phone number to purchase in E.164 format

provider
string
required

Provider to use ('twilio', 'telnyx', 'vonage', or 'byo-sip-trunk')

country_code
string | null

ISO-2 country code (e.g. US, GB). Auto-derived from phone number if not provided.

assistant_id
integer | null

Assistant to assign the number to

friendly_name
string | null

Friendly name for the number

messaging_profile_id
string | null

Telnyx messaging profile ID to assign the number to

Response

Successful Response

Response model for phone number purchase.

success
boolean
required
provider
string
required
message
string
required
phone_number
string | null
purchase_details
Purchase Details · object | null