Webhooks
Listen for events so your integration can trigger reactions.
Treddy uses webhooks which allows you to receive real-time updates and trigger reactions in your integration. When an event occurs in your integration, Treddy sends a notification to your app in the form of a JSON payload. You can then use this information to perform actions in your backend systems.
Steps to receive webhooks
To set up Treddy webhooks, follow these steps:
- Identify the events you want to monitor and the corresponding event payloads.
- Create a webhook endpoint as an HTTP URL on your server.
- Implement handling of requests from Treddy by parsing each event object and returning a 2xx response status code.
- Deploy your webhook endpoint as a publicly accessible HTTPS URL.
- Register your HTTPS URL in the Treddy developer portal.
Event
{
"id": "...",
"event": "signature.status",
"api_version": "v1",
"created": 1671434298,
"data": {
"dealId": "...",
"userId": "...",
"status": "...",
"signatureType": "...",
"signatureDate": "..."
}
}
Return a 2xx response
Your endpoint must quickly return a successful status code (2xx) prior to any complex logic that could cause a timeout.
Secure your webhooks
Use webhook signatures to verify that Treddy generated a webhook request and that it didn’t come from a server acting like Treddy.
@POST
@Produces(MediaType.APPLICATION_JSON)
public Response handleEvent(String payload, @HeaderParam("Treddy-Signature") String signature) {
boolean validHeader = Signature.verifyHeader(payload, signature);
if (!validHeader) {
return Response.status(400).build();
}
return Response.ok().build();
}