curl --request POST \
--url https://rest.newlead.ai/v1/webhook_endpoints \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://n8n.example.com/webhook/newlead",
"events": []
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://n8n.example.com/webhook/newlead', events: []})
};
fetch('https://rest.newlead.ai/v1/webhook_endpoints', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://rest.newlead.ai/v1/webhook_endpoints"
payload = {
"url": "https://n8n.example.com/webhook/newlead",
"events": []
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "webhook_endpoint",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"url": "<string>",
"events": [
"call.started"
],
"text_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"voice_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"active": true,
"last_success_at": "2023-11-07T05:31:56Z",
"last_failure_at": "2023-11-07T05:31:56Z",
"consecutive_failures": 1,
"created_at": "2023-11-07T05:31:56Z",
"secret": "<string>"
}{
"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 webhook endpoint
Registers your URL to receive an agent’s events, signed with a secret you see only in this response. If the agent already has 3 active endpoints, returns 409 webhook_endpoint_limit_reached: pause or delete one first.
curl --request POST \
--url https://rest.newlead.ai/v1/webhook_endpoints \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://n8n.example.com/webhook/newlead",
"events": []
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: 'https://n8n.example.com/webhook/newlead', events: []})
};
fetch('https://rest.newlead.ai/v1/webhook_endpoints', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://rest.newlead.ai/v1/webhook_endpoints"
payload = {
"url": "https://n8n.example.com/webhook/newlead",
"events": []
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "webhook_endpoint",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"url": "<string>",
"events": [
"call.started"
],
"text_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"voice_agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"active": true,
"last_success_at": "2023-11-07T05:31:56Z",
"last_failure_at": "2023-11-07T05:31:56Z",
"consecutive_failures": 1,
"created_at": "2023-11-07T05:31:56Z",
"secret": "<string>"
}{
"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
An endpoint belongs to one agent: send text_agent_id or voice_agent_id, exactly one. A text agent listens for lead and message events and a voice agent for call events. Each agent has at most 3 active endpoints.
1call.* events belong to voice agents; the others belong to text agents. What each event carries and how to verify the signature are at https://docs.newlead.ai/webhook-events.
call.started, call.rejected, call.ended, call.analyzed, lead.created, lead.qualified, lead.appointment_booked, lead.handoff, follow_up.sent, message.received, message.failed Response
The endpoint, with its secret. This is the only time you see it.
The newly created endpoint, with its secret. This is the only time you see it.
call.* events belong to voice agents; the others belong to text agents. What each event carries and how to verify the signature are at https://docs.newlead.ai/webhook-events.
call.started, call.rejected, call.ended, call.analyzed, lead.created, lead.qualified, lead.appointment_booked, lead.handoff, follow_up.sent, message.received, message.failed