Overview
LeoKit webhooks push real-time event notifications to your server as swaps progress through their lifecycle. Discord and Slack webhook URLs are auto-detected and receive formatted embeds/blocks instead of raw JSON.Supported Events
| Event | Description | When it fires |
|---|---|---|
quote.created | A quote was requested | After /leokit/quote responds and the quote is saved |
deposit.initiated | A deposit was built | After /leokit/deposit returns transaction data |
swap.pending | Transaction submitted | After /leokit/save-transaction records the tx hash |
swap.success | Swap completed | Status polling detects completion |
swap.failed | Swap failed | Status polling detects failure |
swap.refunded | Swap refunded | Status polling detects refund |
Webhook Types
| Type | Auto-detected | Payload format | Signing |
|---|---|---|---|
standard | Default | Raw JSON | HMAC-SHA256 |
discord | discord.com / discordapp.com URLs | Discord embed | None |
slack | hooks.slack.com URLs | Slack Block Kit | None |
POST /leokit/webhooks
Register a new webhook endpoint.Authentication
RequiresApi-Key header.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | HTTPS endpoint URL. Discord/Slack URLs are auto-detected. |
events | string[] | No | Events to subscribe to. Defaults to all 6 events. |
type | string | No | standard, discord, or slack. Auto-detected from URL if omitted. |
Response
Status Code:200 OK
secret is only returned on creation. Save it immediately — you’ll need it to verify webhook signatures.
GET /leokit/webhooks
List all webhooks for the authenticated client.Authentication
RequiresApi-Key header.
Response
DELETE /leokit/webhooks?id=
Delete a webhook by ID.Authentication
RequiresApi-Key header.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Webhook ID to delete |
Response
Webhook Payload (Standard)
Standard webhooks receive a JSON payload with HMAC-SHA256 signature headers.Headers
| Header | Description |
|---|---|
X-LeoKit-Event | Event type (e.g., swap.success) |
X-LeoKit-Signature | HMAC-SHA256 signature: sha256=<hex> |
X-LeoKit-Delivery-ID | Unique delivery ID |
X-LeoKit-Timestamp | Unix timestamp (seconds) |
Body
Verifying Signatures
Compute HMAC-SHA256 of the raw request body using your webhooksecret, then compare to the X-LeoKit-Signature header:
Delivery & Retry
- Timeout: 10 seconds per delivery attempt
- Max attempts: 5
- Backoff schedule: 30s, 1m, 5m, 15m, 1h
- Final state: Marked as
failedafter 5 failed attempts
Rate Limits
- Webhooks per client: 20 active webhooks max
- Events per webhook: No per-event rate limit; high-volume clients may see deliveries batched within the same backoff window
- TLS required:
urlmust behttps://(Discord/Slack URLs are also enforced as HTTPS)
Discord Webhooks
Discord webhook URLs (discord.com/api/webhooks/...) automatically receive formatted embed payloads with color-coded event types:
- Green:
swap.success - Red:
swap.failed - Yellow:
swap.refunded - Blue:
quote.created,deposit.initiated,swap.pending
Slack Webhooks
Slack incoming webhook URLs (hooks.slack.com/services/...) automatically receive Block Kit formatted payloads with header blocks, mrkdwn fields, and contextual metadata.
Examples
Register a Discord webhook
"type": "discord" (auto-detected).