Webhooks
Complete guide to handling app webhooks
Webhooks are HTTP callbacks that allow Thena to notify your app about events in real-time. This guide covers both installation lifecycle events and platform events that your app can receive.
Types of webhooks
Your app can receive two types of webhooks:
- Installation webhooks: Events related to your app’s lifecycle (installation, uninstallation, etc.)
- Platform event webhooks: Events from Thena that your app subscribes to (ticket creation, comments, etc.)
Installation webhooks
Installation webhooks notify you about events related to the installation lifecycle of your app.
Event types
The installation webhook receives several event types, indicated by the event_type
field:
app:installation
: Sent when your app is first installedapp:reinstall
: Sent when an installation needs reconfigurationapp:uninstall
: Sent when your app is uninstalledapp:configuration:update
: Sent when settings are updatedapp:team:added
: Sent when access is granted to new teamsapp:team:removed
: Sent when team access is revoked
Installation webhook payload
Example of an app:installation
event:
Other event types follow a similar structure but may include fields like updated_by
and updated_at
instead of created_by
and created_at
. The bot_token
might be redacted in update events.
Platform event webhooks
Platform event webhooks notify you about events that occur within organizations where your app is installed, based on your app’s event subscriptions.
Event identification
Platform events are identified by the message.eventType
field in the payload (e.g., ticket:created
, ticket:comment:added
).
Platform event payload
Example of a ticket:created
event:
Handling webhooks
Follow these best practices when handling both types of webhooks:
-
Endpoint setup
- Configure webhook URLs in your app manifest
- Ensure endpoints are publicly accessible via HTTPS
- Use separate URLs for installation and platform events
-
Processing events
- Parse the JSON payload from the request body
- Identify the event type
- Process events asynchronously
- Respond quickly (within 5 seconds) with a 2xx status
-
Installation webhook handling
- Store
bot_token
,installation_id
, and other credentials securely - Update configuration when settings change
- Clean up resources on uninstallation
- Handle team access changes appropriately
- Store
-
Platform event handling
- Extract event type from
message.eventType
- Process relevant data from
message.payload
- Handle event-specific logic based on type
- Implement idempotency to handle duplicates
- Extract event type from
Security best practices
-
Endpoint security
- Always use HTTPS
- Implement request verification
- Validate webhook signatures when provided
- Keep endpoints behind authentication
-
Data handling
- Store sensitive data (like
bot_token
) securely - Encrypt data at rest
- Follow data retention policies
- Clean up data when no longer needed
- Store sensitive data (like
-
Error handling
- Implement proper error logging
- Handle retries gracefully
- Set up monitoring for webhook failures
- Have fallback mechanisms for critical operations
-
Rate limiting
- Implement rate limiting on your endpoints
- Handle concurrent requests properly
- Queue events for processing if needed
- Monitor webhook traffic patterns
Best practices
-
Response time
- Respond within 5 seconds
- Process events asynchronously
- Queue long-running tasks
- Monitor processing times
-
Reliability
- Implement retry mechanisms
- Handle duplicate events
- Log all webhook activities
- Set up alerting for failures
-
Scalability
- Design for high throughput
- Use appropriate caching
- Implement proper database indexing
- Consider using message queues
-
Maintenance
- Monitor webhook health
- Track success/failure rates
- Set up proper logging
- Regular security audits