Webhooks configuration

  • To enable notifications, please follow these steps:
  1. Create a new event subscription via API:

POST http://yourproject.vouchery.io/api/v2.0/subscriptions

In the request body, you need to provide a list of events that you want to listen to and a callback_url which is an HTTP endpoint in your system where events will be delivered.

Make sure you have full control over this endpoint. You will need to adjust the GET response in the verification process.

{
            "callback_url": "https://<your_server_url>",
            "events": [
                "voucher_redeemed", 
                "voucher_batch_created",
                "voucher_created", 
                "voucher_redemption_rejected",
                "budget_limit_reached",
                "voucher_redemptions_limit_reached"
            ]
    }
  1. In the response, you should receive a subscription ID and verification_code that will be used to verify that provided callback_url is valid and reachable from Vouchery.io

  2. Now you should configure your callback_url GET response so that it will reply to the verification request. The reply should have text/plain MIME type and contain only verification_code in the body.

  3. Once the reply is configured you should verify it via API:

GET http://yourproject.vouchery.io/api/v2.0/subscriptions/{subscription_id}/verify

  1. After a successful response (204) the subscription is activated. You should start receiving POST requests on callback_url in the following format:
{
    "type": <event_type>,
    "data": <event_details>
}

🚧

NOTE: HTTP 400 (Bad Request)

HTTP 400 (Bad Request) reply usually means that your reply is malformed / contains an invalid verification_code. You will not receive any events until the callback_url is properly verified.

After successful verification, you can disable the GET handler.

  1. To delete subscription use the following API:

DELETE http://yourproject.vouchery.io/api/v2.0/subscriptions/{subscription_id}