Webhooks
Webhooks allow you to receive real-time notifications about the completion of document processing, instead of constantly polling the API.
How Webhooks Work
- You specify the
webhook_urlwhen creating a document. - Rekognita processes the document.
- Upon completion, Rekognita sends a POST request to your URL with the result.
Setup
Specify the webhook URL when submitting a document:
curl -X POST https://api.rekognita.com/v1/documents \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@invoice.pdf" \
-F "webhook_url=https://your-server.com/webhooks/rekognita"Payload Format
Rekognita sends a POST request with a JSON body:
{
"event": "document.completed",
"document_id": "doc_abc123",
"status": "completed",
"created_at": "2025-01-15T12:00:00Z",
"completed_at": "2025-01-15T12:00:03Z",
"result": {
"text": "Recognized document text...",
"confidence": 0.991,
"pages": 1,
"language": "en"
}
}Event Types
| Event | Description |
|---|---|
document.completed | Document processed successfully |
document.failed | Error during document processing |
document.partial | Partial result (for large documents) |
Request Verification
Each webhook includes an X-Rekognita-Signature header to verify authenticity (HMAC-SHA256):
import crypto from 'crypto';
function verifyWebhook(payload: string, signature: string, secret: string) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}Security. Always verify the webhook signature. The webhook secret can be found in Dashboard → Settings → Webhooks.
Retries
If your server does not return a 2xx code, Rekognita will retry the request:
- 1st retry — in 30 seconds
- 2nd retry — in 5 minutes
- 3rd retry — in 30 minutes
- Final retry — in 2 hours
Your endpoint must respond within 10 seconds. If processing takes longer, save the payload and process it asynchronously.