Introduction
A webhook is an HTTP request triggered by an event in a source system and sent to a destination system, with a payload of data. In the Tyk Developer Portal, webhooks allow you to subscribe to specific events and receive real-time notifications when those events occur. This enables you to integrate the Developer Portal with external systems and automate workflows based on portal events.Use Cases
- Slack Notifications: Send a notification to a Slack channel when a new user registers.
- CRM Data Synchronization: Keep your CRM system up-to-date with the latest user and application data from the Tyk Developer Portal.
Supported Portal Events
The portal fires the following webhook events:- RegisterInvite when a user is invited to register in the portal
- UserRegistered when a new user is registered.
- UserAccountActivated when a user is activated.
- UserAccountDeactivated when a user is deactivated.
- PasswordReset when a user tries to reset a password.
- ApplicationRegistered when a new API consumer application is created.
- CredentialRegistered when a new API credential is created.
- AccessRequestCreated when a new API access request is created.
- AccessRequestApproved when an API access request is approved.
- AccessRequestRejected when an API access request is rejected.
- OrganizationRegistered when an API consumer organization is created.
- OrganizationRequestCreated when a new API consumer organization registration request is created.
- OrganizationRequestApproved when an API consumer organization registration request is approved.
- OrganizationRequestRejected when an API consumer organization registration request is rejected.
Register Invite
This event is fired whenever a user is invited to register in the portal via the admin UI or APIs.New User Registered
This event is fired whenever a new user is created via APIs, the admin UI, and the live portal UI (SSO or invite though the org dashboard or self-registration or invite code). Sample payload:Expandable
User Account Activated
This event is fired whenever a user (either an admin or a developer) account is activated via APIs or the admin UI. Sample payload:Expandable
User Account Deactivated
This event is fired whenever a user account is deactivated via APIs or the admin UI. Sample payload:Expandable
Password Reset
This event is fired whenever a user tries to reset their password. Sample payload:Expandable
New Application Registered
This event is fired whenever a new app is created via APIs, and the live portal UI (either via the checkout or the create app button in the developer’s dashboard). Sample payload:Expandable
New Credential Is Created
This event is fired whenever a new credential is created via APIs, the admin UI (creation after approval) and the live portal UI. Sample payload:Expandable
New Access Request Created
This event is fired whenever a new access request is created via APIs and the live portal UI. Sample payload:Expandable
An Access Request Is Approved
This event is fired whenever an access request is approved or auto-approved via the admin APIs or admin UI. Sample payload:Expandable
An Access Request Is Rejected
This event is fired whenever an access request is rejected via the admin APIs or the admin UI. Sample payload:Expandable
New Organization Registered
This event is fired whenever a new consumer organization is created via the admin APIs, the live portal (the become an organization flow) or the admin UI. Sample payload:Expandable
New Organization Registration Request Created
This event is fired whenever a new organization request is created via the live portal (the become an organization flow) or the admin UI. Sample payload:Expandable
Organization Registration Request Is Approved
This event is fired whenever an organization registration request is approved by an admin user. Sample payload:Expandable
Organization Request Is Rejected
This event is fired whenever a new organization request is rejected by an admin user. Sample payload:Expandable
Configuration
In the Tyk Developer Portal, webhooks can be configured using the Developer Portal API or the UI. The configuration includes setting up the- Target endpoint
- Selecting the events to subscribe to
Payload Structure
The payload of a webhook is a JSON object with the following structure:Event
The name of the event that triggered the webhook. Check the supported events section below for the list of available events.
Message
A JSON object containing the details of the event. The structure of this object varies depending on the event type.
Timestamp
The timestamp of when the event occurred.
Authenticate Webhook Requests
The portal uses HMAC-SHA256 signatures to secure webhooks. Each webhook request includes a signature generated using the webhook secret key and the request payload. This allows the receiving application to verify the authenticity of the request and ensure that it has not been tampered with during transit. The signature is sent in the HTTP header:- Configuration File
- Environment Variable
Error Handling and Retries
If a webhook delivery fails, Tyk will not automatically retry the request. It is the responsibility of the receiving application to handle delivery failures. Strategies for managing delivery failures:- Implement a retry mechanism in your application with exponential backoff.
- Use a message queue to buffer webhook payloads and ensure that they are processed even if your application is temporarily unavailable.
Best Practices
- Idempotency: Design your webhook handler to be idempotent, meaning that it can safely receive the same webhook payload multiple times without causing any unintended side effects.
- Payload Validation: Validate the payload of every webhook request to ensure that it is well-formed and that it has not been tampered with.