Overview
Webhooks let your application receive HTTP POST callbacks when events occur in your Stable organization. Instead of polling the API, you register a URL and Stable pushes event data to you in real time.
Webhooks require the API Access entitlement on your organization plan.
Setting Up Webhooks
1. Create a Webhook Endpoint
curl -X POST https://api.stable.se/v1/organizations/{org_public_id}/webhooks/endpoints \
-H "Authorization: Bearer $STABLE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.com/webhooks/stable",
"description": "My integration webhook",
"event_types": ["horse.created", "booking.created", "task.updated"]
}'
Managing webhooks requires an organization Owner or Admin signed in with their Stable account; API tokens are not accepted. Creating an endpoint and rotating its secret can ask for two-factor confirmation first.
2. Receive Events
When a subscribed event occurs, Stable sends a POST request to your URL with these headers:
| Header | Description |
|---|---|
Content-Type | application/json |
User-Agent | Stable-Webhooks/1.0 |
X-Webhook-Id | Unique event ID for deduplication |
X-Webhook-Signature | HMAC-SHA256 signature (see Verifying Signatures) |
X-Webhook-Timestamp | Unix timestamp (seconds) when the event was sent |
The request body:
{
"id": "evt_abc123",
"type": "horse.created",
"created_at": "2026-03-28T14:30:00Z",
"organization_id": "org_xyz789",
"data": {
"entity_type": "horse",
"entity_id": "hrs_def456",
"action": "created",
"attributes": {
"name": "Starlight",
"breed": "Warmblood"
}
}
}
For update events, the payload includes a changes object showing what changed:
{
"id": "evt_ghi789",
"type": "horse.updated",
"created_at": "2026-03-28T15:00:00Z",
"organization_id": "org_xyz789",
"data": {
"entity_type": "horse",
"entity_id": "hrs_def456",
"action": "updated",
"attributes": { "name": "Starlight II", "breed": "Warmblood" },
"changes": {
"before": { "name": "Starlight" },
"after": { "name": "Starlight II" },
"changed_fields": ["name"]
}
}
}
3. Respond with 2xx
Your endpoint must respond with a 2xx status code within 30 seconds to acknowledge receipt. Any other response is treated as a failure.
Event Types
List the available event types with GET /v1/organizations/{org_public_id}/webhooks/event-types before subscribing. The examples below are not a complete list:
Horses
horse.created horse.updated horse.deleted
Horse Health
health_record.created health_record.updated health_record.deleted
vaccination.created vaccination.updated vaccination.deleted
medication.created medication.updated medication.deleted
farrier_record.created farrier_record.updated farrier_record.deleted
weight_history.created weight_history.updated weight_history.deleted
vitals_log.created vitals_log.updated vitals_log.deleted
health_template.created health_template.updated health_template.deleted
Bookings
booking.created booking.updated booking.cancelled
Tasks
task.created task.updated task.deleted
task_series.created task_series.updated task_series.deleted
Training
training_program.created training_program.updated training_program.deleted
Products & Inventory
product.created product.updated product.deleted
Documents
document.created document.updated document.deleted
Billing
invoice.created invoice.updated
Equipment
equipment.created equipment.updated equipment.deleted
Expenses
expense.created expense.updated expense.deleted
Organization
organization.updated organization.member_added organization.member_removed
Verifying Signatures
Every webhook delivery includes a cryptographic signature so you can verify it came from Stable.
Algorithm
- Get the timestamp from
X-Webhook-Timestampand the raw request body - Construct the signing message:
{timestamp}.{body} - Compute HMAC-SHA256 using your endpoint's secret (hex-decoded) as the key
- Compare with the
X-Webhook-Signatureheader value (format:sha256=<hex>)
Example (Node.js)
import crypto from 'node:crypto';
function verifyWebhookSignature(secret, timestamp, body, signature) {
if (typeof timestamp !== 'string' || typeof signature !== 'string') return false;
if (!/^\d+$/.test(timestamp) || !/^sha256=[a-f0-9]{64}$/i.test(signature)) return false;
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const message = `${timestamp}.${body}`;
// Secret is hex-encoded; decode it for HMAC key
const key = Buffer.from(secret, 'hex');
const expected = 'sha256=' + crypto
.createHmac('sha256', key)
.update(message)
.digest('hex');
// Use constant-time comparison to prevent timing attacks
const expectedBytes = Buffer.from(expected);
const suppliedBytes = Buffer.from(signature);
return expectedBytes.length === suppliedBytes.length &&
crypto.timingSafeEqual(expectedBytes, suppliedBytes);
}
// In your webhook handler:
const timestamp = req.headers['x-webhook-timestamp'];
const signature = req.headers['x-webhook-signature'];
const body = req.rawBody; // raw request body as string
if (!verifyWebhookSignature(endpointSecret, timestamp, body, signature)) {
return res.status(401).send('Invalid signature');
}
Secret Management
Your endpoint secret is a 64-character hex string (32 random bytes). You receive it when creating the endpoint and can rotate it via the API:
curl -X POST https://api.stable.se/v1/organizations/{org_public_id}/webhooks/endpoints/{endpoint_id}/rotate-secret \
-H "Authorization: Bearer $STABLE_TOKEN"
Retry Policy
Stable makes up to five delivery attempts, including the first one. After a failed attempt it waits before trying again:
| Attempt | Delay |
|---|---|
| 1st retry | 1 minute |
| 2nd retry | 5 minutes |
| 3rd retry | 30 minutes |
| 4th retry | 2 hours |
If the fifth attempt fails too, the delivery is abandoned. Retry times are approximate. You can retry a failed delivery yourself with POST /v1/organizations/{org_public_id}/webhooks/deliveries/{delivery_id}/retry.
Circuit Breaker
After 10 consecutive failed deliveries (adjustable in the endpoint's notification settings), the endpoint is disabled. A successful delivery resets the count. You can re-enable a disabled endpoint via the API:
curl -X POST https://api.stable.se/v1/organizations/{org_public_id}/webhooks/endpoints/{endpoint_id}/enable \
-H "Authorization: Bearer $STABLE_TOKEN"
Security
URL Validation
Webhook URLs must use HTTPS and point to a publicly reachable address.
Webhook Management API
| Method | Path | Description |
|---|---|---|
| GET | /v1/organizations/{org_public_id}/webhooks/endpoints | List all endpoints |
| POST | /v1/organizations/{org_public_id}/webhooks/endpoints | Create an endpoint |
| GET | /v1/organizations/{org_public_id}/webhooks/endpoints/{endpoint_id} | Get endpoint details |
| PATCH | /v1/organizations/{org_public_id}/webhooks/endpoints/{endpoint_id} | Update an endpoint |
| DELETE | /v1/organizations/{org_public_id}/webhooks/endpoints/{endpoint_id} | Delete an endpoint |
| POST | /v1/organizations/{org_public_id}/webhooks/endpoints/{endpoint_id}/test | Send a test event |
| GET | /v1/organizations/{org_public_id}/webhooks/event-types | List available event types |
| GET | /v1/organizations/{org_public_id}/webhooks/endpoints/{endpoint_id}/deliveries | View delivery history |
Best Practices
- Respond quickly -- acknowledge the webhook with a
200immediately, then process asynchronously - Verify signatures -- always validate
X-Webhook-Signatureto ensure requests come from Stable - Handle duplicates -- use
X-Webhook-Idfor deduplication in case of retries - Subscribe selectively -- only subscribe to the event types you need to reduce unnecessary traffic
- Monitor your endpoint -- watch for failures in the webhook delivery logs (available via API)
- Use HTTPS -- all webhook URLs must use HTTPS for security