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 successfully

  • 400 Bad Request: Invalid request data

  • 401 Unauthorized: Authentication required

  • 409 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 review

  • approved: Request approved, ready for assignment

  • rejected: Request denied

  • assigned: 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 trunk

  • address: SIP provider address (e.g., sip.twilio.com)

  • numbers: Array of phone numbers associated with this trunk

  • auth_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 rule

  • room_prefix: Prefix for room names (e.g., support- creates rooms like support-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 remove

    • sip_trunk: Remove SIP trunk configuration

    • dispatch_rule: Remove dispatch rule configuration

    • all: 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 agent

  • welcome_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 transcript

  • include_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

  1. Use descriptive names for trunks and dispatch rules

  2. Set appropriate room prefixes to organize different types of calls

  3. Configure both inbound and outbound trunks for full functionality

  4. Test configurations with small call volumes before production use

Outbound Calling

  1. Provide clear system prompts for consistent agent behavior

  2. Use appropriate voice settings for your use case

  3. Monitor call quality and adjust settings as needed

  4. Implement proper error handling for failed calls

Security

  1. Keep authentication credentials secure

  2. Use environment variables for sensitive configuration

  3. Regularly rotate API keys

  4. 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:

Last updated