POST
/
v2
/
create-phone-call
JavaScript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
});

const phoneCallResponse = await client.call.createPhoneCall({
  from_number: '+14157774444',
  to_number: '+12137774445',
});

console.log(phoneCallResponse.agent_id);
{
  "call_type": "phone_call",
  "from_number": "+12137771234",
  "to_number": "+12137771235",
  "direction": "inbound",
  "telephony_identifier": {
    "twilio_call_sid": "CA5d0d0d8047bf685c3f0ff980fe62c123"
  },
  "call_id": "Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6",
  "agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
  "agent_version": 1,
  "call_status": "registered",
  "metadata": {},
  "retell_llm_dynamic_variables": {
    "customer_name": "John Doe"
  },
  "collected_dynamic_variables": {
    "last_node_name": "Test node"
  },
  "custom_sip_headers": {
    "X-Custom-Header": "Custom Value"
  },
  "opt_out_sensitive_data_storage": true,
  "opt_in_signed_url": true,
  "start_timestamp": 1703302407333,
  "end_timestamp": 1703302428855,
  "duration_ms": 10000,
  "transcript": "Agent: hi how are you doing?\nUser: Doing pretty well. How are you?\nAgent: That's great to hear! I'm doing well too, thanks! What's up?\nUser: I don't have anything in particular.\nAgent: Got it, just checking in!\nUser: Alright. See you.\nAgent: have a nice day",
  "transcript_object": [
    {
      "role": "agent",
      "content": "hi how are you doing?",
      "words": [
        {
          "word": "hi",
          "start": 0.7,
          "end": 1.3
        }
      ]
    }
  ],
  "transcript_with_tool_calls": [
    {
      "role": "agent",
      "content": "hi how are you doing?",
      "words": [
        {
          "word": "hi",
          "start": 0.7,
          "end": 1.3
        }
      ]
    }
  ],
  "recording_url": "https://retellai.s3.us-west-2.amazonaws.com/Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6/recording.wav",
  "public_log_url": "https://retellai.s3.us-west-2.amazonaws.com/Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6/public_log.txt",
  "knowledge_base_retrieved_contents_url": "https://retellai.s3.us-west-2.amazonaws.com/Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6/kb_retrieved_contents.txt",
  "latency": {
    "e2e": {
      "p50": 800,
      "p90": 1200,
      "p95": 1500,
      "p99": 2500,
      "max": 2700,
      "min": 500,
      "num": 10,
      "values": [
        123
      ]
    },
    "llm": {
      "p50": 800,
      "p90": 1200,
      "p95": 1500,
      "p99": 2500,
      "max": 2700,
      "min": 500,
      "num": 10,
      "values": [
        123
      ]
    },
    "llm_websocket_network_rtt": {
      "p50": 800,
      "p90": 1200,
      "p95": 1500,
      "p99": 2500,
      "max": 2700,
      "min": 500,
      "num": 10,
      "values": [
        123
      ]
    },
    "tts": {
      "p50": 800,
      "p90": 1200,
      "p95": 1500,
      "p99": 2500,
      "max": 2700,
      "min": 500,
      "num": 10,
      "values": [
        123
      ]
    },
    "knowledge_base": {
      "p50": 800,
      "p90": 1200,
      "p95": 1500,
      "p99": 2500,
      "max": 2700,
      "min": 500,
      "num": 10,
      "values": [
        123
      ]
    },
    "s2s": {
      "p50": 800,
      "p90": 1200,
      "p95": 1500,
      "p99": 2500,
      "max": 2700,
      "min": 500,
      "num": 10,
      "values": [
        123
      ]
    }
  },
  "disconnection_reason": "agent_hangup",
  "call_analysis": {
    "call_summary": "The agent called the user to ask question about his purchase inquiry. The agent asked several questions regarding his preference and asked if user would like to book an appointment. The user happily agreed and scheduled an appointment next Monday 10am.",
    "in_voicemail": false,
    "user_sentiment": "Positive",
    "call_successful": true,
    "custom_analysis_data": {}
  },
  "call_cost": {
    "product_costs": [
      {
        "product": "elevenlabs_tts",
        "unitPrice": 1,
        "cost": 60
      }
    ],
    "total_duration_seconds": 60,
    "total_duration_unit_price": 1,
    "total_one_time_price": 10,
    "combined_cost": 70
  },
  "llm_token_usage": {
    "values": [
      123
    ],
    "average": 123,
    "num_requests": 123
  }
}

Authorizations

Authorization
string
header
required

Authentication header containing API key (find it in dashboard). The format is "Bearer YOUR_API_KEY"

Body

application/json
from_number
string
required

The number you own in E.164 format. Must be a number purchased from Retell or imported to Retell.

Example:

"+14157774444"

to_number
string
required

The number you want to call, in E.164 format. If using a number purchased from Retell, only US numbers are supported as destination.

Example:

"+12137774445"

override_agent_id
string

For this particular call, override the agent used with this agent id. This does not bind the agent to this number, this is for one time override.

Example:

"oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD"

override_agent_version
integer

For this particular call, override the agent version used with this version. This does not bind the agent version to this number, this is for one time override.

Example:

1

metadata
object

An arbitrary object for storage purpose only. You can put anything here like your internal customer id associated with the call. Not used for processing. You can later get this field from the call object.

retell_llm_dynamic_variables
object

Add optional dynamic variables in key value pairs of string that injects into your Response Engine prompt and tool description. Only applicable for Response Engine.

Example:
{ "customer_name": "John Doe" }
custom_sip_headers
object

