Skip to content

Webhooks Reference

Learn about Voucher API webhooks and how to implement them.

Webhook Events

Event Description Payload
voucher.created Voucher created Voucher object
voucher.updated Voucher updated Voucher object
voucher.deleted Voucher deleted Voucher ID
voucher.validated Voucher validated Validation result
voucher.applied Voucher applied Application result
voucher.expired Voucher expired Voucher ID

Webhook Configuration

{
  "url": "https://your-domain.com/webhooks/voucher",
  "events": ["voucher.created", "voucher.updated"],
  "secret": "your_webhook_secret"
}

Event Payloads

Voucher Created

{
  "event": "voucher.created",
  "data": {
    "id": "v_123",
    "code": "SUMMER2024",
    "type": "percentage",
    "value": 20,
    "created_at": "2024-03-20T10:00:00Z"
  }
}

Voucher Validated

{
  "event": "voucher.validated",
  "data": {
    "voucher_id": "v_123",
    "is_valid": true,
    "discount_amount": 20.00,
    "validated_at": "2024-03-20T10:01:00Z"
  }
}

Security

  1. Signature Verification
  2. Verify webhook signatures
  3. Use secure webhook secrets
  4. Implement request validation

  5. TLS Requirements

  6. Use HTTPS endpoints
  7. Validate SSL certificates
  8. Monitor certificate expiry

  9. IP Allowlisting

  10. Allowlist Voucher API IPs
  11. Monitor IP changes
  12. Update allowlist regularly

Best Practices

  1. Implementation
  2. Handle duplicate events
  3. Implement idempotency
  4. Process events asynchronously

  5. Error Handling

  6. Log failed deliveries
  7. Implement retry logic
  8. Monitor webhook health

  9. Testing

  10. Use webhook testing tools
  11. Verify event handling
  12. Test error scenarios

Next Steps