Skip to main content

Webhooks API

Manage webhook subscriptions to receive real-time event notifications. Leezy uses the RestHooks pattern for webhook management.

Subscribe to Webhooks

POST /api/v1/webhooks/subscribe

Required Scope: webhooks:manage

Request Body

{
"target_url": "https://yourapp.com/webhooks/leezy",
"event_types": ["lead.created", "lead.qualified"],
"filters": {
"chatbot_id": "chatbot_abc123"
}
}
FieldTypeRequiredDescription
target_urlstringYesHTTPS URL to receive webhooks
event_typesarrayYesEvent types to subscribe to
filtersobjectNoOptional filters (e.g., chatbot_id)

Example Request

curl -X POST "https://app.leezy.ai/api/v1/webhooks/subscribe" \
-H "Authorization: Bearer lzy_at_your_token" \
-H "Content-Type: application/json" \
-d '{
"target_url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
"event_types": ["lead.created"]
}'

Response

{
"data": {
"id": "webhook_abc123",
"target_url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
"event_types": ["lead.created"],
"filters": {},
"status": "active",
"secret": "lzy_ws_abc123xyz789...",
"created_at": "2024-01-15T10:00:00Z"
},
"meta": {
"api_version": "2024-01-01"
}
}
Secret Shown Once

The secret is only returned when creating the subscription. Store it securely for webhook verification.

List Subscriptions

GET /api/v1/webhooks

Required Scope: webhooks:manage

Example Request

curl -X GET "https://app.leezy.ai/api/v1/webhooks" \
-H "Authorization: Bearer lzy_at_your_token"

Response

{
"data": [
{
"id": "webhook_abc123",
"target_url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
"event_types": ["lead.created"],
"filters": {},
"status": "active",
"failure_count": 0,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
}
],
"meta": {
"api_version": "2024-01-01",
"total": 1,
"count": 1
}
}

Delete Subscription

DELETE /api/v1/webhooks/:id

Required Scope: webhooks:manage

Example Request

curl -X DELETE "https://app.leezy.ai/api/v1/webhooks/webhook_abc123" \
-H "Authorization: Bearer lzy_at_your_token"

Response

{
"data": {
"id": "webhook_abc123",
"deleted": true
},
"meta": {
"api_version": "2024-01-01"
}
}

Available Event Types

Lead Events

EventDescription
lead.createdNew lead captured
lead.updatedLead information updated
lead.qualifiedLead marked as qualified
lead.convertedLead converted to customer
lead.score_changedLead score changed

Conversation Events

EventDescription
conversation.startedNew conversation started
conversation.endedConversation ended
conversation.message_receivedNew message received
conversation.sentiment_negativeNegative sentiment detected
conversation.sentiment_positivePositive sentiment detected

Ticket Events

EventDescription
ticket.createdNew support ticket created
ticket.updatedTicket updated
ticket.resolvedTicket resolved

Meeting Events

EventDescription
meeting.scheduledMeeting scheduled
meeting.cancelledMeeting cancelled
meeting.completedMeeting completed
meeting.reminderMeeting reminder sent

Other Events

EventDescription
message.feedback_negativeNegative feedback on message
message.feedback_positivePositive feedback on message
agent.tool_failedAI action failed
agent.tool_executedAI action executed
usage.threshold_reachedUsage threshold reached

Subscription Status

StatusDescription
activeReceiving webhooks normally
failedPaused due to consecutive failures

Subscriptions are automatically paused after 5 consecutive delivery failures.

Error Responses

StatusErrorDescription
400invalid_requestInvalid URL or event types
401unauthorizedMissing or invalid token
403insufficient_scopeToken lacks webhooks:manage scope
404not_foundSubscription not found

Next Steps