Overview
Chainrails webhooks allow you to receive real-time notifications about events happening with your transfer intents. Instead of polling the API for status updates, webhooks push event data to your server when significant changes occur.Quick Start
1. Create a Webhook
You’d rarely need to do this manually, as you can create webhooks directly from the Dashboard. But if you want to create one programmatically, here’s how:secret value - it’s only returned once when creating or regenerating the webhook. You’ll need it to verify webhook signatures.
2. Implement Your Webhook Endpoint
Your webhook endpoint must:- Accept
POSTrequests - Respond with
200 OKwithin 5 seconds - Verify the signature (instructions below)
- Be publicly accessible (HTTPS required for live webhooks)
Event Types
Subscribe to the events relevant to your use case:| Event Type | Description | When It’s Triggered |
|---|---|---|
intent.funded | User funded the intent address | When tokens are detected on the intent address |
intent.initiated | Bridge transaction started | When Chainrails initiates the bridge transaction |
intent.completed | Transfer successfully completed | When tokens arrive on destination chain |
intent.expired | Intent expired without funding | When intent funding deadline passes |
intent.refunded | Funds returned to sender | When transfer fails and funds are refunded |
Webhook Payload Structure
All webhook events follow this structure:Field Descriptions
id: Unique identifier for this webhook event (idempotency key)type: One of the event typescreated_at: When the event occurred (UTC, ISO 8601)data: The full intent object with current stateprevious_attributes: What changed (only for update events)
Security & Signature Verification
All webhook payloads are signed using HMAC-SHA256. Always verify signatures to ensure the webhook came from Chainrails.How Signing Works
- Chainrails generates a signature using your webhook secret
- Signature is sent in the
X-Chainrails-Signatureheader - Timestamp is sent in the
X-Chainrails-Timestampheader - You verify the signature matches what you compute
Signature Format
The signature is computed as:Verification Example (Node.js)
- Always verify signatures - Never trust webhook data without verification
- Check timestamp - Prevent replay attacks by rejecting old events
- Keep secrets secure - Store webhook secrets in environment variables, never in code
- Use HTTPS - Required for live webhooks
Delivery & Retries
Delivery Behavior
- Timeout: Webhooks must respond within 5 seconds
- Success: Any
2xxstatus code (200, 201, 204, etc.) - Failure: Timeouts, network errors, or non-2xx responses
- Retries: Automatic retry with exponential backoff
Retry Schedule
Failed deliveries are automatically retried:| Attempt | Delay After Failure |
|---|---|
| 1 | Immediate |
| 2 | 1 minute |
| 3 | 5 minutes |
| 4 | 15 minutes |
| 5 | 1 hour |
| 6 | 6 hours |
| 7 | 24 hours |

