API Documentation
Complete API documentation for AI Calling System
API Overview
This AI Calling System provides comprehensive APIs for managing outbound calls, handling inbound calls, and managing AI assistants. The system integrates with VAPI.ai for AI-powered conversations and Twilio for telephony services.
Outbound Calls
Initiate AI-powered callsAI Assistants
Manage conversation agentsWebhooks
Real-time call eventsLocal API Endpoints
Endpoints provided by this applicationPOST Outbound Call API
/api/calls/outbound
Initiate an outbound call using VAPI
Parameters:
to_number- Phone number to call (required)assistant_id- VAPI Assistant ID (optional, uses default if not provided)customer_name- Customer name (optional)
Example Request:
{
"url": "https:\/\/aicalling.tranquilcrm.in\/api\/calls\/outbound",
"method": "POST",
"headers": [
"Content-Type: application\/json",
"Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837"
],
"body": {
"to_number": "+1234567890",
"assistant_id": "b886f9cd-f109-4459-8795-aaf060ed6517",
"customer_name": "John Doe"
}
}
POST Inbound Call Webhook
/api/calls/inbound
Handle incoming calls from Twilio
Parameters:
CallSid- Twilio Call SIDFrom- Caller phone numberTo- Called phone number
Example Request:
{
"url": "https:\/\/aicalling.tranquilcrm.in\/api\/calls\/inbound",
"method": "POST",
"headers": [
"Content-Type: application\/x-www-form-urlencoded"
],
"body": {
"CallSid": "CA1234567890abcdef",
"From": "+1234567890",
"To": "+0987654321"
}
}
POST Call Status Webhook
/api/calls/status
Receive call status updates from Twilio
Parameters:
CallSid- Twilio Call SIDCallStatus- Call status (ringing, in-progress, completed, etc.)CallDuration- Call duration in seconds
Example Request:
{
"url": "https:\/\/aicalling.tranquilcrm.in\/api\/calls\/status",
"method": "POST",
"headers": [
"Content-Type: application\/x-www-form-urlencoded"
],
"body": {
"CallSid": "CA1234567890abcdef",
"CallStatus": "completed",
"CallDuration": "120"
}
}
GET VAPI Assistant Management
/assistant
List all VAPI assistants
Example Request:
{
"url": "https:\/\/aicalling.tranquilcrm.in\/assistant",
"method": "GET",
"headers": [
"Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837"
]
}
POST Create VAPI Assistant
/assistant/store
Create a new VAPI assistant
Parameters:
name- Assistant name (required)system_prompt- System prompt for the assistant (required)first_message- First message to say (required)voice_provider- Voice provider (openai, elevenlabs)voice_id- Voice IDmodel_provider- Model provider (openai)model_name- Model name (gpt-4, gpt-3.5-turbo)
Example Request:
{
"url": "https:\/\/aicalling.tranquilcrm.in\/assistant\/store",
"method": "POST",
"headers": [
"Content-Type: application\/json",
"Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837"
],
"body": {
"name": "Customer Service Agent",
"system_prompt": "You are a helpful customer service agent...",
"first_message": "Hello! How can I help you today?",
"voice_provider": "openai",
"voice_id": "alloy",
"model_provider": "openai",
"model_name": "gpt-4"
}
}
VAPI Direct API Endpoints
Direct integration with VAPI.ai servicesPOST Make Call (VAPI Direct)
https://api.vapi.ai/call/phone
Direct VAPI call initiation
Parameters:
assistantId- VAPI Assistant IDcustomer.number- Customer phone numberphoneNumberId- VAPI Phone Number ID
Example Request:
{
"url": "https:\/\/api.vapi.ai\/call\/phone",
"method": "POST",
"headers": [
"Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837",
"Content-Type: application\/json"
],
"body": {
"assistantId": "b886f9cd-f109-4459-8795-aaf060ed6517",
"customer": {
"number": "+1234567890",
"name": "John Doe"
},
"phoneNumberId": "8be4028b-6b36-4e2d-87a9-b3339aff9346"
}
}
GET Get Call Details
https://api.vapi.ai/call/{call_id}
Get details of a specific call
Parameters:
call_id- VAPI Call ID
Example Request:
{
"url": "https:\/\/api.vapi.ai\/call\/12345",
"method": "GET",
"headers": [
"Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837"
]
}
POST End Call
https://api.vapi.ai/call/{call_id}/end
End an active call
Parameters:
call_id- VAPI Call ID
Example Request:
{
"url": "https:\/\/api.vapi.ai\/call\/12345\/end",
"method": "POST",
"headers": [
"Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837"
]
}
GET List Assistants
https://api.vapi.ai/assistant
List all VAPI assistants
Example Request:
{
"url": "https:\/\/api.vapi.ai\/assistant",
"method": "GET",
"headers": [
"Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837"
]
}
POST Create Assistant
https://api.vapi.ai/assistant
Create a new VAPI assistant
Parameters:
name- Assistant namemodel- Model configurationvoice- Voice configurationfirstMessage- First message
Example Request:
{
"url": "https:\/\/api.vapi.ai\/assistant",
"method": "POST",
"headers": [
"Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837",
"Content-Type: application\/json"
],
"body": {
"name": "Customer Service Agent",
"model": {
"provider": "openai",
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful customer service agent."
}
]
},
"voice": {
"provider": "openai",
"voiceId": "alloy"
},
"firstMessage": "Hello! How can I help you today?"
}
}
Configuration
Required configuration for API usageEnvironment Variables
VAPI_API_KEY=6f79b097-c301-4f38-b4f1-4431657ed837ASSISTANT_ID=b886f9cd-f109-4459-8795-aaf060ed6517PHONE_NUMBER_ID=8be4028b-6b36-4e2d-87a9-b3339aff9346API_BASE_URL=https://aicalling.tranquilcrm.in/
Required Headers
Authorization: Bearer 6f79b097-c301-4f38-b4f1-4431657ed837Content-Type: application/json
Quick Start Guide
Get started with the API in 3 stepsConfigure
Set up your VAPI API key and assistant ID in the configuration
Create Assistant
Create an AI assistant using the assistant management API
Make Calls
Initiate outbound calls using the call API endpoints