For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
AcademyContact SalesHelp CenterDashboard
DocumentationAPI ReferenceIntegrationsAdministrationChangelog
DocumentationAPI ReferenceIntegrationsAdministrationChangelog
  • Get Started
    • Introduction
    • Aurora
  • Build
    • Create an Agent
    • The Agent Editor
    • Single-Prompt Agents
    • Memory
    • Knowledge Base
    • Variables
    • Version Control
  • Evaluate
    • Manual Testing
    • Custom Evaluations
    • Simulations
  • Launch
    • Deployment Options
      • Overview
      • Connect your Phone System
      • SIP Trunking Network ACL
      • Egress IP Addresses
      • Performance Metrics
      • Concurrency
      • Telephony Errors
      • Forward Calls to Synthflow
      • Call Transfer to SIP
        • How to Direct SIP Dialing
        • Viewing the SIP call ladder
        • Use Action Variables in Inbound SIP Calls
        • Forward Calls to the SIP Trunk
        • Forward Calls Using SIP Diversion Headers
        • Use the X-EI SIP Header
        • Use SIP X-Headers in Prompts, Actions & Transfers
      • Deploy in LATAM Regions
    • WhatsApp
    • Website and Apps
    • Launching a Chat Agent
    • Workflows
  • Learn
    • Analytics Dashboard
    • Logs
    • Export Call Data
  • Legal
    • Subscriber Terms
    • GTC - Direct Use (DACH)
    • GTC - Direct Use (US)
    • GTC - Distribution (DACH)
    • GTC - Distribution (US)
    • Business Associate Agreement
    • Privacy Policy
    • Imprint
    • AI Transparency Statement
    • Trust Vault
LogoLogo
AcademyContact SalesHelp CenterDashboard
On this page
  • Final Step: Initializing the call
  • Creating the call
  • Forward call to SIP Trunk
LaunchTelephonyDial to the SIP Endpoint

Forward calls to the SIP trunk

||View as Markdown|
Was this page helpful?
Previous

Forward calls using SIP diversion headers

Next
Built with

This guide walks you through the process of initializing the call via the SIP trunk. The setup consists of three primary steps:

  1. Create the call
  2. Forward call to SIP Trunk

Final Step: Initializing the call

Creating the call

Endpoint:
POST /v2/prepare_inbound

Headers:

JSON
{
"Content-Type": "application/json",
"Authorization": "Bearer {TOKEN}"
}

Request Body

JSON
{
"from_number": "",
"to_number": "",
"model_id": "",
"workspace_id": "",
"custom_variables": {
"name": "value"
},
}

Response Format

JSON
{
"call_status": "registered",
"synthflow_call_id": "a29407fb-1bf2-4be6-9d1d-f501c3dd9a2b",
"direction": "inbound",
"model_id": "1744274157255x646200691892837600",
"workspace_id": null,
"custom_variables": {
"name": "erfan",
"job": "backend"
},
"duration": null,
"end_call_reason": null,
"judge_results": null,
"is_voicemail": null,
"lead_phone_number": "+15075785607",
"voicemail_not_detected_during_call_but_detected_in_post_call": null,
"voicemail_during_call_but_not_voicemail_in_post_call": null,
"timeline": [
],
"twilio_call_sid": null,
"egress_recording_url": null,
"agents_used": [
],
"original_payload": null,
"executed_actions": [
],
"prompt_variables": {
},
"voicemail_message_left": null,
"recording_sid": null,
"secondary_call_id": null,
"recording_url": null,
"payload_received": null,
"language": null,
"type_of_call": null,
"recording_duration": null,
"transcript": null,
"error_message_payload_validation": null,
"error_message": null,
"node_and_stage_time_track": {
},
"start_time": 1744309477691,
"campaign_name": null,
"lead_name": null,
"labels": [
],
"agent_phone_number": "",
"deployment_type": null,
"timezone": null
}

synthflow_call_id This is the call ID that should be sent to the SIP trunk via the X-EI header.

call_status Indicates the status of the call. A value of registered means that SynthFlow is operational, while failed indicates a service outage.

Forward call to SIP Trunk

After the call is created on SynthFlow, redirect Twilio calls to it using TwiML commands. Make sure to include the received synthflow_call_id in the SIP headers using the X-EI key, formatted as follows:

X-EI=S.synthflow_call_id;

Regex pattern: (S|E)\.([^\;]+);

Here’s a code snippet for redirecting a call:

1const express = require('express');
2const VoiceResponse = require('twilio').twiml.VoiceResponse;
3
4const app = express();
5const PORT = process.env.PORT || 3000;
6const TERMINATION = "sip.synthflow.ai:32681";
7
8app.get('/redirect_call', (req, res) => {
9 const phone_number = "" // Custom phone number
10 const call_id = "" // synthflow_call_id
11
12 const voice = new VoiceResponse();
13 voice.dial().sip(`sip:${phone_number}@${TERMINATION}?X-EI=S.${call_id};`);
14
15 res.type('text/xml');
16 res.send(voice.toString());
17});
18
19app.listen(PORT, () => {
20 console.log(`Server running on port ${PORT}`);
21});
python
from fastapi import FastAPI, Response, Request
app = FastAPI()
TERMINATION = "sip.synthflow.ai:32681"
@app.get("/redirect_call")
async def redirect_call(CallSid: str, From: str):
phone_number = "" # Custom Phone number
call_id = await create_call() # Creating call and returning synthflow_call_id
voice = VoiceResponse()
voice.dial().sip(f"sip:{phone_number}@{TERMINATION}?X-EI=S.{call_id};")
return Response(str(voice), media_type="text/xml", status_code=200)

Note: The transfer call will work the same as before.