# Webhook Events

This page catalogs webhook event types, payload shapes, and delivery behavior. For registration, headers, and security, start with [Webhooks](/docs/developers/webhooks). For HMAC verification steps, see [Webhook Signature Verification](/docs/developers/webhook-signature-verification).

## Envelope format

Every delivered webhook uses the same top-level structure:

```json
{
  "data": {
    "notification_type": "...",
    ...
  }
}
```

Fluxis signs the **entire parsed JSON body** (the object containing `data`), not the inner `data` object alone and not raw request bytes. Optional fields omitted from the payload (Go `omitempty`) affect the signature—always verify against the JSON you actually received.

### Delivery headers

| Header | Description |
| ------ | ----------- |
| `X-Request-Signature` | Hex-encoded HMAC-SHA256 |
| `X-Request-Timestamp` | Unix timestamp (seconds) |
| `Content-Type` | `application/json` |

Reject requests older than **300 seconds**. See the [signature verification guide](/docs/developers/webhook-signature-verification) for the full algorithm.

## Event types

Webhooks are registered **per account** via `POST /v1/account/{accountID}/webhook`. Each webhook lists the event types it receives in `event_types`, and **receives only those**. Choose them on create, change them with `PUT /v1/account/{accountID}/webhook/{webhookID}/event-types`, or edit them in the dashboard under **Developers → Webhooks**. See [Webhooks](/docs/developers/webhooks#event-types).

| Event type | `notification_type` in payload | Delivery status |
| ---------- | ------------------------------ | --------------- |
| `payment_request` | `payment_request_status_update` | **Active** |
| `subscription` | `subscription_invoice_settled`, `subscription_updated`, `subscription_paused`, `subscription_resumed`, `subscription_cancelled`, `subscription_expired` | **Alpha** — accounts enabled for [subscriptions](/docs/developers/subscriptions) |

One event type can carry several notices, so always switch on `data.notification_type` and ignore the ones you do not handle.

::::note
Webhooks created before event types could be chosen receive every type. Edit their `event_types` to narrow what they receive.
::::

---

## `payment_request` events

Delivered to webhooks whose `event_types` include `payment_request`.

### When they fire

Fluxis sends a webhook when the payment request status changes to:

| Status | Trigger |
| ------ | ------- |
| `processing` | On-chain deposit detected; finality check queued |
| `completed` | Full payment received |
| `underpaid` | Payment received but below requested amount |
| `overpaid` | Payment received above requested amount |

Statuses such as `pending`, `created`, `expired`, `failed`, and `confirmed` do **not** trigger `payment_request` webhooks today.

### Payload fields

```json
{
  "data": {
    "notification_type": "payment_request_status_update",
    "payment_request_id": "aa5d6c80-0b0b-4a2a-bbc8-14a41e6245bf",
    "payment_request_type": "fixed",
    "external_reference_id": "order-123",
    "status": "completed",
    "point_of_sale_id": "3cc1f7ca-c017-4e7e-b00d-aca0da6e464e",
    "account_id": "c87464d1-c54a-48c3-80c9-bee4fddf593d"
  }
}
```

| Field | Description |
| ----- | ----------- |
| `notification_type` | Always `payment_request_status_update` |
| `payment_request_id` | Fluxis payment request UUID |
| `payment_request_type` | `fixed`, `dynamic`, `pre_loaded`, or `open` |
| `external_reference_id` | Your order reference (optional; omitted when unset) |
| `status` | Current payment request status |
| `point_of_sale_id` | POS that created the payment request |
| `account_id` | Owning account (optional; omitted when unset) |

### Integration guidance

- Treat `processing` as "payment detected" — wait for a terminal status before fulfilling goods
- Handle `underpaid` and `overpaid` per your POS configuration
- Use `external_reference_id` to map events back to your order system

---

## Subscription events

Sent for subscriptions in **alpha**, to accounts enabled for them. Delivered to webhooks whose `event_types` include `subscription`. See [Subscriptions](/docs/developers/subscriptions).

Every subscription notice starts with the same fields:

| Field | Description |
| ----- | ----------- |
| `notification_type` | Which notice this is, from the sections below |
| `notice_id` | Unique per notice and the same on a repeated delivery. The key to deduplicate on |
| `subscription_id` | The subscription the notice is about |
| `point_of_sale_id`, `account_id` | Where the subscription was created |
| `collection_method` | `email_invoice` or `wallet_mandate` |
| `subscription_status` | The subscription right after the change: `active`, `paused` or `cancelled` |

Timestamps are unix seconds. Amounts are decimal strings.

### `subscription_invoice_settled`

Sent once a payer's payment for an invoice is applied, normally within a minute of the payment being confirmed. It tells you both that the money arrived and what it did to the subscription.

```json
{
  "data": {
    "notification_type": "subscription_invoice_settled",
    "notice_id": "0c6f3a2e-5b8d-4f3e-9a51-2d7c8e4b1f90",
    "subscription_id": "f2353889-21be-4c84-9852-17f8de63fb42",
    "point_of_sale_id": "dd3ef322-ed47-4c25-8db4-40b19176fd74",
    "account_id": "41150e54-2c5e-4259-8f79-8a1b61f5e217",
    "collection_method": "email_invoice",
    "subscription_status": "active",
    "payment_request_id": "78ba11aa-4af7-4957-b3ea-138d19e535f8",
    "period_index": 0,
    "amount": "9.99",
    "asset": "npolygon_t0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
    "activated": true,
    "next_charge_at": 1730419200,
    "settled_at": 1728043200
  }
}
```

| Field | Description |
| ----- | ----------- |
| `payment_request_id` | The invoice that was paid. The same id the `payment_request` notices carry for this payment |
| `period_index` | Which period was paid. `0` is the first invoice |
| `amount`, `asset` | What the invoice billed, as a decimal string and a [unique asset id](/docs/key-concepts/uai). The payer may have chosen another token the point of sale accepts; look up `payment_request_id` to see what was paid |
| `activated` | `true` when this was the first invoice, which is what activates the subscription |
| `next_charge_at` | When the next invoice falls due. Omitted when no further invoice will be issued |
| `settled_at` | When Fluxis applied the payment |

A payment applied while the subscription is paused is notified the same way, with `subscription_status: "paused"`. A payment that arrives after the subscription was cancelled is not: that money is recorded but never reactivates the subscription; contact Fluxis to resolve it.

### `subscription_updated`

Sent when you change a subscription's terms, or withdraw a change that was waiting. It is sent when you make the change, not when it takes effect.

```json
{
  "data": {
    "notification_type": "subscription_updated",
    "notice_id": "5e0b7c1d-2a43-4c8e-b6f1-93d2a7e8c405",
    "subscription_id": "f2353889-21be-4c84-9852-17f8de63fb42",
    "point_of_sale_id": "dd3ef322-ed47-4c25-8db4-40b19176fd74",
    "account_id": "41150e54-2c5e-4259-8f79-8a1b61f5e217",
    "collection_method": "email_invoice",
    "subscription_status": "active",
    "previous_terms": {
      "amount": "9.99",
      "asset": "npolygon_t0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
      "interval": "month",
      "interval_count": 1,
      "anchor_day": 1
    },
    "new_terms": {
      "amount": "12.5",
      "asset": "npolygon_t0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
      "interval": "month",
      "interval_count": 1,
      "anchor_day": 1
    },
    "effective_period_index": 4,
    "effective_at": 1735689600,
    "updated_at": 1733097600
  }
}
```

| Field | Description |
| ----- | ----------- |
| `previous_terms` | What the invoice at `effective_period_index` would have billed: a change already waiting, or the terms in force |
| `new_terms` | What it will bill instead. When these are the terms already in force, a waiting change was withdrawn |
| `effective_period_index`, `effective_at` | The first invoice the change applies to, and when it falls due |
| `updated_at` | When you made the change |

### `subscription_paused`

Sent when you pause a subscription. `subscription_status` is `paused`.

```json
{
  "data": {
    "notification_type": "subscription_paused",
    "notice_id": "9a4d2e6b-1c7f-4b30-8e95-6f2a0d3c7b18",
    "subscription_id": "f2353889-21be-4c84-9852-17f8de63fb42",
    "point_of_sale_id": "dd3ef322-ed47-4c25-8db4-40b19176fd74",
    "account_id": "41150e54-2c5e-4259-8f79-8a1b61f5e217",
    "collection_method": "email_invoice",
    "subscription_status": "paused",
    "paused_at": 1733097600
  }
}
```

### `subscription_resumed`

Sent when you resume a paused subscription. `next_charge_at` is when the next new invoice falls due; periods that fell inside the pause are not billed.

```json
{
  "data": {
    "notification_type": "subscription_resumed",
    "notice_id": "3f8c1b5a-7e2d-4a69-b0c4-8d5e2f1a6c37",
    "subscription_id": "f2353889-21be-4c84-9852-17f8de63fb42",
    "point_of_sale_id": "dd3ef322-ed47-4c25-8db4-40b19176fd74",
    "account_id": "41150e54-2c5e-4259-8f79-8a1b61f5e217",
    "collection_method": "email_invoice",
    "subscription_status": "active",
    "resumed_at": 1738368000,
    "next_charge_at": 1740787200
  }
}
```

### `subscription_cancelled`

Sent when billing stops, whoever stopped it.

```json
{
  "data": {
    "notification_type": "subscription_cancelled",
    "notice_id": "b71e4d09-6c2a-4f85-9d13-0a8f5e2c4b66",
    "subscription_id": "f2353889-21be-4c84-9852-17f8de63fb42",
    "point_of_sale_id": "dd3ef322-ed47-4c25-8db4-40b19176fd74",
    "account_id": "41150e54-2c5e-4259-8f79-8a1b61f5e217",
    "collection_method": "email_invoice",
    "subscription_status": "cancelled",
    "period_index": 3,
    "cancellation_reason": "invoice_unpaid",
    "cancelled_by": "system",
    "cancelled_at": 1735689600
  }
}
```

| Field | Description |
| ----- | ----------- |
| `period_index` | The first period that will not be billed. `0` when cancelled before the first invoice was paid |
| `cancellation_reason` | The same value the subscription returns, such as `merchant_cancelled` or `invoice_unpaid` |
| `cancelled_by` | Who stopped billing: `merchant` when you cancelled, `system` when a period ran out unpaid |
| `cancelled_at` | When the subscription was cancelled |

### `subscription_expired`

Sent when the first invoice was never paid before `expires_at`, so nothing was agreed. Separate from a cancellation so you can tell a customer who never started from one who left. The subscription reads `status: cancelled` with `cancellation_reason: expired`.

```json
{
  "data": {
    "notification_type": "subscription_expired",
    "notice_id": "e25a9f71-0d4b-4c3e-a8b2-5c6d7e8f9a01",
    "subscription_id": "f2353889-21be-4c84-9852-17f8de63fb42",
    "point_of_sale_id": "dd3ef322-ed47-4c25-8db4-40b19176fd74",
    "account_id": "41150e54-2c5e-4259-8f79-8a1b61f5e217",
    "collection_method": "email_invoice",
    "subscription_status": "cancelled",
    "expired_at": 1727913600
  }
}
```

### Delivery

- **Within about a minute** of the change.
- **At least once.** The same notice can arrive twice. Deduplicate on `notice_id`.
- **Not always in order.** A pause and a resume made a minute apart can arrive resume first. Order notices by their own timestamps (`paused_at`, `resumed_at`, `updated_at`), or read the subscription with `GET /v1/subscriptions/{id}`.
- **One attempt per webhook, no retry.** If your endpoint was down, read the subscription.
- **No payer email.** Notices never carry the payer's email or other personal data; the subscription id leads to everything else.
- **Payment notices too.** Each invoice is a payment request, so a webhook that also receives `payment_request` gets `payment_request_status_update` for it too.

---

## Testing webhooks

Send a signed test payload to your endpoint:

```
POST /v1/account/{accountID}/webhook/{webhookID}/test
```

Without a body, the test sends a sample of the webhook's first event type. To pick another of its types, send:

```json
{ "event_type": "subscription" }
```

An event type the webhook does not receive is rejected with HTTP `400`. The samples are:

| Event type | Sample | How to tell it is a test |
| ---------- | ------ | ------------------------ |
| `payment_request` | `payment_request_status_update` | `status` is `pending`, which no real notice carries |
| `subscription` | `subscription_invoice_settled` | `data.test` is `true` |

Ids in a sample are random and match nothing in your account. Verify the sample with the same algorithm as production events—see [Webhook Signature Verification](/docs/developers/webhook-signature-verification). The test fails with an error when your endpoint does not answer HTTP `200`.

## Status → webhook matrix

| Payment request status | Webhook sent? |
| ---------------------- | ------------- |
| `pending` | No |
| `created` | No |
| `processing` | Yes |
| `completed` | Yes |
| `underpaid` | Yes |
| `overpaid` | Yes |
| `confirmed` | No |
| `expired` | No |
| `failed` | No |

## Related documentation

- [Webhooks](/docs/developers/webhooks) — registration, secrets, best practices
- [Webhook Signature Verification](/docs/developers/webhook-signature-verification) — HMAC-SHA256 verification
- [Payment Requests](/docs/key-concepts/payment-request) — full status lifecycle
