Skip to content

Webhooks

Webhooks allow your application to receive real-time notifications when events occur in Tiketti.

Overview

When an event occurs (e.g., ticket created, message received), Tiketti sends an HTTP POST request to your configured endpoint with event data.

Webhook Endpoints

MethodEndpointDescription
GET/webhooksList webhooks
POST/webhooksCreate webhook
GET/webhooks/:idGet webhook
PATCH/webhooks/:idUpdate webhook
DELETE/webhooks/:idDelete webhook

Create Webhook

Terminal window
POST /api/v1/webhooks
{
"url": "https://your-server.com/webhooks/tiketti",
"events": ["ticket.created", "ticket.updated", "message.created"],
"secret": "your_webhook_secret"
}
FieldTypeRequiredDescription
urlstringYesHTTPS endpoint to receive events
eventsstring[]YesEvents to subscribe to
secretstringNoSecret for signature verification
activebooleanNoEnable/disable webhook

Available Events

Ticket Events

EventTrigger
ticket.createdNew ticket created
ticket.updatedTicket properties changed
ticket.deletedTicket deleted
ticket.assignedTicket assigned to user
ticket.status_changedStatus changed

Message Events

EventTrigger
message.createdNew message on ticket
message.deletedMessage deleted

Contact Events

EventTrigger
contact.createdNew contact created
contact.updatedContact updated
contact.deletedContact deleted

Time Entry Events

EventTrigger
time_entry.createdTime logged
time_entry.updatedTime entry updated
time_entry.deletedTime entry deleted

Webhook Payload

Headers

HeaderDescription
Content-Typeapplication/json
X-Tiketti-EventEvent type
X-Tiketti-DeliveryUnique delivery ID
X-Tiketti-SignatureHMAC signature
X-Tiketti-TimestampEvent timestamp

Body Structure

{
"event": "ticket.created",
"timestamp": "2024-01-15T10:30:00Z",
"organization_id": "org-uuid",
"data": {
"id": "ticket-uuid",
"code": "ACME-42",
"subject": "Cannot login",
"status": "open",
"priority": "high",
"contact": {
"id": "contact-uuid",
"name": "John Doe",
"email": "john@example.com"
},
"created_at": "2024-01-15T10:30:00Z"
}
}

Signature Verification

Verify webhook authenticity using the signature:

const crypto = require('crypto');
function verifySignature(payload, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(`sha256=${expected}`)
);
}

Retry Policy

Failed webhook deliveries are retried:

AttemptDelay
1Immediate
21 minute
35 minutes
430 minutes
52 hours

After 5 failed attempts, the webhook is marked as failed. Fix the issue and re-enable.

Best Practices

Endpoint Requirements

  • Use HTTPS (required)
  • Respond with 2xx within 30 seconds
  • Return quickly, process asynchronously
  • Handle duplicate deliveries (idempotency)

Security

  • Use a strong secret
  • Verify signatures
  • Validate event types
  • Use IP allowlisting if possible

Reliability

  • Respond immediately, process later
  • Use a queue for processing
  • Handle retries gracefully
  • Log all webhook deliveries

Testing

Test Endpoint

Send a test event to your webhook:

Terminal window
POST /api/v1/webhooks/:id/test

Sends a test.ping event to verify connectivity.

Webhook Logs

View delivery attempts:

Terminal window
GET /api/v1/webhooks/:id/deliveries
{
"data": [
{
"id": "delivery-uuid",
"event": "ticket.created",
"status": "success",
"response_code": 200,
"response_time_ms": 150,
"created_at": "2024-01-15T10:30:00Z"
}
]
}

Error Codes

CodeDescription
WEBHOOK_NOT_FOUNDWebhook doesn’t exist
INVALID_URLURL must be HTTPS
INVALID_EVENTSUnknown event types
WEBHOOK_DISABLEDWebhook is not active