Skip to content

Creating Webhooks

Webhooks are registered through the K42 platform API. You provide:

  • A callback_url - the HTTPS endpoint that will receive events
  • A list of events - which event types to subscribe to
  • An optional secret - if not provided, one is generated for you

Registering a Webhook

bash
curl -X POST https://platform.k42.com/dsp.v1/publisher.webhook/create \
  -H "Authorization: Bearer <platform-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "publisher_id": "pub_abc123",
    "callback_url": "https://your-service.com/webhooks/k42",
    "events": [
      "cashback.created",
      "cashback.cleared",
      "cashback.reverted",
      "qualifying_purchase.created",
      "qualifying_purchase.voided"
    ]
  }'

Response:

json
{
  "webhook_id": "webhook_xyz789",
  "publisher_id": "pub_abc123",
  "secret": "sec_a1b2c3d4...",
  ...
}

The secret is returned only at creation time. Store it securely - you will need it to verify webhook signatures.

You are also able to provide your own secret during creation. Refer to the Webhook API Reference for more information.

Event Types

You can subscribe to any combination of the following events:

Event TypeDescription
cashback.createdA cashback reward was triggered
cashback.clearedA pending cashback has settled
cashback.revertedA cashback was reversed
qualifying_purchase.createdA transaction counted as a loyalty stamp
qualifying_purchase.voidedA qualifying purchase was voided
qualifying_purchase.unredeemedA qualifying purchase was marked unredeemed

At least one event type must be specified.

Listing Webhooks

bash
curl -X POST https://platform.k42.com/dsp.v1/publisher.webhook/list \
  -H "Authorization: Bearer <platform-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "publisher_id": "pub_abc123"
  }'

Getting Webhook Details

bash
curl -X POST https://platform.k42.com/dsp.v1/publisher.webhook/get \
  -H "Authorization: Bearer <platform-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "webhook_id": "webhook_xyz789"
  }'

The secret is not returned in list or get responses.