Webhooks
Webhooks enable real-time updates from Maple to your application. Webhooks can be setup in the Maple web application by specifying a URL endpoint in your application to receive the relevant webhook payload when events you have subscribed to occur.
We currently use Convoy Service to send webhooks to your servers.
Setting up webhooks
Webhooks can be enabled and configured through the Maple web application under the Developers section. You can subscribe to specific events or all events.
- Go to the Webhooks sub-section under Developers.
- Click on New Webhook button
- Add a Target URL, Description and select the events you want to listen to. Then click Add Webhook
- Copy the secret.
Once you create the webhook, a secret will be provided that can be used to verify the events received. Make sure to copy the secret since you will not be able to retrieve it again.
Once you set up a webhook, you can continue to subscribe to a number of webhook event types to perform actions in your application. We continue to add more webhook event types, so feel free to reach out to us if you need a specific webhook event type.
Security
Maple will only send webhooks via a POST
request to an HTTPS endpoint. Each request will also contain X-Maple-Signature
header that represents the signature of the request. This signature can be verified to ensure that the webhook came from our servers, prevent replay attacks and ensure a zero downtime key rotation. See this blog post for more details.
A sample header may look something like this:
Receiving webhooks
Verifying webhook signature
We recommend using Convoy SDKs to verify the signature. They have support for a few common programming languages (Go, Ruby, Python, Javascript, PHP). The following code will verify the code and a 200
status code as the response
Understanding webhook data
Your endpoint must be configured to read the webhook event object. Each event has a event_type
, created_at
, data_type
and data
.
Responding to webhooks
Your endpoint must return a successful status code (2XX
) within 30s. Maple webhooks have a built-in retry mechanism for any non-2xx
(3XX
,4XX
, and 5XX
) status codes. They will be retried 10 times with an exponential backoff strategy.