Webhook endpoints

Register and manage webhook endpoints programmatically — create configs, inspect deliveries, and rotate the signing secret used to verify events.

A webhook endpoint is a URL Tokeflow delivers signed events to, plus the configuration that governs it: which event types it subscribes to, whether it is active, and the signing secret used to prove each delivery came from Tokeflow.

These endpoints let you manage that configuration from your backend instead of the Dashboard — useful when you provision merchants programmatically or need to rotate secrets on a schedule. Every delivery Tokeflow sends is signed; always verify the signature before acting on an event. See Verifying webhook signatures.

The signing secret (whsec_…) is returned only when you create the endpoint or rotate the secret. Store it in a secrets manager at that moment — it cannot be retrieved later. Rotating invalidates the previous secret, so deploy the new one before rotating, or accept a short window of failed verifications.

The webhook endpoint object

A webhook configuration as returned by the create, list, and retrieve endpoints.

FieldTypeDescription
idstringUnique identifier for the webhook configuration.
merchant_idstringMerchant ID that owns this webhook configuration.
urlstringThe URL where webhook events will be sent.
descriptionstring | nullDescription for this webhook configuration.
event_filterarray | nullList of event types subscribed to. Null means all events.
is_activebooleanWhether this webhook configuration is active.
created_atstringWhen the webhook configuration was created. (ISO 8601 UTC).
updated_atstringWhen the webhook configuration was last updated. (ISO 8601 UTC).
last_triggered_atstring | nullWhen the webhook was last triggered (most recent delivery). (ISO 8601 UTC).

Endpoints

GET/api/v1/merchants/:merchant_id/webhook-configs

OrgMerchant

Auth: Organization key (with merchant_id) or Merchant key.

List webhook configurations.

Path parameters

FieldTypeRequiredDescription
merchant_idstringYes

Query parameters

FieldTypeRequiredDescription
pagenumberNoPage number (1-indexed). Default 1, min 1.
limitnumberNoNumber of items per page. Default 20, min 1, max 100.

Example request

curl -G https://api.tokeflow.com/api/v1/merchants/mrc_8a3f12d9/webhook-configs \
  -H "Authorization: Bearer sk_live_mer_…" \
  --data-urlencode "page=1" \
  --data-urlencode "limit=20"

Example response200

{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "merchant_id": "550e8400-e29b-41d4-a716-446655440001",
      "url": "https://api.example.com/webhooks/payments",
      "description": "Production payment notifications",
      "event_filter": [
        "transaction.authorized",
        "transaction.failed",
        "transaction.refunded"
      ],
      "is_active": true,
      "created_at": "2024-01-15T10:30:00.000Z",
      "updated_at": "2024-01-15T10:30:00.000Z",
      "last_triggered_at": "2024-01-15T10:30:00.000Z"
    }
  ],
  "meta": {
    "page": 1,
    "limit": 20,
    "total": 42,
    "total_pages": 3,
    "has_next": true,
    "has_prev": false
  }
}

POST/api/v1/merchants/:merchant_id/webhook-configs

OrgMerchant

Auth: Organization key (with merchant_id) or Merchant key.

Create a webhook configuration.

Path parameters

FieldTypeRequiredDescription
merchant_idstringYes

Request fields

FieldTypeRequiredDescription
urlstringYesThe URL where webhook events will be sent.
descriptionstringNoOptional description for this webhook configuration.
event_filterarrayNoList of event types to subscribe to. If not provided, all events will be sent.

Example request

curl -X POST https://api.tokeflow.com/api/v1/merchants/mrc_8a3f12d9/webhook-configs \
  -H "Authorization: Bearer sk_live_mer_…" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://api.example.com/webhooks/payments",
    "description": "Production payment notifications",
    "event_filter": [
      "transaction.authorized",
      "transaction.failed",
      "transaction.refunded"
    ]
  }'

Example response201

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "merchant_id": "550e8400-e29b-41d4-a716-446655440001",
  "url": "https://api.example.com/webhooks/payments",
  "description": "Production payment notifications",
  "event_filter": [
    "transaction.authorized",
    "transaction.failed",
    "transaction.refunded"
  ],
  "is_active": true,
  "created_at": "2024-01-15T10:30:00.000Z",
  "updated_at": "2024-01-15T10:30:00.000Z",
  "last_triggered_at": "2024-01-15T10:30:00.000Z",
  "secret": "whsec_abc123def456..."
}

DELETE/api/v1/merchants/:merchant_id/webhook-configs/:webhook_id

OrgMerchant

Auth: Organization key (with merchant_id) or Merchant key.

Delete a webhook configuration.

Path parameters

FieldTypeRequiredDescription
merchant_idstringYes
webhook_idstringYes

Example request

curl -X DELETE https://api.tokeflow.com/api/v1/merchants/mrc_8a3f12d9/webhook-configs/whk_3e9d1f42 \
  -H "Authorization: Bearer sk_live_mer_…"

Example response204 No Content

An empty body is returned on success.


GET/api/v1/merchants/:merchant_id/webhook-configs/:webhook_id

OrgMerchant

Auth: Organization key (with merchant_id) or Merchant key.

Get a webhook configuration.

Path parameters

FieldTypeRequiredDescription
merchant_idstringYes
webhook_idstringYes

Example request

curl https://api.tokeflow.com/api/v1/merchants/mrc_8a3f12d9/webhook-configs/whk_3e9d1f42 \
  -H "Authorization: Bearer sk_live_mer_…"

