Create Webhook

Create a new webhook for an agent. Each agent can have at most one webhook of each type (pre_call and post_call).

HTTP Request

$POST https://app.resemble.ai/api/v2/agents/{agent_uuid}/webhooks

URL Parameters

ParameterTypeDescription
agent_uuidstringThe agent’s UUID

Request Body

AttributeTypeRequiredDescription
webhook_typestringYesWebhook type: “pre_call” or “post_call”
webhook_configobjectYesWebhook configuration (see below)

Pre-Call Webhook Example

$curl --request POST "https://app.resemble.ai/api/v2/agents/550e8400-e29b-41d4-a716-446655440000/webhooks" \
> -H "Authorization: Bearer YOUR_API_TOKEN" \
> -H "Content-Type: application/json" \
> --data '{
> "webhook_type": "pre_call",
> "webhook_config": {
> "api_schema": {
> "url": "https://api.example.com/pre-call",
> "method": "POST",
> "request_headers": {
> "Authorization": "Bearer secret123",
> "Content-Type": "application/json"
> },
> "request_body": {
> "agent_uuid": "{{agent_uuid}}",
> "caller_phone": "{{caller_phone}}"
> }
> },
> "assignments": [
> {
> "source": "response",
> "attribute_name": "customer_name",
> "dynamic_variable": "customer_name"
> },
> {
> "source": "response",
> "attribute_name": "account_balance",
> "dynamic_variable": "balance"
> }
> ],
> "response_timeout_secs": 10
> }
> }'

Post-Call Webhook Example

$curl --request POST "https://app.resemble.ai/api/v2/agents/550e8400-e29b-41d4-a716-446655440000/webhooks" \
> -H "Authorization: Bearer YOUR_API_TOKEN" \
> -H "Content-Type: application/json" \
> --data '{
> "webhook_type": "post_call",
> "webhook_config": {
> "api_schema": {
> "url": "https://api.example.com/post-call",
> "method": "POST",
> "request_headers": {
> "Authorization": "Bearer secret123"
> },
> "request_body": {
> "conversation_uuid": "{{conversation_uuid}}",
> "duration_seconds": "{{call_duration}}",
> "summary": "{{call_summary}}"
> }
> },
> "response_timeout_secs": 5
> }
> }'

Pre-Call Webhook Configuration

AttributeTypeRequiredDescription
api_schemaobjectYesAPI endpoint configuration
assignmentsarrayYesVariable assignments from webhook response
response_timeout_secsintegerNoTimeout in seconds

API Schema

AttributeTypeRequiredDescription
urlstringYesHTTP/HTTPS URL
methodstringYesHTTP method (typically POST)
request_headersobjectNoHTTP headers
request_bodyobjectNoRequest body

Assignments

AttributeTypeRequiredDescription
sourcestringYesMust be “response” for pre-call webhooks
attribute_namestringYesField name in webhook response
dynamic_variablestringYesTarget dynamic variable (must exist in agent)

Post-Call Webhook Configuration

AttributeTypeRequiredDescription
api_schemaobjectYesAPI endpoint configuration
response_timeout_secsintegerNoTimeout in seconds

Note: Post-call webhooks do not support assignments (no variables are updated after call ends).

Response (Success)

1{
2 "success": true,
3 "item": {
4 "id": 1,
5 "webhook_type": "pre_call",
6 "webhook_config": {
7 "api_schema": {
8 "url": "https://api.example.com/pre-call",
9 "method": "POST",
10 "request_headers": {
11 "Authorization": "Bearer secret123",
12 "Content-Type": "application/json"
13 },
14 "request_body": {
15 "agent_uuid": "{{agent_uuid}}",
16 "caller_phone": "{{caller_phone}}"
17 }
18 },
19 "assignments": [
20 {
21 "source": "response",
22 "attribute_name": "customer_name",
23 "dynamic_variable": "customer_name"
24 }
25 ],
26 "response_timeout_secs": 10
27 },
28 "created_at": "2025-01-27T10:00:00Z",
29 "updated_at": "2025-01-27T10:00:00Z"
30 },
31 "message": "Webhook created successfully"
32}

Response (Error)

1{
2 "success": false,
3 "errors": {
4 "webhook_type": ["must be one of: pre_call, post_call"],
5 "webhook_config": [
6 "missing required fields: api_schema",
7 "assignments[0].source must be 'response' for pre_call webhooks",
8 "assignments[0].dynamic_variable 'customer_name' does not exist in agent's dynamic_variables"
9 ]
10 },
11 "message": "Failed to create webhook"
12}

Validation Rules

  • webhook_type: Required, must be “pre_call” or “post_call”
  • webhook_config: Required
  • Uniqueness: Only one webhook of each type per agent
  • Pre-call assignments[].source: Must be “response”
  • Pre-call assignments[].dynamic_variable: Must exist in agent’s dynamic_variables
  • Post-call: No assignments field

See Also