How It Works
- Number Selection: Use a phone number from the search results
- Provider Purchase: The system purchases the number from the specified provider
- Automatic Configuration: Webhooks are automatically configured for voice and SMS
- Database Registration: The number is added to your organization’s phone number inventory
- 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 formatprovider(string, required): Provider to use ("twilio"or"telnyx")assistant_id(integer, optional): ID of the assistant to assign this number tofriendly_name(string, optional): Custom display name for the number
Request
Response
A successful request returns a200 OK status with purchase confirmation.
Response
Response Fields
success(boolean): Whether the purchase completed successfullyphone_number(string): The purchased phone numberprovider(string): Provider used for the purchase (“twilio” or “telnyx”)purchase_details(object): Provider-specific purchase information- For Twilio:
sid(string): Twilio phone number SIDfriendly_name(string): Display namevoice_url(string): Configured voice webhook URLsms_url(string): Configured SMS webhook URLcapabilities(object): Number capabilitiesdate_created(string): Purchase timestamp
- For Telnyx:
id(string): Telnyx order IDstatus(string): Order status (“completed”, “pending”, etc.)connection_id(string): Associated connection IDdate_created(string): Purchase timestamp
- For Twilio:
message(string): Human-readable confirmation message
Error Responses
400 Bad Request
Returned when the request contains invalid data.- Invalid
providervalue (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.- 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 anassistant_id, the system:
- Assigns Ownership: Links the number to the specified assistant
- Configures Provider: Uses the assistant’s configured telephony provider
- Sets Webhooks: Configures appropriate webhook URLs based on provider
- 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
- 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
- Verify Availability: Always search before purchasing
- Check Pricing: Confirm costs, especially setup fees
- Assistant Readiness: Ensure the target assistant is properly configured
- Provider Selection: Choose the provider that best fits your needs
Error Handling
Implement robust error handling for common purchase failures:Cost Management
- Monitor Spending: Track number purchases across providers
- Compare Costs: Evaluate monthly costs vs. setup fees
- Bulk Purchases: Consider purchasing multiple numbers for volume discounts
- Regular Audits: Review and release unused numbers
Security Considerations
- API Key Protection: Secure your API keys
- Purchase Validation: Validate purchases in your application
- Audit Logging: Log all purchase activities
- Access Control: Restrict purchase permissions to authorized users
Troubleshooting
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| ”Number not available” | Number purchased by someone else | Search for new numbers |
| ”Insufficient balance” | Account balance too low | Add funds to provider account |
| ”Invalid credentials” | Wrong API keys | Check provider credentials |
| ”Assistant not found” | Invalid assistant ID | Verify assistant exists |
Provider-Specific Issues
Twilio:- Ensure account is verified for international numbers
- Check geographic permissions for certain area codes
- Verify connection ID is correct
- Ensure account has number purchasing enabled
Support
If you encounter persistent issues:- Check provider account status
- Verify API credentials
- Contact provider support for account-specific issues
- Reach out to Burki support for integration help