# Transaction lifecycle and webhooks

> Operation statuses for deposits, withdrawals, conversions, internal transfers and ramps: which are final, which wait on you, the webhook events, signature verification, retries, and how to reconcile after a missed webhook.

Source: https://business-api-docs.youhodler.com/guides/transaction-lifecycle

> **Status: In the API.** Every status, event type and endpoint on this page is in the public API contract. Sandbox-only steps are marked.

You move money through the API and need two answers: **when is a payment
final**, so you can credit a customer or release goods, and **how do you keep
your own records in step** when a notification is late or lost. This page is
for the developer who builds that sync and for the operator who reads the
statuses in the console.

The short version:

- Final success is `settled`. Final without success is `failed` or
`cancelled`. `partially_settled` is final too and needs a person to look.
- There is no `pending`, `confirming`, `completed` or `refunded` status on an
operation, and there is no refund operation. See
[the vocabulary mapping](#if-you-expect-pending-confirming-completed-failed-refunded).
- Webhooks tell you quickly; reads tell you reliably. Build both: handle
events as they arrive and reconcile from the API on a schedule.

For the model behind the statuses read [Operations](/concepts/operations); for
the split between the event history and webhook delivery read
[Events and webhooks](/concepts/events-and-webhooks).

## One status model for every money movement

Deposits, withdrawals, conversions, internal transfers and on-ramp or off-ramp
sessions all report the same `status` field with the same twelve values. A
family uses only part of the set (see
[Differences per family](#differences-per-family)).

```mermaid
stateDiagram-v2
  [*] --> requested
  requested --> pending_approval: approval required
  requested --> pending_compliance: compliance review
  requested --> pending_admission: deposit, account not ready
  requested --> admissible: accepted
  requested --> executing: withdrawal or deposit accepted
  requested --> failed: denied
  pending_approval --> pending_compliance: approved, then review
  pending_approval --> admissible: approved
  pending_approval --> executing: withdrawal approved
  pending_approval --> failed: rejected or expired
  pending_approval --> cancelled: cancelled
  pending_compliance --> admissible: cleared
  pending_compliance --> executing: withdrawal or deposit cleared
  pending_compliance --> failed: denied
  pending_compliance --> cancelled: cancelled
  pending_admission --> pending_compliance: account ready, then review
  pending_admission --> executing: account ready
  pending_admission --> failed: refused
  admissible --> settled
  admissible --> partially_settled
  admissible --> failed
  admissible --> cancelled: off-ramp before funds arrive
  executing --> settled
  executing --> failed
  settled --> [*]
  partially_settled --> [*]
  failed --> [*]
  cancelled --> [*]
```

The same flow as steps:

1. An operation starts as `requested`. You create it (withdrawal, conversion,
internal transfer, ramp session), or the platform creates it when a rail
detects incoming funds (deposit).
2. The platform checks it. If a policy rule needs an approver it becomes
`pending_approval`. If compliance has to review it, it becomes
`pending_compliance`. An operation can pass through both, approval first.
A deposit whose account cannot be credited yet becomes `pending_admission`.
3. Once the checks pass, the operation is in flight: a withdrawal or a deposit
is `executing`; a conversion, internal transfer or ramp session is
`admissible`.
4. It ends in exactly one final status: `settled`, `partially_settled`,
`failed` or `cancelled`. A final status never changes.
5. A denied, rejected or expired check ends the operation as `failed`. A
cancellation ends it as `cancelled`. When a check denies the operation
while you create it, the create call itself returns an error with code
`not_admissible` (see [Errors](/concepts/errors)).

### What each status means

| Status | Group | What it means for you | Final |
| --- | --- | --- | --- |
| `requested` | In flight | Recorded. The platform is running its checks. You mostly see it in the `…requested.v1` event; the create response already carries the next status. | No |
| `pending_approval` | Waiting on you | A policy rule requires an approver. `approval_ref` carries the approval id and its expiry. | No |
| `pending_compliance` | Waiting on compliance | A compliance review is open; `compliance_assessment_ref` is set. There is nothing to call. | No |
| `pending_admission` | Waiting on you | Deposits only. The funds arrived, but the receiving account may not be credited yet. `admission_hold_reason` says why. | No |
| `admissible` | In flight | Conversions, internal transfers and ramp sessions: accepted and handed to execution. For an off-ramp session it also covers the wait for the customer's crypto. | No |
| `executing` | In flight | Withdrawal: sent for payout; the amount is held on the account. Deposit: cleared and being credited. | No |
| `executed` | In flight | In the enum, but the platform does not set it today. If you ever read it, treat it as in flight. | No |
| `settled` | Final, success | The money moved. `settled_at` is set. Safe to credit your customer or release goods. | Yes |
| `partially_settled` | Final, needs attention | Some legs of the operation settled and others did not; `failure_reason` is set. Never reported for a withdrawal or a deposit. | Yes |
| `failed` | Final, no success | The operation did not complete. `failure_reason` says why. A failed withdrawal releases the amount it held. | Yes |
| `cancelled` | Final, no success | Stopped before anything executed, through the family's cancel route. | Yes |
| `ledger_visible` | In flight | In the enum, but the platform does not set it today. It is meant for a conversion whose ledger entry exists while its route has not finished. If you ever read it, treat it as not final and keep reading the operation. | No |

> **Write your handler against the groups:** Treat `settled`, `partially_settled`,{' '} `failed` and `cancelled` as final, and every other value as not final. Then a status you have not seen before cannot make you credit a customer early.

A conversion whose route needs manual recovery can also stay `admissible`
longer than usual. Keep reading it until it reaches a final status.

### Differences per family

| Family | Who creates it | Path it takes | Statuses it never reports | Cancel route |
| --- | --- | --- | --- | --- |
| Deposit | The platform, when a rail detects incoming funds | `requested`, optionally `pending_admission` and `pending_compliance`, then `executing`, then `settled` or `failed` | `pending_approval`, `admissible`, `cancelled`, `partially_settled` | None |
| Withdrawal | You | `requested`, optionally `pending_approval` and `pending_compliance`, then `executing`, then `settled` or `failed` | `pending_admission`, `admissible`, `partially_settled` | [Cancel withdrawal](/api/reference/withdrawals/withdrawals-cancel) |
| Conversion | You | `requested`, optionally `pending_approval` and `pending_compliance`, then `admissible`, then `settled`, `partially_settled` or `failed` | `pending_admission`, `executing` | [Cancel conversion](/api/reference/conversions/conversions-cancel) |
| Internal transfer | You | Same as conversion | `pending_admission`, `executing` | [Cancel internal transfer](/api/reference/internal-transfers/internal-transfers-cancel) |
| On-ramp session | You | Same as conversion | `pending_admission`, `executing` | [Cancel on-ramp session](/api/reference/on-ramp-sessions/on-ramp-sessions-cancel) |
| Off-ramp session | You | Same as conversion; `admissible` includes the wait for the customer's crypto | `pending_admission`, `executing` | [Cancel off-ramp session](/api/reference/off-ramp-sessions/off-ramp-sessions-cancel) |

External settlement conversions use the same status field and have no cancel
route. Only one event type exists for them (see
[Event types](#event-types)), so read the operation to learn its outcome.

Cancelling works only while nothing has executed: in `pending_approval` or
`pending_compliance`, and for an off-ramp session also while it still waits
for the customer's crypto. After that the cancel route answers
`409 state_conflict` with `data.reason` set to `operation_not_cancellable`.

### When an operation waits on you

- **`pending_approval`.** Someone with the `approvals.decide` capability must
decide the case named in `approval_ref`: use
[Approve](/api/reference/approvals/approvals-approve) or
[Reject](/api/reference/approvals/approvals-reject), or the Approvals screen
in the console. Approval moves the operation on. A rejection ends it as
`failed` with `failure_reason` `APPROVAL_REJECTED`; an approval that passes
its `expires_at` ends it as `failed` with `APPROVAL_EXPIRED`. See
[Policies and approvals](/concepts/policies-and-approvals).
- **`pending_compliance`.** Wait. When the review ends, the operation
continues or becomes `failed` with a compliance `failure_reason` such as
`COMPLIANCE_DENIED`.
- **`pending_admission`** (deposits). Fix what `admission_hold_reason` names,
for example `CLIENT_NOT_VERIFIED`, `ENTERPRISE_NOT_VERIFIED` or
`ACCOUNT_SUSPENDED`. The platform re-checks the deposit when the account's
standing changes; you do not resubmit anything.

Step-up authentication is not a status. For withdrawals, conversions and
external settlement conversions, a human caller sends an `X-Action-Token`
with the create request, before the operation exists; a service account does
not need one.

## Related lifecycles

You meet four more state fields while following a payment.

**Funding endpoint** (where deposits arrive; see
[Funding endpoints](/concepts/funding-endpoints)):

| `status` | Meaning |
| --- | --- |
| `provisioning` | Requested; receive details are not ready yet. Keep reading the endpoint. |
| `active` | Ready to receive. |
| `failed` | Could not be issued; `failure` on the endpoint says why. |
| `disabled` | Temporarily not receiving. |
| `retired` | Closed for good. |

**Withdrawal destination** (where payouts go; see
[Withdrawal destinations](/concepts/withdrawal-destinations)):

| `status` | Meaning |
| --- | --- |
| `active` | Can be used for new withdrawals. |
| `disabled` | Not selectable for new withdrawals; withdrawals in flight continue. |
| `retired` | Closed for good. |

**Approval** (the case behind `pending_approval`):

| `status` | Meaning | Effect on the operation |
| --- | --- | --- |
| `pending` | Waiting for a decision. | Stays `pending_approval`. |
| `approved` | Approved. | Continues. |
| `rejected` | Declined. | `failed`, `APPROVAL_REJECTED`. |
| `expired` | Nobody decided before `expires_at`. | `failed`, `APPROVAL_EXPIRED`. |
| `cancelled` | The case was withdrawn. | If you cancelled the operation, it is already `cancelled`. If only the case was cancelled, the operation ends as `failed`, the same as a rejection. |

**Webhook delivery** (one event sent to one subscription):

| `status` | Meaning | Final |
| --- | --- | --- |
| `pending` | Created; the first attempt has not run yet. | No |
| `retrying` | An attempt failed, or a redelivery is queued. `next_retry_at` says when the next attempt runs. | No |
| `delivered` | Your endpoint answered with a 2xx status. | Yes |
| `dlq` | Every attempt failed. The delivery stays in the dead-letter state until you redeliver it. | Yes |
| `failed` | Not attempted: the subscription was paused or deleted before the delivery could be sent. | Yes |

A webhook subscription itself is `active`, `paused` or `deleted`.

## Webhooks

### Subscribe

Create a subscription with the `webhooks.create` capability. `url` must be an
HTTPS address on a public host; anything else is refused with
`callback_url_not_allowed`. `secret` is the shared key the platform signs
deliveries with: generate a long random string and store it, because no read
returns it and an update cannot change it. `scope_ref` is an enterprise
(`enterprises/<id>`) or a connected account (API: `client`, `clients/<id>`);
an enterprise subscription also receives the events of its connected accounts
and their accounts.

**Subscribe to every operation event — POST**
```http
POST https://b2b2x-sandbox.youhodler.com/api/webhook-subscriptions
Authorization: Bearer <access_token>
Idempotency-Key: webhook-sub-001
Content-Type: application/json
```

```json
{
  "scope_ref": "enterprises/b8e2f1a0-4c3d-4e5f-9a1b-2c3d4e5f6a7b",
  "url": "https://example.com/webhooks/youhodler",
  "event_types": ["operations.*.v1", "rails.deposit.detected.v1"],
  "secret": "replace-with-a-long-random-string"
}
```

Keep the returned `id` and `etag`: updating, pausing and deleting the
subscription need the current `If-Match` value. See
[Create webhook subscription](/api/reference/webhook-subscriptions/webhook-subscriptions-create).

`event_types` takes exact types, a resource group such as
`operations.withdrawal.*.v1`, a domain group such as `operations.*.v1`, or
`["*"]` alone for everything.

### Event types

Event types are named `<domain>.<resource>.<verb>.v<major>`. The current list
comes from [List webhook event types](/api/reference/events/events-types)
(`GET /events/types`); read it instead of hard-coding one. For operations the
verb is the status the operation just entered, with one exception:
`approved` means "a wait ended and the operation moves on".

| Family | Event types the platform publishes | Final ones |
| --- | --- | --- |
| Deposit | `operations.deposit.requested.v1`, `operations.deposit.pending_admission.v1`, `operations.deposit.pending_compliance.v1`, `operations.deposit.approved.v1` (status `executing`), `operations.deposit.settled.v1`, `operations.deposit.failed.v1` | `settled`, `failed` |
| Withdrawal | `operations.withdrawal.requested.v1`, `operations.withdrawal.pending_approval.v1`, `operations.withdrawal.pending_compliance.v1`, `operations.withdrawal.executing.v1`, `operations.withdrawal.settled.v1`, `operations.withdrawal.failed.v1`, `operations.withdrawal.cancelled.v1` | `settled`, `failed`, `cancelled` |
| Conversion | `operations.conversion.requested.v1`, `operations.conversion.pending_approval.v1`, `operations.conversion.pending_compliance.v1`, `operations.conversion.admissible.v1`, `operations.conversion.approved.v1` (status `admissible`), `operations.conversion.settled.v1`, `operations.conversion.failed.v1`, `operations.conversion.cancelled.v1` | `settled`, `failed`, `cancelled` |
| Internal transfer | The same eight verbs under `operations.internal_transfer.` | `settled`, `failed`, `cancelled` |
| On-ramp session | The same eight verbs under `operations.on_ramp.` | `settled`, `failed`, `cancelled` |
| Off-ramp session | The same eight verbs under `operations.off_ramp.` | `settled`, `failed`, `cancelled` |
| External settlement conversion | `operations.external_settlement_conversion.pending_compliance.v1` only | None: read the operation |

The catalog, and the `event_types` values a subscription accepts, also list
`operations.deposit.pending_approval.v1`, `operations.deposit.admissible.v1`,
`operations.deposit.cancelled.v1`, `operations.withdrawal.admissible.v1` and
`operations.withdrawal.approved.v1`. They are reserved: deposits and
withdrawals never enter those statuses (see
[Differences per family](#differences-per-family)), so the platform does not
publish them. Subscribing to them is harmless, but do not wait for them; an
approved withdrawal reports `operations.withdrawal.executing.v1`.

The catalog also lists rail-level facts (`rails.deposit.detected.v1`,
`rails.dispatch.acknowledged.v1`, `rails.dispatch.rejected.v1`,
`rails.settlement.confirmed.v1`) and `ledger.transaction.posted.v1`. Use
`rails.deposit.detected.v1` as the earliest sign of incoming funds; use the
operation events to decide when money is final.

> **One outcome has no event type:** There is no event type for `partially_settled`. A conversion, internal transfer or ramp session that reaches it sends no webhook and adds nothing to the event history, so an operation that stays `admissible` on your side must be read from the API. Switch on `data.status` in your handler, not on the event type name.

### What a delivery looks like

Each delivery is an HTTP `POST` with a JSON body. For operation events `data`
carries the operation id, family, status, account, amounts, and the wait or
failure fields when they apply.

```json
{
  "id": "5d0c6a52-8f0e-4a55-9f5e-3f1c2f0c9a11",
  "event_type": "operations.withdrawal.settled.v1",
  "scope_ref": "client-accounts/aaaaaaa1-aaaa-4aaa-8aaa-aaaaaaaaaaa1",
  "data": {
    "operation_id": "b8e2f1a0-4c3d-4e5f-9a1b-2c3d4e5f6a7b",
    "family": "withdrawal",
    "status": "settled",
    "account_ref": "client-accounts/aaaaaaa1-aaaa-4aaa-8aaa-aaaaaaaaaaa1",
    "scope_ref": "client-accounts/aaaaaaa1-aaaa-4aaa-8aaa-aaaaaaaaaaa1",
    "principal_amount": {"value": "250.00", "currency": "USDC"},
    "fee_summary": {
      "components": [
        {"kind": "network_fee", "amount": {"value": "1.00", "currency": "USDC"}}
      ],
      "total": {"value": "1.00", "currency": "USDC"}
    },
    "fill_rate": null,
    "failure_reason": null,
    "occurred_at": "2026-05-01T10:00:00.000Z"
  },
  "schema_version": 1,
  "aggregate": {
    "type": "operations.withdrawal.settled.v1",
    "id": "b8e2f1a0-4c3d-4e5f-9a1b-2c3d4e5f6a7b"
  },
  "trace_id": "0f8c1f0e-6f1d-4a43-9d5b-0c7e5a1b2c3d",
  "occurred_at": "2026-05-01T10:00:00.000Z",
  "recipient": {
    "subscription_id": "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
    "enterprise_ref": "enterprises/b8e2f1a0-4c3d-4e5f-9a1b-2c3d4e5f6a7b"
  }
}
```

- `id` is the event id. It is the same value in `x-yh-webhook-event-id`, in
`event_id` on the delivery, and in `GET /events/{event_id}`.
- `data.operation_id` is the id you read with the family's `GET` route. For
operation events `aggregate.id` holds the same id; rely on
`data.operation_id` and `data.family`.
- `recipient` names the subscription and enterprise the body was built for.

| Header | Value |
| --- | --- |
| `x-yh-webhook-event-id` | The event id. Use it (or `id` in the body) to drop duplicates. |
| `x-yh-webhook-delivery-id` | The delivery id, for the deliveries API. |
| `x-yh-webhook-timestamp` | Unix time in seconds of this attempt. |
| `x-yh-webhook-signature` | `t=<unix seconds>,v1=<hex signature>`. |
| `x-yh-webhook-signature-v2` | `t=…,kid=…,sub=…,ent=…,sig=…`, an Ed25519 signature made with a platform key. Present when the platform key is configured. |
| `user-agent` | `yh-webhook-service/1.0` |

### Verify the signature

`v1` in `x-yh-webhook-signature` is the HMAC-SHA256, hex-encoded, of the
string `<t>.<raw body>`, keyed with the `secret` you sent when you created the
subscription. `t` is the same number as `x-yh-webhook-timestamp`, and it is
new on every attempt.

1. Read the raw request body as bytes, before any JSON parsing.
2. Split the header on commas and take `t` and `v1`.
3. Refuse a `t` that is too far from your clock (five minutes is a common
limit) so a captured request cannot be replayed later.
4. Compute HMAC-SHA256 of `<t>.<raw body>` with your secret and compare it to
`v1` in constant time.

```js

const SECRET = process.env.WEBHOOK_SECRET; // the `secret` you sent on create
const TOLERANCE_SECONDS = 300;
const seen = new Set(); // use a table with a unique key in production

function isAuthentic(rawBody, header) {
  const parts = new Map(
    String(header ?? '')
      .split(',')
      .map(part => part.trim().split('='))
      .filter(pair => pair.length === 2)
  );
  const t = parts.get('t') ?? '';
  const v1 = parts.get('v1') ?? '';
  if (!/^\d+$/.test(t) || !/^[0-9a-f]{64}$/i.test(v1)) return false;
  if (Math.abs(Date.now() / 1000 - Number(t)) > TOLERANCE_SECONDS) return false;
  const expected = crypto
    .createHmac('sha256', SECRET)
    .update(`${t}.${rawBody}`, 'utf8')
    .digest();
  return crypto.timingSafeEqual(expected, Buffer.from(v1, 'hex'));
}

http
  .createServer((req, res) => {
    const chunks = [];
    req.on('data', chunk => chunks.push(chunk));
    req.on('end', () => {
      const rawBody = Buffer.concat(chunks).toString('utf8');
      if (!isAuthentic(rawBody, req.headers['x-yh-webhook-signature'])) {
        res.writeHead(401).end();
        return;
      }
      const event = JSON.parse(rawBody);
      if (!seen.has(event.id)) {
        seen.add(event.id);
        // Queue the event and return. Do the slow work after you answer.
        console.log(event.event_type, event.data.operation_id, event.data.status);
      }
      res.writeHead(204).end();
    });
  })
  .listen(8080);
```

A subscription you create has `signing` set to `hmac`, so the `v1` check
above is enough. The `v2` header is an Ed25519 signature over
`<t>.<subscription id>.<enterprise ref>.<raw body>` with a platform key named
by `kid`; it lets a receiver verify a delivery without holding a secret. The
public keys are a JWKS document at `/.well-known/webhooks-jwks.json` under the
API base URL, served without a token; pick the key whose `kid` matches the
header.

### Acknowledge quickly

- Answer with any 2xx status to acknowledge. Every other status, a timeout
and a connection error count as a failed attempt.
- Answer within 10 seconds, the default delivery timeout. Store the event
and process it afterwards.
- Redirects are not followed: a 3xx answer is a failed attempt.
- The first 4,096 characters of your response body are stored and shown in
the delivery's `attempts`. Do not put secrets in it.

### Retries and the dead-letter state

A failed attempt is retried with a delay that doubles each time: 1 second,
then 2, 4, 8 and so on, capped at 5 minutes. Due deliveries are picked up
every 5 seconds, so real gaps are a few seconds longer. When the last attempt
fails the delivery becomes `dlq` and is not retried again on its own.

The number of attempts is a deployment setting. Sandbox makes five attempts
in total, so a delivery dead-letters within about a minute of failures.
Production makes ten: the waits between them add up to about 8.5 minutes,
plus the time the attempts themselves take. An outage of your endpoint that
lasts longer than that leaves deliveries in `dlq`, and you recover them
yourself (next section). Read `attempt_count` and `next_retry_at` on the
delivery instead of hard-coding the schedule.

Pausing a subscription
([Disable](/api/reference/webhook-subscriptions/webhook-subscriptions-disable))
does not buffer anything: events published during the pause are not delivered,
and deliveries still waiting become `failed` without an attempt. After you
enable it again, replay the events you missed.

### Inspect, redeliver, replay, test

| You want to | Call | Notes |
| --- | --- | --- |
| See what was sent and how your endpoint answered | [List deliveries](/api/reference/webhook-subscriptions/webhook-subscriptions-deliveries), `GET /webhook-subscriptions/{subscription_id}/deliveries` | Filter with `status` (for example `dlq`) or `event_id`. Each delivery lists its `attempts` with `http_status_code` and `response_body`. Needs `webhooks.read`. |
| Send one delivery that has not succeeded again | [Redeliver](/api/reference/webhook-subscriptions/webhook-subscriptions-redeliver), `POST /webhook-subscriptions/{subscription_id}/deliveries/{delivery_id}/redeliver` | Queues one more attempt of the same delivery. A `delivered` one returns `409` with `webhook_delivery_already_delivered`. Needs `webhooks.manage`. |
| Send a stored event again, even after a successful delivery | [Replay event](/api/reference/events/events-replay), `POST /events/{event_id}/replay` | Creates a new delivery with the same event id. Send `subscription_ids` to target specific subscriptions, or omit it for every matching one. Needs `events.read` and `webhooks.manage`. |
| Check that your endpoint is reachable and your signature check works | [Send test delivery](/api/reference/webhook-subscriptions/webhook-subscriptions-test), `POST /webhook-subscriptions/{subscription_id}/test` | Sends a synthetic event of type `webhook.test_delivery.v1` with `data.test` set to `true`, signed like a real one. The response includes the first attempt. It changes no money and is not stored in the event history. |

**Redeliver a dead-lettered delivery — POST**
```http
POST https://b2b2x-sandbox.youhodler.com/api/webhook-subscriptions/<subscription_id>/deliveries/<delivery_id>/redeliver
Authorization: Bearer <access_token>
Idempotency-Key: redeliver-001
```

### Ordering and duplicates

- **Delivery is at least once.** A retry after a lost acknowledgement, a
redelivery and a replay all send an event you may already have. Record the
event `id` with a unique key and skip an id you have processed.
- **Order is best effort.** Events are sent in the order they happened where
possible, but a retried event can arrive after a later one. Never let an
older event overwrite a newer state: once you have recorded a final status
for an operation, ignore later non-final events for it, and when in doubt
read the operation.
- **A handler must be safe to run twice.** Credit a customer keyed by
`data.operation_id`, not by the number of events you received.

## Reconcile from the API

Webhooks are a signal, not the record. These reads are the record.

| Source | Use it for | Call |
| --- | --- | --- |
| The operation by id | The current truth about one payment | `GET /withdrawals/{withdrawal_id}`, `GET /deposits/{deposit_id}`, `GET /conversions/{conversion_id}`, `GET /internal-transfers/{internal_transfer_id}`, `GET /on-ramp-sessions/{session_id}`, `GET /off-ramp-sessions/{session_id}`, `GET /external-settlement-conversions/{external_settlement_conversion_id}` |
| The operation lists | Finding operations you do not know yet, such as new deposits | `GET /deposits`, `GET /withdrawals` and the other list routes. The only filters are `account_ref`, `page_size` and `page_token`; there is no status or date filter, so filter after reading. |
| The event history | Everything that happened, pull-based | [List events](/api/reference/events/events-list), `GET /events`. Filters: `scope_ref`, `from_date`, `to_date`, `event_type`, `event_type_pattern` (with `*` as a wildcard), `aggregate_id`, `aggregate_type`, `actor_id`, `trace_id`. Newest first. Needs `events.read`. |
| Balances | Checking that your ledger and the account agree | [Client-account balances](/api/reference/balances/client-accounts-balances) and [master-account balances](/api/reference/balances/master-accounts-balances): `available`, `held`, `total` per asset. |
| Activity export | Period-end reconciliation as a file | [Create operations activity export](/api/reference/operations-activity-exports/operations-activity-exports-create) |

An activity export is asynchronous. Create it, read it until `status` is
`ready` (the others are `queued`, `running`, `failed`, `expired`), then fetch
the file from `download_path`.

**Export one month of operations — POST**
```http
POST https://b2b2x-sandbox.youhodler.com/api/operations-activity-exports
Authorization: Bearer <access_token>
Idempotency-Key: ops-export-2026-04
Content-Type: application/json
```

```json
{
  "format": "csv",
  "requested_scope": {
    "kind": "enterprise",
    "ref": "enterprises/b8e2f1a0-4c3d-4e5f-9a1b-2c3d4e5f6a7b"
  },
  "filter_criteria": {
    "date_from_utc": "2026-04-01T00:00:00Z",
    "date_to_utc": "2026-04-30T23:59:59Z",
    "operation_families": ["deposit", "withdrawal"]
  }
}
```

`format` is `csv` or `json` (newline-delimited). `filter_criteria.statuses`
takes its own set of reporting labels, not the operation statuses on this
page, so this request leaves it out and you filter the rows afterwards.

### When a webhook was missed

Run this on a schedule (every few minutes is typical) and after any outage of
your endpoint.

1. **Find what you missed.** List the event history since your last
checkpoint and compare the event ids with the ones you processed.

   ```bash
   # $API is the sandbox base URL, $TOKEN an access token with events.read
   curl "$API/events?event_type_pattern=operations.*&from_date=2026-05-01T10:00:00Z&page_size=100" \
     -H "Authorization: Bearer $TOKEN"
```

Follow `next_page_token` until it is `null`. Each item has the same `id`,
`event_type` and `data` a delivery would have carried.

2. **Process the missing events** with the same handler your webhook uses.
Because the handler is keyed by event id, running it twice is harmless.
3. **Re-read every operation that is not final on your side.** Use the
family's `GET` route by id. This catches `partially_settled`, which has no
event type, and external settlement conversions.
4. **Look for deposits you have never seen.** Page through `GET /deposits`
for each account you credit and match them by `id`.
5. **Clear the backlog on the webhook side.** List deliveries with
`status=dlq` and redeliver them, or replay the events, so your delivery
log is clean. This is optional once steps 1 to 4 have run.
6. **Compare balances** for the affected accounts with your own ledger. A
difference means an operation you have not recorded: go back to step 3.
7. **Move the checkpoint** to the newest `occurred_at` you processed. An
event can reach the history a little after the time it carries, so start
the next run a few minutes before the checkpoint; the event ids you have
already processed are skipped.

To follow a single payment, list its events with
`GET /events?aggregate_id=<operation_id>`.

## If you expect pending, confirming, completed, failed, refunded

Many payment APIs use these five words. Here they map to the following.

| Generic word | Closest real status | Notes |
| --- | --- | --- |
| pending | `requested`, `pending_approval`, `pending_compliance`, `pending_admission` | Four values, split by who has to act. There is no operation status named `pending`. |
| confirming, processing | `executing` (withdrawals, deposits) or `admissible` (conversions, internal transfers, ramp sessions) | There is no `confirming` status and no confirmation counter in the status. |
| completed, succeeded, paid | `settled` | `settled_at` is set. There is no operation status named `completed`. |
| failed | `failed` | Read `failure_reason`. Also treat `cancelled` (stopped before execution) and `partially_settled` (some legs settled) as final without full success. |
| refunded | None | There is no refund operation, no `refunded` status and no refund event. A failed withdrawal releases the amount it held back to the account. To send money back to a payer, create a new [withdrawal](/api/reference/withdrawals/withdrawals-create) to a destination you register for them. |

`pending` and `completed` do exist on other resources (approvals, webhook
deliveries, verification status), which is why they are easy to assume here.

## Test it on sandbox

Sandbox-only The simulation routes below exist on sandbox only
and return 404 in production. They need the `sandbox_simulator.run`
capability. Which currencies and rails support them is listed in
[Sandbox testing](/guides/sandbox-testing).

1. **Subscribe and send a test delivery.** Create the subscription as above,
then call `POST /webhook-subscriptions/{subscription_id}/test`. This step
is not sandbox-only. Confirm your signature check accepts it.
2. **Drive a deposit to `settled`.** Sandbox-only Simulate an
incoming transfer on an `active` funding endpoint.

   ```bash
   curl -X POST "$API/sandbox/funding-endpoints/$FUNDING_ENDPOINT_ID/incoming-transfers" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: lifecycle-deposit-001" \
     -d '{"rail_class":"fiat","account_ref":"client-accounts/aaaaaaa1-aaaa-4aaa-8aaa-aaaaaaaaaaa1","amount":{"value":"100.00","currency":"USD"}}'
```

Use the endpoint's own account and currency.

Expect `rails.deposit.detected.v1`, then the `operations.deposit.` events
up to `operations.deposit.settled.v1`, and the deposit in `GET /deposits`.
If the deposit stops in `pending_admission`, finish the account's
verification first.
3. **Drive a withdrawal to `settled` or `failed`.** Create a fiat withdrawal
through the ordinary [Create withdrawal](/api/reference/withdrawals/withdrawals-create)
route and wait until it is `executing`. Sandbox-only Then
supply the rail's answer. A `409` with `simulation_target_not_ready` means
the provider has not accepted the payment yet; retry with the same
`Idempotency-Key` after a few seconds.

   ```bash
   curl -X POST "$API/sandbox/withdrawals/$WITHDRAWAL_ID/settlement" \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: lifecycle-withdrawal-001" \
     -d '{"outcome":"settled"}'
```

Expect `operations.withdrawal.settled.v1`. Send
`{"outcome": "failed", "reason": "Sandbox test"}` on another withdrawal to
see `operations.withdrawal.failed.v1`. Crypto withdrawals and withdrawals
that are already final cannot be simulated.
4. **See the waiting statuses.** There is no simulation for an approval:
a policy rule that requires one puts the operation in `pending_approval`,
and you decide it through the ordinary approval routes. Cancel a
withdrawal in that state to see `cancelled`.
5. **Rehearse a missed webhook.** Pause the subscription, repeat step 2,
enable the subscription again, then run
[When a webhook was missed](#when-a-webhook-was-missed).

Each simulation answers `202` with `simulation_id` and `accepted_at`. That
means it was accepted, not that the operation is final: watch the events and
the ordinary reads.

## Related

- [Operations](/concepts/operations): the shared operation model.
- [Events and webhooks](/concepts/events-and-webhooks) and the
[integration guide](/guides/events-and-webhooks): the two event surfaces.
- [Policies and approvals](/concepts/policies-and-approvals): why an
operation waits for an approver.
- [Idempotency and concurrency](/concepts/idempotency-and-concurrency):
`Idempotency-Key` and `If-Match`.
- [Errors](/concepts/errors): the error envelope behind `409 state_conflict`.
- [Sandbox testing](/guides/sandbox-testing): every simulation route.
- Reference: [Webhook subscriptions](/api/reference/webhook-subscriptions),
[Events](/api/reference/events), [Deposits](/api/reference/deposits),
[Withdrawals](/api/reference/withdrawals),
[Operations activity exports](/api/reference/operations-activity-exports).