Add optional custom SIP headers to the call.

Example:
{ "X-Custom-Header": "Custom Value" }

Response

201
application/json

Successfully made an outbound call.

call_type
enum<string>
required

Type of the call. Used to distinguish between web call and phone call.

Available options:
phone_call
Example:

"phone_call"

from_number
string
required

The caller number.

Example:

"+12137771234"

to_number
string
required

The callee number.

Example:

"+12137771235"

direction
enum<string>
required

Direction of the phone call.

Available options:
inbound,
outbound
Example:

"inbound"

call_id
string
required

Unique id of the call. Used to identify in LLM websocket and used to authenticate in audio websocket.

Example:

"Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6"

agent_id
string
required

Corresponding agent id of this call.

Example:

"oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD"

agent_version
integer
required

The version of the agent.

Example:

1

call_status
enum<string>
required

Status of call.

  • registered: Call id issued, starting to make a call using this id.

  • ongoing: Call connected and ongoing.

  • ended: The underlying websocket has ended for the call. Either user or agent hanged up, or call transferred.

  • error: Call encountered error.

Available options:
registered,
not_connected,
ongoing,
ended,
error
Example:

"registered"

telephony_identifier
object

Telephony identifier of the call, populated when available. Tracking purposes only.

metadata
object

An arbitrary object for storage purpose only. You can put anything here like your internal customer id associated with the call. Not used for processing. You can later get this field from the call object.

retell_llm_dynamic_variables
object

Add optional dynamic variables in key value pairs of string that injects into your Response Engine prompt and tool description. Only applicable for Response Engine.

Example:
{ "customer_name": "John Doe" }
collected_dynamic_variables
object

Dynamic variables collected from the call. Only available after the call ends.

Example:
{ "last_node_name": "Test node" }
custom_sip_headers
object

Custom SIP headers to be added to the call.

Example:
{ "X-Custom-Header": "Custom Value" }
opt_out_sensitive_data_storage
boolean

Whether this call opts out of sensitive data storage like transcript, recording, logging.

Example:

true

opt_in_signed_url
boolean

Whether this agent opts in for signed URLs for public logs and recordings. When enabled, the generated URLs will include security signatures that restrict access and automatically expire after 24 hours.

Example:

true

start_timestamp
integer

Begin timestamp (milliseconds since epoch) of the call. Available after call starts.

Example:

1703302407333

end_timestamp
integer

End timestamp (milliseconds since epoch) of the call. Available after call ends.

Example:

1703302428855

duration_ms
integer

Duration of the call in milliseconds. Available after call ends.

Example:

10000

transcript
string

Transcription of the call. Available after call ends.

Example:

"Agent: hi how are you doing?\nUser: Doing pretty well. How are you?\nAgent: That's great to hear! I'm doing well too, thanks! What's up?\nUser: I don't have anything in particular.\nAgent: Got it, just checking in!\nUser: Alright. See you.\nAgent: have a nice day"

transcript_object
object[]

Transcript of the call in the format of a list of utterance, with timestamp. Available after call ends.

transcript_with_tool_calls
object[]

Transcript of the call weaved with tool call invocation and results. It precisely captures when (at what utterance, which word) the tool was invoked and what was the result. Available after call ends.

recording_url
string

Recording of the call. Available after call ends.

Example:

"https://retellai.s3.us-west-2.amazonaws.com/Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6/recording.wav"

public_log_url
string

Public log of the call, containing details about all the requests and responses received in LLM WebSocket, latency tracking for each turntaking, helpful for debugging and tracing. Available after call ends.

Example:

"https://retellai.s3.us-west-2.amazonaws.com/Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6/public_log.txt"

knowledge_base_retrieved_contents_url
string

URL to the knowledge base retrieved contents of the call. Available after call ends if the call utilizes knowledge base feature. It consists of the respond id and the retrieved contents related to that response. It's already rendered in call history tab of dashboard, and you can also manually download and check against the transcript to view the knowledge base retrieval results.

Example:

"https://retellai.s3.us-west-2.amazonaws.com/Jabr9TXYYJHfvl6Syypi88rdAHYHmcq6/kb_retrieved_contents.txt"

latency
object

Latency tracking of the call, available after call ends. Not all fields here will be available, as it depends on the type of call and feature used.

disconnection_reason
enum<string>

The reason for the disconnection of the call. Read details desciption about reasons listed here at Disconnection Reason Doc.

Available options:
user_hangup,
agent_hangup,
call_transfer,
voicemail_reached,
inactivity,
max_duration_reached,
concurrency_limit_reached,
no_valid_payment,
scam_detected,
dial_busy,
dial_failed,
dial_no_answer,
invalid_destination,
telephony_provider_permission_denied,
telephony_provider_unavailable,
sip_routing_error,
marked_as_spam,
user_declined,
error_llm_websocket_open,
error_llm_websocket_lost_connection,
error_llm_websocket_runtime,
error_llm_websocket_corrupt_payload,
error_no_audio_received,
error_asr,
error_retell,
error_unknown,
error_user_not_joined,
registered_call_timeout
Example:

"agent_hangup"

call_analysis
object

Post call analysis that includes information such as sentiment, status, summary, and custom defined data to extract. Available after call ends. Subscribe to call_analyzed webhook event type to receive it once ready.

call_cost
object

Cost of the call, including all the products and their costs and discount.

llm_token_usage
object

LLM token usage of the call, available after call ends. Not populated if using custom LLM, realtime API, or no LLM call is made.