Phone Number Management & Outbound Calling
This document provides comprehensive documentation for managing phone numbers and making outbound calls through the KrosAI Platform.
Overview
The phone number management system allows users to:
Request phone numbers for their account
Configure phone numbers
Make outbound calls using configured phone numbers
Monitor call statistics and history
Manage phone number configurations
Authentication
All endpoints require authentication using either:
API Key:
Authorization: Bearer <your-api-key>User Token:
Authorization: Bearer <user-jwt-token>
Phone Number Request Flow
1. Request a Phone Number
Endpoint: POST /telephony/phone-number-requests
Description: Submit a request for a phone number. This request will be reviewed by administrators.
Request Body:
Response:
Status Codes:
201 Created: Request submitted successfully400 Bad Request: Invalid request data401 Unauthorized: Authentication required409 Conflict: Phone number already requested
2. Check Request Status
Endpoint: GET /telephony/phone-number-requests/{request_id}
Description: Get the current status of a phone number request.
Response:
Possible Statuses:
pending: Awaiting admin reviewapproved: Request approved, ready for assignmentrejected: Request deniedassigned: Phone number assigned to user
Phone Number Configuration
1. Configure a Phone Number
Endpoint: POST /outbound-calls/phone-numbers/{phone_number_id}/configure
Description: Configure a phone number with LiveKit SIP trunks and dispatch rules for making/receiving calls.
Request Body:
Response:
Configuration Options:
SIP Trunk Configuration
name: Human-readable name for the trunkaddress: SIP provider address (e.g.,sip.twilio.com)numbers: Array of phone numbers associated with this trunkauth_username: Authentication username (if required)auth_password: Authentication password (if required)destination_country: Two-letter country code for outbound trunks
Dispatch Rule Configuration
rule_name: Name for the dispatch ruleroom_prefix: Prefix for room names (e.g.,support-creates rooms likesupport-abc123)agent_name: Name of the agent to dispatch for calls
2. Get Phone Number Configuration
Endpoint: GET /outbound-calls/phone-numbers/{phone_number_id}/configuration
Description: Retrieve the complete configuration for a phone number.
Response:
3. Remove Phone Number Configuration
Endpoint: DELETE /outbound-calls/phone-numbers/{phone_number_id}/configuration
Description: Remove specific or all configurations from a phone number.
Query Parameters:
config_type(required): Type of configuration to removesip_trunk: Remove SIP trunk configurationdispatch_rule: Remove dispatch rule configurationall: Remove all configurations
Response:
4. List User Phone Numbers
Endpoint: GET /outbound-calls/phone-numbers
Description: Get all phone numbers assigned to the current user with their configuration status.
Response:
Outbound Calling
1. Create an Outbound Call
Endpoint: POST /outbound-calls/create
Description: Initiate an outbound call to a phone number. This creates a call record and dispatches an agent via LiveKit.
Request Body:
Response:
Call Configuration Options:
phone_number: Target phone number to call (with country code)system_prompt: Custom system prompt for the AI agentwelcome_message: Custom welcome message for the call
2. Call Management
Hang Up a Call
Endpoint: POST /outbound-calls/{call_id}/hangup
Description: End an active call by deleting the LiveKit room.
Response:
Transfer a Call
Endpoint: POST /outbound-calls/{call_id}/transfer
Description: Transfer an ongoing call to another phone number.
Request Body:
Response:
3. Call Information
Get Call Details
Endpoint: GET /outbound-calls/{call_id}/details
Description: Retrieve comprehensive call information including optional transcript and summary.
Query Parameters:
include_transcript(optional): Include full conversation transcriptinclude_summary(optional): Include AI-generated summary of the call
Response:
Get Call Statistics
Endpoint: GET /outbound-calls/stats
Description: Get aggregate statistics for the authenticated user's outbound calls.
Response:
Error Handling
Common Error Responses
400 Bad Request:
401 Unauthorized:
403 Forbidden:
404 Not Found:
500 Internal Server Error:
Rate Limits
Phone Number Requests: 5 requests per hour per user
Phone Number Configuration: 10 configurations per hour per user
Outbound Calls: 100 calls per hour per user
API Calls: 1000 requests per hour per API key
Best Practices
Phone Number Configuration
Use descriptive names for trunks and dispatch rules
Set appropriate room prefixes to organize different types of calls
Configure both inbound and outbound trunks for full functionality
Test configurations with small call volumes before production use
Outbound Calling
Provide clear system prompts for consistent agent behavior
Use appropriate voice settings for your use case
Monitor call quality and adjust settings as needed
Implement proper error handling for failed calls
Security
Keep authentication credentials secure
Use environment variables for sensitive configuration
Regularly rotate API keys
Monitor usage patterns for unusual activity
Integration Examples
Python Client Example
cURL Examples
Configure Phone Number:
Make Outbound Call:
Support
For technical support or questions about phone number management and outbound calling:
Documentation: https://docs.krosai.com
API Status: https://status.krosai.com
Support Email: support@krosai.com
Developer Community: https://community.krosai.com
Last updated