https://retellai.com/?utm_source=discord&utm_medium=seo logo
p
@AI Evy can. you give me an example of sending metadata through the call?
a
Thanks for tagging me @PixelDrift42. I'll look through relevant sources and get back to you shortly.
### Answer You can send metadata through calls using the
metadata
parameter [(1) ]() [(2) ]() [(3) ]() . Here are examples from the Retell AI JavaScript SDK: For updating an existing call:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const callResponse = await client.call.update('call_a4441234567890777c4a4a123e6', {
 data_storage_setting: 'everything_except_pii',
 metadata: { customer_id: 'cust_123', notes: 'Follow-up required' },
}) ;
console.log(callResponse) ;
[(1) ]() For registering a phone call:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
[(2) ]() For creating a web call:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const webCallResponse = await client.call.createWebCall({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(webCallResponse.agent_id) ;
[(3) ]() The metadata is described as "an arbitrary object for storage purpose only" that you can use to store information like internal customer IDs associated with the call [(1) ]() [(2) ]() [(3) ]() . It's not used for processing but can be retrieved later from the call object .
​ To learn more, see the sources I considered: [[1] Update Call](https://docs.retellai.com/api-references/update-call) [[2] Register Phone Call](https://docs.retellai.com/api-references/register-phone-call) [[3] Create Web Call](https://docs.retellai.com/api-references/create-web-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
Thanks for the feedback, glad I was helpful.
p
@AI Evy can you use python sdk as an exame?
a
Thanks for the follow-up, @PixelDrift42. I'll get back to you soon.
​ To learn more, see the sources I considered: [[1] Retell Python API library](https://github.com/RetellAI/retell-python-sdk/blob/main/README.md) [[2] RetellAI/retell-python-sdk/api.md](https://github.com/RetellAI/retell-python-sdk/blob/main/api.md) ​
### Answer Here's how to send metadata using the Retell Python SDK: For creating a phone call:
Copy code
python
from retell import Retell

client = Retell()

agent_response = client.agent.create(
    response_engine={
        "llm_id": "llm_234sdertfsdsfsdf",
        "type": "retell-llm",
    },
    voice_id="11labs-Adrian",
    user_dtmf_options={},
)
print(agent_response.user_dtmf_options)
[(1) ]() For updating a call:
Copy code
python
from retell.types import CallResponse, PhoneCallResponse, WebCallResponse, CallListResponse
[(2) ]() The Python SDK provides methods like
client.call.create_phone_call()
,
client.call.create_web_call()
, and
client.call.update()
that accept metadata parameters . You can pass metadata as a dictionary containing arbitrary key-value pairs for storage purposes . Error handling example:
Copy code
python
import retell
from retell import Retell

client = Retell()

try:
    client.agent.create(
        response_engine={
            "llm_id": "llm_234sdertfsdsfsdf",
            "type": "retell-llm",
        },
        voice_id="11labs-Adrian",
    )
except retell.APIConnectionError as e:
    print("The server could not be reached")
    print(e.__cause__)  # an underlying Exception, likely raised within httpx.
except retell.RateLimitError as e:
    print("A 429 status code was received; we should back off a bit.")
except retell.APIStatusError as e:
    print("Another non-200-range status code was received")
    print(e.status_code)
    print(e.response)
[(1) ]() The metadata parameter allows you to store information like customer IDs or notes that can be retrieved later from the call object [(2) ]() .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
p
@AI Evy there should be a metadata argument right?
a
Thanks for the follow-up, @PixelDrift42. I'll get back to you soon.
### Answer Yes, you're absolutely correct! The
metadata
parameter is available in the Retell AI API calls [(1) ]() [(2) ]() [(3) ]() [(4) ]() [(5) ]() . Here's the JavaScript SDK example showing the metadata argument:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const callResponse = await client.call.update('call_a4441234567890777c4a4a123e6', {
 data_storage_setting: 'everything_except_pii',
 metadata: { customer_id: 'cust_123', notes: 'Follow-up required' },
}) ;
console.log(callResponse) ;
[(1) ]() For phone calls, you can also include metadata when creating the call:
Copy code
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) ;
[(4) ]() The metadata is described as "an arbitrary object for storage purpose only" that you can use to store information like your internal customer ID associated with the call [(1) ]() [(2) ]() [(3) ]() [(4) ]() [(5) ]() . It's not used for processing but can be retrieved later from the call object .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.