dj.ufk
11/03/2025, 9:44 AMAI Evy
11/03/2025, 9:44 AMAI Evy
11/03/2025, 9:44 AMmetadata field [(1) ]() .
When registering a phone call via the Register Phone Call API, you can include an arbitrary object in the metadata parameter . This field is for storage purposes only and is not used for processing, but you can retrieve it later from the call object .
Here's how you would structure it:
json
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"from_number": "+12137771234",
"to_number": "+12137771235",
"direction": "inbound",
"metadata": {
"your_unique_identifier": "your_value_here"
}
}
The metadata object allows you to put anything you need, like your internal customer ID associated with the call . You can later retrieve this field from the call object to recognize and track your calls .
Additionally, you can add custom SIP headers using the custom_sip_headers field, which are forwarded to your SIP provider on the SIP INVITE and can be used for custom routing, tagging, or metadata [(2) ]() . All header names must start with X- .AI Evy
11/03/2025, 9:44 AMAI Evy
11/03/2025, 9:44 AMdj.ufk
11/03/2025, 9:45 AMAI Evy
11/03/2025, 9:45 AMAI Evy
11/03/2025, 9:46 AMmetadata and other required parameters [(2) ]()
2. Get the call_id - The API returns a call_id in the response
3. Forward the SIP call - Use that call_id to construct the SIP URI and forward your call to Retell [(1) ]()
The SIP URI format is: sip:{call_id}@sip.retellai.com
Here's an example of registering the call:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const phoneCallResponse = await client.call.registerPhoneCall({
agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
}) ;
console.log(phoneCallResponse.agent_id) ;
[(2) ]()
You can include your unique identifier in the metadata field:
json
{
"agent_id": "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
"from_number": "+12137771234",
"to_number": "+12137771235",
"direction": "inbound",
"metadata": {
"your_unique_identifier": "your_value_here"
}
}
The metadata object is for storage purposes only and can be retrieved later from the call object .
**Note**: If you're using Elastic SIP Trunking instead (the recommended method) , you don't need to register calls manually - the SIP trunk connection handles this automatically [(1) ]() .AI Evy
11/03/2025, 9:46 AMAI Evy
11/03/2025, 9:46 AM