BETA
Skip to content

Webhooks

Create and manage webhooks for feature flag events. Webhooks send HTTP POST requests to your URL when flag events occur, enabling real-time integrations.

Base URL: https://app.krafter.dev/api/v1

Signing, retry policy, and auto-disable rules are shared across the platform — see Webhook delivery.

List Webhooks

Retrieve all webhooks for a project.

GET /flags/webhooks?project_id=...

Required scope: flags:read

Query Parameters

ParameterTypeRequiredDescription
project_idstringYesProject to list webhooks for.

Example Request

bash
curl "https://app.krafter.dev/api/v1/flags/webhooks?project_id=a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d" \
  -H "Authorization: Bearer kr_live_abc123def456"

Example Response

json
{
  "data": [
    {
      "id": "4d5e6f7a-8b9c-4d0e-9f1a-2b3c4d5e6f7a",
      "url": "https://example.com/webhooks/flags",
      "events": ["flag.created", "flag.updated", "flag.toggled", "flag.archived", "flag.deleted"],
      "enabled": true,
      "failure_count": 0,
      "created_at": "2025-03-10T12:00:00Z",
      "updated_at": "2025-03-10T12:00:00Z"
    },
    {
      "id": "5e6f7a8b-9c0d-4e1f-9a2b-3c4d5e6f7a8b",
      "url": "https://slack.example.com/hooks/flags",
      "events": ["flag.toggled"],
      "enabled": true,
      "failure_count": 2,
      "created_at": "2025-03-11T15:30:00Z",
      "updated_at": "2025-03-15T10:00:00Z"
    }
  ]
}

Create Webhook

Create a new webhook for flag events.

POST /flags/webhooks

Required scope: flags:write

Request Body

FieldTypeRequiredDescription
project_idstringYesProject this webhook belongs to.
urlstringYesThe endpoint URL to receive webhook payloads. Both http:// and https:// are accepted; HTTPS is strongly recommended in production so signatures and payloads cannot be observed in transit. Private and internal addresses (RFC 1918, localhost, *.local, *.internal, link-local, IPv6 ULA/link-local) are rejected by UrlValidator for SSRF protection.
secretstringNoSecret used to sign webhook payloads with HMAC-SHA256. Strongly recommended in production. When omitted (or empty), the x-krafter-signature header is not sent — receivers cannot verify the payload origin.
eventsstring[]YesList of events to subscribe to. See Event Types.
enabledbooleanNoWhether the webhook is active. Defaults to true.

Event Types

The event name is delivered in the x-krafter-event header; the body is the JSON payload below (no envelope around it).

EventWhen firesPayload fields
flag.createdA new flag was created.flag_id, key, name
flag.updatedA flag's configuration was modified (name, description, default value, rules, etc.).flag_id, key
flag.toggledA flag was enabled or disabled (manual or scheduled).flag_id, key, enabled
flag.archivedA flag was archived. Evaluations of archived flags return the caller's default value until the flag is unarchived or deleted.flag_id, key
flag.deletedA flag was permanently deleted.flag_id, key

Example body — flag.toggled

json
{
  "flag_id": "c3d4e5f6-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
  "key": "new-checkout-flow",
  "enabled": false
}

Example Request

bash
curl -X POST https://app.krafter.dev/api/v1/flags/webhooks \
  -H "Authorization: Bearer kr_live_abc123def456" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
    "url": "https://example.com/webhooks/flags",
    "secret": "whsec_a1b2c3d4e5f6g7h8i9j0",
    "events": ["flag.created", "flag.updated", "flag.toggled", "flag.archived", "flag.deleted"]
  }'

Example Response

json
// 201 Created
{
  "data": {
    "id": "4d5e6f7a-8b9c-4d0e-9f1a-2b3c4d5e6f7a",
    "url": "https://example.com/webhooks/flags",
    "events": ["flag.created", "flag.updated", "flag.toggled", "flag.archived", "flag.deleted"],
    "enabled": true,
    "failure_count": 0,
    "created_at": "2025-03-10T12:00:00Z",
    "updated_at": "2025-03-10T12:00:00Z"
  }
}

Update Webhook

Update an existing webhook. Only provided fields are changed.

PATCH /flags/webhooks/:webhook_id

Required scope: flags:write

Request Body

FieldTypeRequiredDescription
urlstringNoThe endpoint URL to receive webhook payloads.
secretstringNoNew secret for signing webhook payloads.
eventsstring[]NoList of events to subscribe to.
enabledbooleanNoWhether the webhook is active.

Example Request

bash
curl -X PATCH https://app.krafter.dev/api/v1/flags/webhooks/5e6f7a8b-9c0d-4e1f-9a2b-3c4d5e6f7a8b \
  -H "Authorization: Bearer kr_live_abc123def456" \
  -H "Content-Type: application/json" \
  -d '{
    "events": ["flag.toggled", "flag.deleted"],
    "enabled": true
  }'

Example Response

json
{
  "data": {
    "id": "5e6f7a8b-9c0d-4e1f-9a2b-3c4d5e6f7a8b",
    "url": "https://slack.example.com/hooks/flags",
    "events": ["flag.toggled", "flag.deleted"],
    "enabled": true,
    "failure_count": 2,
    "created_at": "2025-03-11T15:30:00Z",
    "updated_at": "2025-03-16T17:00:00Z"
  }
}

Delete Webhook

Permanently delete a webhook. No further events will be delivered to this endpoint.

DELETE /flags/webhooks/:webhook_id

Required scope: flags:write

Example Request

bash
curl -X DELETE https://app.krafter.dev/api/v1/flags/webhooks/5e6f7a8b-9c0d-4e1f-9a2b-3c4d5e6f7a8b \
  -H "Authorization: Bearer kr_live_abc123def456"

Example Response

// 204 No Content

Built by Krafter Studio