API Reference: Webhooks

Complete reference for the Webhooks API including endpoints, event types, payload schemas, and examples.

Authentication

All webhook endpoints require a valid API key passed in the Authorization header as Bearer <token>.

Webhook Delivery

Webhooks are delivered with at-least-once semantics. Your endpoint must be idempotent and respond with a 2xx status code.
POST/api/v1/webhooks/endpoints

Register a new webhook endpoint to receive event notifications.

Request Body

NameTypeRequiredDescription
urlstringRequiredThe HTTPS URL to deliver webhook events to.
eventsstring[]RequiredList of events to subscribe to. See Event Types below.
secretstringOptionalOptional secret for HMAC-SHA256 signature verification.
bash
curl -X POST https://agentinbox.in/api/v1/webhooks/endpoints \
-H "Authorization: Bearer $AgentInbox_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.com/webhooks/AgentInbox",
"events": ["email.received", "otp.extracted"],
"secret": "whsec_..."
}'

Responses

HTTP 201
{
"id": "whp_123",
"url": "https://your-app.com/webhooks/AgentInbox",
"events": ["email.received", "otp.extracted"],
"status": "active",
"createdAt": "2024-06-12T10:00:00Z"
}
GET/api/v1/webhooks/endpoints

List all registered webhook endpoints.

bash
curl -s https://agentinbox.in/api/v1/webhooks/endpoints \
-H "Authorization: Bearer $AgentInbox_API_KEY"

Responses

HTTP 200
{
"data": [
{
"id": "whp_123",
"url": "https://your-app.com/webhooks/AgentInbox",
"events": ["email.received", "otp.extracted"],
"status": "active",
"createdAt": "2024-06-12T10:00:00Z"
}
]
}
DELETE/api/v1/webhooks/endpoints/{id}

Delete a webhook endpoint. No further events will be delivered to this URL.

Path Parameters

NameTypeRequiredDescription
idstringRequiredThe unique webhook endpoint ID.
bash
curl -X DELETE https://agentinbox.in/api/v1/webhooks/endpoints/whp_123 \
-H "Authorization: Bearer $AgentInbox_API_KEY"

Responses

HTTP 204
// No body
POST/api/v1/webhooks/events

Test a webhook by sending a test event to your endpoint. Useful for verifying your integration.

Request Body

NameTypeRequiredDescription
endpointIdstringRequiredThe webhook endpoint ID to send the test event to.
eventstringRequiredThe event type to simulate.
bash
curl -X POST https://agentinbox.in/api/v1/webhooks/events \
-H "Authorization: Bearer $AgentInbox_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"endpointId": "whp_123",
"event": "email.received"
}'

Responses

HTTP 200
{
"success": true,
"delivered": true,
"responseStatus": 200
}
POST/api/v1/webhooks/endpoints/{id}/rotate-secret

Rotate the webhook signing secret. The old secret is invalidated immediately.

Path Parameters

NameTypeRequiredDescription
idstringRequiredThe webhook endpoint ID to rotate the secret for.
bash
curl -X POST https://agentinbox.in/api/v1/webhooks/endpoints/whp_123/rotate-secret \
-H "Authorization: Bearer $AgentInbox_API_KEY"

Responses

HTTP 200
{
"secret": "whsec_new_...",
"updatedAt": "2024-06-12T10:00:00Z"
}

Event Types

All webhook payloads share a common envelope with event-specific data.

Common Envelope
{
"event": "email.received",
"timestamp": "2024-06-12T10:30:00Z",
"data": { /* event-specific data */ }
}

email.received

email.received
{
"event": "email.received",
"timestamp": "2024-06-12T10:30:00Z",
"data": {
"inboxId": "inb_123",
"messageId": "msg_456",
"subject": "Your verification code",
"from": "noreply@example.com",
"to": ["k3v9x2m4q7tz@agentinbox.in"],
"receivedAt": "2024-06-12T10:30:00Z"
}
}

otp.extracted

otp.extracted
{
"event": "otp.extracted",
"timestamp": "2024-06-12T10:30:01Z",
"data": {
"inboxId": "inb_123",
"messageId": "msg_456",
"extractionId": "ext_789",
"value": "123456",
"confidence": 0.98
}
}

wait.completed

wait.completed
{
"event": "wait.completed",
"timestamp": "2024-06-12T10:30:01Z",
"data": {
"inboxId": "inb_123",
"waitId": "wait_789",
"status": "completed",
"result": {
"type": "otp",
"value": "123456",
"confidence": 0.98
}
}
}

Signature Verification

Verify webhook signatures using the secret you configured when creating the endpoint.

Signature Algorithm
signature = HMAC-SHA256(payload, secret)
header = "x-AgentInbox-signature: " + signature

Security

Always verify webhook signatures before processing the payload. Unsigned or incorrectly signed payloads should be rejected.

Related Documentation