Example response200

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "merchant_id": "550e8400-e29b-41d4-a716-446655440001",
  "url": "https://api.example.com/webhooks/payments",
  "description": "Production payment notifications",
  "event_filter": [
    "transaction.authorized",
    "transaction.failed",
    "transaction.refunded"
  ],
  "is_active": true,
  "created_at": "2024-01-15T10:30:00.000Z",
  "updated_at": "2024-01-15T10:30:00.000Z",
  "last_triggered_at": "2024-01-15T10:30:00.000Z"
}

PATCH/api/v1/merchants/:merchant_id/webhook-configs/:webhook_id

OrgMerchant

Auth: Organization key (with merchant_id) or Merchant key.

Update a webhook configuration.

Path parameters

FieldTypeRequiredDescription
merchant_idstringYes
webhook_idstringYes

Request fields

FieldTypeRequiredDescription
urlstringNoThe URL where webhook events will be sent.
descriptionstringNoOptional description for this webhook configuration.
event_filterarrayNoList of event types to subscribe to.
is_activebooleanNoWhether this webhook configuration is active.

Example request

curl -X PATCH https://api.tokeflow.com/api/v1/merchants/mrc_8a3f12d9/webhook-configs/whk_3e9d1f42 \
  -H "Authorization: Bearer sk_live_mer_…" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://api.example.com/webhooks/payments",
    "description": "Production payment notifications",
    "event_filter": [
      "transaction.authorized",
      "transaction.failed",
      "transaction.refunded"
    ],
    "is_active": true
  }'

Example response200

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "merchant_id": "550e8400-e29b-41d4-a716-446655440001",
  "url": "https://api.example.com/webhooks/payments",
  "description": "Production payment notifications",
  "event_filter": [
    "transaction.authorized",
    "transaction.failed",
    "transaction.refunded"
  ],
  "is_active": true,
  "created_at": "2024-01-15T10:30:00.000Z",
  "updated_at": "2024-01-15T10:30:00.000Z",
  "last_triggered_at": "2024-01-15T10:30:00.000Z"
}

GET/api/v1/merchants/:merchant_id/webhook-deliveries

OrgMerchant

Auth: Organization key (with merchant_id) or Merchant key.

List webhook delivery history.

Path parameters

FieldTypeRequiredDescription
merchant_idstringYes

Query parameters

FieldTypeRequiredDescription
pagenumberNoPage number (1-indexed). Default 1, min 1.
limitnumberNoNumber of items per page. Default 20, min 1, max 100.
statusstringNoFilter by delivery status
fromstringNoFrom timestamp (ISO 8601 format) - filter deliveries after this time
tostringNoTo timestamp (ISO 8601 format) - filter deliveries before this time

Example request

curl -G https://api.tokeflow.com/api/v1/merchants/mrc_8a3f12d9/webhook-deliveries \
  -H "Authorization: Bearer sk_live_mer_…" \
  --data-urlencode "page=1" \
  --data-urlencode "limit=20" \
  --data-urlencode "status=failed" \
  --data-urlencode "from=2024-01-01T00:00:00Z"

Example response200

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "merchant_id": "550e8400-e29b-41d4-a716-446655440001",
  "merchant_webhook_config_id": "550e8400-e29b-41d4-a716-446655440002",
  "payment_transaction_id": "550e8400-e29b-41d4-a716-446655440003",
  "order_id": "550e8400-e29b-41d4-a716-446655440004",
  "event_type": "transaction.authorized",
  "payload": {
    "event": "transaction.authorized",
    "data": {
      "transaction_id": "..."
    }
  },
  "target_url": "https://api.example.com/webhooks/payments",
  "attempt_number": 1,
  "http_status_code": 200,
  "response_body": "{\"received\": true}",
  "status": "success",
  "next_retry_at": "2024-01-15T10:35:00.000Z",
  "created_at": "2024-01-15T10:30:00.000Z",
  "sent_at": "2024-01-15T10:30:01.000Z"
}

POST/api/v1/merchants/:merchant_id/webhooks/:webhook_id/rotate-secret

OrgMerchant

Auth: Organization key (with merchant_id) or Merchant key.

Rotate the webhook secret.

Path parameters

FieldTypeRequiredDescription
merchant_idstringYes
webhook_idstringYes

Example request

curl -X POST https://api.tokeflow.com/api/v1/merchants/mrc_8a3f12d9/webhooks/whk_3e9d1f42/rotate-secret \
  -H "Authorization: Bearer sk_live_mer_…"

Example response200

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "merchant_id": "550e8400-e29b-41d4-a716-446655440001",
  "url": "https://api.example.com/webhooks/payments",
  "description": "Production payment notifications",
  "event_filter": [
    "transaction.authorized",
    "transaction.failed",
    "transaction.refunded"
  ],
  "is_active": true,
  "created_at": "2024-01-15T10:30:00.000Z",
  "updated_at": "2024-01-15T10:30:00.000Z",
  "last_triggered_at": "2024-01-15T10:30:00.000Z",
  "secret": "whsec_abc123def456..."
}

Errors

Errors use the standard envelope. The most common cases here:

HTTPtypeTypical cause
400validation_errorMissing required field, or an operation the current state does not allow.
401authentication_errorMissing or invalid API key.
403authorization_errorThe key lacks the required scope.
404not_found_errorThe resource does not exist or is not owned by this entity.
429rate_limit_errorRate limit exceeded — back off exponentially.

See Errors for the full catalog.

On this page