Skip to content

Webhooks

Our system will send webhooks to notify your server of various events. When one of these events occurs, a POST request is made to the provided webhook URL with a JSON payload describing the event.

Webhook Concepts

Event Types

The following event types are available:

  • wallet.created: Triggered when a new wallet is created
  • webhook.created: Triggered when a new webhook is configured
  • webhook.updated: Triggered when a webhook configuration is modified
  • webhook.tested: Triggered when a webhook test is performed
  • webhook.secret.rolled: Triggered when a webhook signing secret is rotated
  • hcs.topic.created: Triggered when a new HCS topic is created
  • hcs.message.added: Triggered when a message is added to an HCS topic
  • ai.processed: Triggered when AI processing completes
  • ai.promptTested: Triggered when an AI prompt is tested
  • ocr.started: Triggered when OCR processing begins
  • ocr.completed: Triggered when OCR processing finishes

Webhook Properties

A webhook configuration includes:

FieldTypeDescription
webhookIdstringUnique identifier for the webhook
namestringName of the webhook
descriptionstringDescription of the webhook
urlstringThe URL where webhooks will be sent
enabledEventsstring[]List of event names this webhook listens to
signingSecretstringSecret used to sign the webhook payload
statusstringStatus of webhook: ‘active’, ‘paused’, or ‘disabled’
lastTriggeredAtstringISO timestamp of last webhook trigger
createdAtstringISO timestamp of webhook creation

Webhook Management

Creating a Webhook

To create a new webhook, send a POST request with the webhook configuration:

POST /webhooks
{
"name": "Document Processing Webhook",
"description": "Receives notifications for document processing events",
"url": "https://api.example.com/webhooks",
"enabledEvents": ["webhook.created", "ocr.completed", "api.processed"]
}

Response:

{
"webhookId": "18ab50c1-070d-441f-a77c-3fcaaffe738d",
"name": "Document Processing Webhook",
"description": "Receives notifications for document processing events",
"url": "https://api.example.com/webhooks",
"enabledEvents": ["webhook.created", "ocr.completed", "api.processed"],
"status": "active",
"createdAt": "2024-03-20T10:30:00Z"
}

Retrieving Webhooks

List All Webhooks

GET /webhooks?page=0&limit=10
Response:
{
"total": 25,
"page": 0,
"perPage": 10,
"hasNext": true,
"hasPrev": false,
"items": [
{
"webhookId": "18ab50c1-070d-441f-a77c-3fcaaffe738d",
"name": "Document Processing Webhook",
"url": "https://api.example.com/webhooks",
"enabledEvents": ["webhook.created", "ocr.completed", "api.processed"],
"status": "active",
"lastTriggeredAt": "2024-03-20T10:35:00Z",
"createdAt": "2024-03-20T10:30:00Z"
}
]
}

Get Single Webhook

GET /webhooks/18ab50c1-070d-441f-a77c-3fcaaffe738d
Response:
{
"webhookId": "18ab50c1-070d-441f-a77c-3fcaaffe738d",
"name": "Document Processing Webhook",
"description": "Receives notifications for document processing events",
"url": "https://api.example.com/webhooks",
"enabledEvents": ["webhook.created", "ocr.completed", "api.processed"],
"status": "active",
"lastTriggeredAt": "2024-03-20T10:35:00Z",
"createdAt": "2024-03-20T10:30:00Z"
}

Webhook Security

Each webhook has a signing secret used to verify request authenticity. You can:

Get Signing Secret

GET /webhooks/18ab50c1-070d-441f-a77c-3fcaaffe738d/signing-secret
Response:
{
"secret": "whsec_abcdef123456789"
}

Roll (Rotate) Signing Secret

POST /webhooks/roll-secret/18ab50c1-070d-441f-a77c-3fcaaffe738d
Response:
{
"webhookId": "18ab50c1-070d-441f-a77c-3fcaaffe738d",
"signingSecret": "whsec_newSecret987654321"
}

Testing Webhooks

Send a test event to verify your webhook configuration:

POST /webhooks/test/18ab50c1-070d-441f-a77c-3fcaaffe738d
Response:
{
"success": true,
"message": "Test webhook sent successfully"
}

Webhook Request History

View the history of webhook deliveries:

GET /webhooks/18ab50c1-070d-441f-a77c-3fcaaffe738d/requests?page=0&limit=10
Response:
{
"total": 50,
"page": 0,
"perPage": 10,
"hasNext": true,
"hasPrev": false,
"items": [
{
"notificationId": "ffb7b1ae-807f-4f5d-92dc-578229012977",
"content": {
"eventType": "event.uploadedDocument",
"timestamp": 1696732952771
},
"externalEventType": "event.uploadedDocument",
"createdAt": "2024-03-20T10:35:00Z"
}
]
}

API Endpoints

MethodEndpointDescription
GET/webhooksList all webhooks
POST/webhooksCreate a new webhook
GET/webhooks/:webhookIdGet a specific webhook
PUT/webhooks/:webhookIdUpdate a webhook
DELETE/webhooks/:webhookIdDelete a webhook
POST/webhooks/test/:webhookIdTest a webhook
POST/webhooks/roll-secret/:webhookIdRoll the webhook signing secret
GET/webhooks/:webhookId/requestsGet webhook request history
GET/webhooks/:webhookId/signing-secretGet the webhook signing secret

Pagination

List endpoints support pagination with the following query parameters:

  • page: Page number (default: 0)
  • limit: Items per page (default: 10)

Best Practices

  1. Security:

    • Store your webhook signing secret securely
    • Always verify webhook signatures before processing
    • Regularly rotate your signing secret using the roll secret endpoint
  2. Reliability:

    • Implement proper error handling for webhook receipts
    • Return 200 status codes promptly to acknowledge receipt
    • Process webhook data asynchronously after acknowledging
  3. Monitoring:

    • Regularly check webhook request history for failed deliveries
    • Monitor webhook status and last triggered time
    • Set up alerts for webhook failures

Webhook Payload

When an event occurs, your webhook endpoint will receive a POST request with a payload with a structure based on the following example:

{
"id": "ffb7b1ae-807f-4f5d-92dc-578229012977",
"type": "ocr.completed",
"data": {
object: {
"timestamp": 1696732952771,
"some-data": "some value"
},
}
}