Webhooks
Webhooks are a crucial part of T-Gate's integration capabilities, allowing seamless communication and data synchronization between T-Gate and its partners. This guide will walk you through what webhooks are, how they work, who can benefit from them, and how to set them up.
What is a Webhook?
A webhook is a user-defined HTTP callback that is triggered by specific events. When an event occurs, such as an update or a creation in T-Gate, a webhook sends a POST request to a URL configured by the receiving application. This allows applications to receive real-time updates and act upon changes as they happen.
Who Can Benefit from Webhooks?
Essentially, any system that requires real-time data synchronization with T-Gate can benefit from webhooks.
Webhook Triggers
T-Gate provides a set of webhook triggers that notify partners when specific actions occur. These include:
- Create: Triggered when a new resource is created.
- Update: Triggered when an existing resource is updated.
- Destroy: Triggered when a resource is deleted.
Each webhook contains information about the id
, resource_type
, and action
that triggered the webhook, allowing partners to determine the nature of the change.
How To Set Up and Use Webhooks
Partners can set up webhooks through their application portals, where they can specify the URL that should receive the webhook POST requests. It's essential to ensure that the receiving endpoint is secure and capable of handling incoming requests.
For detailed instructions, refer to the Partner API → Setup Webhooks Guide.
Retry On Failure
T-Gate expects partners to respond with a 2XX status code (typically 200 OK) to confirm successful receipt of the webhook. However, T-Gate does not retry webhook deliveries if they fail. Once a webhook is sent, T-Gate accepts any response from the partner's side and does not attempt to resend the webhook, regardless of the response status.
Webhooks Timeout
T-Gate's webhooks have a timeout policy to manage the response time of the receiving application. Each webhook request will timeout after 5 seconds if not acknowledged. It is recommended that receiving endpoints are optimized for quick responses to avoid timeouts.
Webhooks Body
The body of the webhook request sent by T-Gate contains:
- ID: The unique identifier of the resource that triggered the webhook.
- Resource Type: The type of resource involved (e.g., branch, section, item, order…etc).
- Action: The specific action that triggered the webhook (e.g., item.create, order.update, integration_scope.destroy…etc).
Partners can use this information to determine what action to take in response to the webhook. By retrieving updates based on the id
and resource_type
, applications can ensure their data remains current and synchronized with T-Gate.
Example Webhook Body
{
"event_type": "item.update", // action that triggered the webhook
"payload": {
"id":194, // resource_id
"type":"Item" // resource_type
},
"meta": {} // whatever meta you added when setting up the hook
}
Additional Resources
For more detailed information about each webhook, the data included, and what triggers them, please refer to the Partner Webhooks API documentation.
Updated 8 months ago