stable.se

API-Tokens und Webhooks gehören heute zu keinem unserer Pläne. Schreiben Sie uns, bevor Sie auf der API aufbauen.

Die Entwicklerdokumentation ist derzeit nur auf Englisch verfügbar.

Webhooks

Receive real-time notifications when events happen in your Stable organization.

5 min read

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:

HeaderDescription
Content-Typeapplication/json
User-AgentStable-Webhooks/1.0
X-Webhook-IdUnique event ID for deduplication
X-Webhook-SignatureHMAC-SHA256 signature (see Verifying Signatures)
X-Webhook-TimestampUnix 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

  1. Get the timestamp from X-Webhook-Timestamp and the raw request body
  2. Construct the signing message: {timestamp}.{body}
  3. Compute HMAC-SHA256 using your endpoint's secret (hex-decoded) as the key
  4. Compare with the X-Webhook-Signature header 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:

AttemptDelay
1st retry1 minute
2nd retry5 minutes
3rd retry30 minutes
4th retry2 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

MethodPathDescription
GET/v1/organizations/{org_public_id}/webhooks/endpointsList all endpoints
POST/v1/organizations/{org_public_id}/webhooks/endpointsCreate 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}/testSend a test event
GET/v1/organizations/{org_public_id}/webhooks/event-typesList available event types
GET/v1/organizations/{org_public_id}/webhooks/endpoints/{endpoint_id}/deliveriesView delivery history

Best Practices

  • Respond quickly -- acknowledge the webhook with a 200 immediately, then process asynchronously
  • Verify signatures -- always validate X-Webhook-Signature to ensure requests come from Stable
  • Handle duplicates -- use X-Webhook-Id for 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