Integrated Webhook - How to Transform the Body into the Request Body
Webhooks are an essential tool for integration between different systems. They allow events that occur in one system to be automatically sent to another, facilitating automation
On the SprintHub platform, configuring a webhook efficiently can be simple, as long as you understand how to map and transform the request body appropriately.
What is the request body?
The request body, or "body", is the part of an HTTP request that contains the data sent to the server. In a webhook setup, this data is usually sent in JSON format and contains specific information about the event that triggered the webhook, such as the creation of an order, updating a customer, among others.
Configuring the Webhook on Sprinthub
1. Creating a New Integration
Name and Alias: Choose a descriptive name and an alias for your integration that make it easy to identify.
Method: Set the appropriate HTTP method (usually POST).
Secret Key: Enter the secret key provided by SprintHub to ensure the security of your requests.
Expected Body: Select the expected format for the request body (normally, JSON).
2. Input Mapping
In the input mapping section, you should define how the data received in the body will be mapped and used on the SprintHub platform.
Automatic Mapping: Send a test request so the platform can capture the JSON sent.
If it is automatic mapping, the external platform will USUALLY already have the body assembled correctly. But it is necessary to check data validation when requesting.
Request Body Parameters: Here, you should map the JSON fields to the fields that will be used in SprintHub.
For example, if you are receiving a JSON like the one below:
In the mapping, you can define that the field event will be mapped to data.event, and so on. In the case of product_id, since it is inside an array, you would need to specify the position, like data.items[0].product_id, if you want the first item.
Conclusion
Transforming the body into the request body on SprintHub is a fundamental process to ensure that your webhooks work correctly and that the information is captured and used effectively. With correct mapping and a well-planned configuration, you can automate complex processes and improve integration between systems in your organization.
Tip: Always test your integrations with real data to ensure everything is working as expected. And remember to document your configurations for future maintenance.