curl --request POST \
--url https://rest.newlead.ai/v1/calls \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"voice_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": "+34600111222"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({voice_agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', to: '+34600111222'})
};
fetch('https://rest.newlead.ai/v1/calls', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://rest.newlead.ai/v1/calls"
payload = {
"voice_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": "+34600111222"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "call",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"voice_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lead_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"direction": "inbound",
"from": "<string>",
"to": "<string>",
"status": "in_progress",
"end_reason": "<string>",
"outcome": "<string>",
"summary": "<string>",
"variables": {},
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"duration_sec": 123,
"recording_url": "<string>",
"transcript_ready": true,
"transcript": [
{
"role": "lead",
"text": "<string>",
"start_ms": 123,
"end_ms": 123
}
]
}{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "phone must match pattern \"^\\+[1-9]\\d{6,14}$\".",
"param": "phone",
"request_id": "req_m3k2a9_4f1c2b7e",
"doc_url": "https://docs.newlead.ai/errors#parameter_invalid"
}
}{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "phone must match pattern \"^\\+[1-9]\\d{6,14}$\".",
"param": "phone",
"request_id": "req_m3k2a9_4f1c2b7e",
"doc_url": "https://docs.newlead.ai/errors#parameter_invalid"
}
}{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "phone must match pattern \"^\\+[1-9]\\d{6,14}$\".",
"param": "phone",
"request_id": "req_m3k2a9_4f1c2b7e",
"doc_url": "https://docs.newlead.ai/errors#parameter_invalid"
}
}Create a call
The voice agent calls to from its outbound number. Finds the agent’s lead with that phone number, or creates it, and returns 201 with the ongoing call and its lead_id. With lead, its name and variables are written to the lead before dialing, and the agent uses them during the call; if the call then fails or is refused for lack of balance, the lead keeps them. If the call cannot be placed, it says so before dialing: 409 agent_not_ready (the voice agent or its text agent is switched off), voice_number_missing (no outbound number), outside_initiation_hours, lead_ai_paused or lead_do_not_contact; 402 with no balance, and 403 feature_disabled if your plan does not include calls. At most 5 calls per minute per key. If you send an Idempotency-Key and it cannot be checked, the call is not placed and the response is 502 provider_unavailable: retry with the same key.
curl --request POST \
--url https://rest.newlead.ai/v1/calls \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"voice_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": "+34600111222"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({voice_agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', to: '+34600111222'})
};
fetch('https://rest.newlead.ai/v1/calls', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://rest.newlead.ai/v1/calls"
payload = {
"voice_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": "+34600111222"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "call",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"voice_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lead_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"direction": "inbound",
"from": "<string>",
"to": "<string>",
"status": "in_progress",
"end_reason": "<string>",
"outcome": "<string>",
"summary": "<string>",
"variables": {},
"started_at": "2023-11-07T05:31:56Z",
"ended_at": "2023-11-07T05:31:56Z",
"duration_sec": 123,
"recording_url": "<string>",
"transcript_ready": true,
"transcript": [
{
"role": "lead",
"text": "<string>",
"start_ms": 123,
"end_ms": 123
}
]
}{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "phone must match pattern \"^\\+[1-9]\\d{6,14}$\".",
"param": "phone",
"request_id": "req_m3k2a9_4f1c2b7e",
"doc_url": "https://docs.newlead.ai/errors#parameter_invalid"
}
}{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "phone must match pattern \"^\\+[1-9]\\d{6,14}$\".",
"param": "phone",
"request_id": "req_m3k2a9_4f1c2b7e",
"doc_url": "https://docs.newlead.ai/errors#parameter_invalid"
}
}{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "phone must match pattern \"^\\+[1-9]\\d{6,14}$\".",
"param": "phone",
"request_id": "req_m3k2a9_4f1c2b7e",
"doc_url": "https://docs.newlead.ai/errors#parameter_invalid"
}
}Authorizations
Headers
Up to 255 characters. Repeat the key with the same body within 24 hours and you get the same response plus an Idempotent-Replayed header set to true. 402, 409, 429 and 5xx responses (except send_outcome_unknown) are not stored: fix the cause and retry with the same key.
1 - 255Body
Response
The ongoing call.
in_progress: ongoing. completed: finished. failed: failed while dialing, opening the room or during the call. dropped: cut off without the agent ending it. no_answer: nobody picked up. rejected: never handled (no balance, plan without calls, unknown number); end_reason says why.
in_progress, completed, failed, dropped, no_answer, rejected