Receive real-time notifications about document events
Webhooks allow you to receive real-time notifications when events occur in Antinium. Instead of polling the API, you can set up webhooks to be notified immediately when documents are translated, updated, or shared.
Note: Your webhook endpoint must be publicly accessible and use HTTPS. For local development, use a tool like ngrok to expose your local server.
Fired when a document translation is completed.
Fired when a document is updated or edited.
Fired when a document is shared with new people.
Fired when a document is deleted.
Fired when a comment is added to a document.
Webhook payloads are sent as JSON in the request body:
{
"event": "document.translated",
"timestamp": "2024-01-15T10:30:00Z",
"data": {
"document_id": "doc_123",
"translation_id": "trans_456",
"target_language": "es",
"status": "completed"
}
}To verify that webhooks are coming from Antinium, we include a signature in the X-Antinium-Signature header. Verify it using your webhook secret:
// Node.js example
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const hmac = crypto.createHmac('sha256', secret);
const digest = hmac.update(JSON.stringify(payload)).digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(digest)
);
}
// In your webhook handler
const signature = req.headers['x-antinium-signature'];
const isValid = verifyWebhook(req.body, signature, WEBHOOK_SECRET);
if (!isValid) {
return res.status(401).send('Invalid signature');
}If your webhook endpoint returns an error (4xx or 5xx status code), Antinium will retry the webhook:
Your endpoint should return a 2xx status code within 10 seconds to be considered successful.
// Express.js example
app.post('/webhooks/antinium', express.json(), (req, res) => {
// Verify signature
const signature = req.headers['x-antinium-signature'];
if (!verifyWebhook(req.body, signature, process.env.WEBHOOK_SECRET)) {
return res.status(401).send('Invalid signature');
}
// Handle the event
const { event, data } = req.body;
switch (event) {
case 'document.translated':
console.log('Document translated:', data.document_id);
// Update your system, send notifications, etc.
break;
case 'document.updated':
console.log('Document updated:', data.document_id);
break;
// Handle other events...
}
// Always return 200 to acknowledge receipt
res.status(200).send('OK');
});You can test your webhook endpoint:
See the delivery status of all webhook events:
Temporarily disable a webhook without deleting it: