> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tribridge.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Tribridge is a crypto payment gateway for Solana and Sui (TON is coming soon). API base URL is https://api.tribridge.xyz. The API Reference documents ONLY the public endpoint surface: checkout sessions (create/get/generate-wallet/customer/simulate/verify/cancel), the two public payment-link endpoints, health probes, and the changelog. Server-side calls that create payments authenticate with the x-api-key header using a tri_test_... key (fully simulated test mode, no real funds) or tri_live_... key (real mainnet payments) - never expose keys client-side; all other documented endpoints are public with no auth. API keys are scoped and capped: payments:create, payments:read, payment_links:create, payment_links:read, webhooks:read, webhooks:write, webhooks:replay. The Tribridge MCP is available at https://mcp.tribridge.xyz/mcp; MCP access is opt-in per key and the MCP exposes no refunds, payouts or sweeps. Dashboard, admin, OTP/auth, payouts, wallets, and webhook-management endpoints are intentionally NOT part of the public docs - they are dashboard-only and must not be presented as public API. Merchant test mode is simulated, not testnet. Refunds are automatic only (underpaid/overpaid), there is no manual refund endpoint. Always verify webhook HMAC-SHA256 signatures from the X-Tribridge-Signature header before trusting payloads, and deduplicate on event_id because events may be retried or replayed. Replays reuse the original event_id and set replay: true plus X-Tribridge-Replay: true. If you are an AI agent: fetch https://docs.tribridge.xyz/llms-full.txt for all documentation in one file, https://docs.tribridge.xyz/openapi/openapi.json for the machine-readable OpenAPI spec, or connect to the read-only MCP server at https://docs.tribridge.xyz/mcp. Any page is available as Markdown by appending .md to its URL. Use only the documented endpoints and fields; do not invent SDK packages or endpoints.

# Webhook replay

> Re-deliver past webhook events safely, with the original event id and an explicit replay marker.

Replays let you recover from a receiver bug without asking customers to pay again: fix your handler,
then re-send the events that failed. Replays are **signed exactly like real deliveries** and clearly
marked, so a correct idempotent handler treats them as retries of the same business event.

## Replay from the dashboard

**1. Open delivery history**

Dashboard → **Logs** → **Webhook Deliveries**.

**2. Find the delivery**

Filter by test/live mode. Each row shows the event, delivery kind, result, attempts, response
status and time.

**3. Replay**

Click **Replay** on the row, or open the delivery and use **Replay this delivery**. The result
(HTTP status, duration, response body) appears immediately and a new delivery entry is recorded.

You can also replay **all latest events for a payment** from the payment's detail view when the
backend route `POST /webhooks/payments/{id}/replay` is used.

## Replay via API

Replays are part of the merchant API and require the `webhooks:replay` scope.

```bash theme={null}
# One recorded delivery
curl -X POST https://api.tribridge.xyz/v1/webhook-deliveries/<delivery_id>/replay \
  -H "x-api-key: tri_test_..." \
  -H "Idempotency-Key: replay-<delivery_id>-attempt-1"

# Latest delivery of each event type for a payment
curl -X POST https://api.tribridge.xyz/v1/payments/<payment_id>/replay-webhooks \
  -H "x-api-key: tri_test_..." \
  -H "Idempotency-Key: replay-<payment_id>-attempt-1"
```

Responses:

```json theme={null}
{
  "delivery_id": "new-delivery-uuid",
  "replay_of": "original-delivery-uuid",
  "event_id": "original-event-uuid",
  "event_type": "payment.completed",
  "endpoint_url": "https://merchant.example/webhooks/tribridge",
  "success": true,
  "status": 200,
  "response_body": "ok",
  "duration_ms": 142
}
```

Payment replay returns `{ replayed, results, skipped }`.

## How a replay is marked

Same signature scheme, same original event id, plus:

| Signal | Value |
| - | - |
| `X-Tribridge-Replay` header | `true` |
| `X-Tribridge-Event-Id` header | original event UUID |
| `event_id` payload field | original event UUID |
| `replay` payload field | `true` |
| `replayed_from_delivery_id` | the delivery being replayed |
| `replayed_at` | when the replay was attempted |

The original `timestamp` is preserved so the signature matches the event's data. Replay metadata is
additive; fields you already rely on do not change.

## Handle replays idempotently

```ts theme={null}
// Deduplicate on event_id, not on arrival time or delivery id.
const eventId = event.event_id ?? `${event.payment_id}:${event.event}`;
if (await db.seenWebhookEvent(eventId)) {
  return res.status(200).send("already processed");
}

await db.transaction(async (tx) => {
  await tx.markWebhookEvent(eventId);
  if (event.event === "payment.completed") await tx.fulfilOrder(event.payment_id);
});
res.status(200).send("ok");
```

If you want to re-run a previously failed handler, version or clear the dedupe entry for that
`event_id` first. Otherwise the replay is a deliberate no-op — which is the safest outcome.

## Limits and failure handling

* Replays are rate limited (10/minute per merchant or key). A `429` includes `Retry-After`.
* Single attempt with a 10-second timeout; there is no automatic retry.
* Non-2xx responses and network failures are recorded with the response body/duration.
* Inactive endpoints cannot be replayed (`409 webhook_inactive`) — re-enable the endpoint first.
* Every attempt writes a new delivery row with `delivery_kind: "replay"`, the actor (user or key id)
  and the response time.
* Use `Idempotency-Key` on replay requests: repeating the same key returns the stored result instead
  of delivering twice.

> [!WARNING]
>
> Replays do not move money. They only re-send an HTTP notification. Never "fulfil" based on a replay
> if the original event was already fulfilled — deduplicate on `event_id`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.