> ## 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.

# API key scopes

> Create multiple named API keys, grant only the permissions each integration needs, and cap what a key can spend.

Every API key in Tribridge is **named, mode-specific and scoped**. Create one key per integration,
worker or AI agent instead of sharing a single all-powerful key.

> [!NOTE]
>
> Existing keys created before scopes were introduced keep working exactly as before: they are
> migrated to **all permissions** and **MCP disabled**. You can rotate them at your own pace.

## Permission model

Scopes use `resource:action`. A key must have the exact scope a request needs.

| Scope | Allows |
| - | - |
| `payments:create` | Create checkout sessions (`POST /payments`) and collect money |
| `payments:read` | Read payments for this key's mode |
| `payment_links:create` | Create reusable payment links |
| `payment_links:read` | List and read payment links |
| `webhooks:read` | List endpoints and delivery history |
| `webhooks:write` | Create endpoints and send test events |
| `webhooks:replay` | Replay a delivery or a payment's events |

API keys can **never** manage other API keys, refund money, create payouts, sweep wallets or touch
treasury operations. Those actions require a dashboard session with the relevant role.

## Presets

| Preset | Scopes | Best for |
| - | - | - |
| **Full access** | All scopes above | Trusted server integration |
| **Read only** | All `*:read` scopes | Analytics, dashboards, support tooling |
| **Agent (safe)** | `payments:create`, `payments:read`, `webhooks:read` + MCP enabled + $100/payment and $500/day caps | AI agents and MCP clients |

Prefer a custom selection when a worker only needs one capability (e.g. `webhooks:replay` on a
debugging job).

## Caps and expiry

Each key can optionally set:

* **Max per payment** — rejects a single payment above the amount.
* **Daily cap** — rejects new payments once today's (UTC) total would exceed the cap. Cancelled and
  expired payments do not count.
* **Expiry** — the key stops authenticating after the date. Maximum two years out.

Cap failures are explicit and machine-readable:

```json theme={null}
{
  "error": "This API key's daily limit is $500.00. $480.00 already used today, $20.00 remaining.",
  "code": "daily_cap_exceeded",
  "limit": 500,
  "remaining": 20
}
```

## MCP access

`allow_mcp` is **off by default**. A key with MCP disabled cannot authenticate MCP requests and
receives:

```json theme={null}
{ "error": "This API key is not permitted to use the Tribridge MCP server…", "code": "mcp_not_allowed" }
```

Enable **Allow MCP access** only on keys used by an assistant. Scopes and caps still apply to every
MCP call; MCP access is an additional opt-in, not a replacement for least privilege.

## Creating and rotating keys

**1. Open API keys**

Dashboard → **API keys** → **Create key**.

**2. Name it**

Use the integration name, e.g. `Production backend`, `Webhook debugger`, `Claude agent`.

**3. Choose test or live**

Live keys require completed business verification. Start in test mode.

**4. Pick scopes, caps and expiry**

Choose a preset or build a custom list. Set caps for anything automated.

**5. Copy the secret once**

The full key (`tri_test_...` / `tri_live_...`) is shown exactly once. Tribridge stores only a
SHA-256 hash. Store it in your environment or secret manager.

To rotate safely: create the new key, deploy it, verify traffic in **Logs → API requests**, then
revoke the old key. Revocation takes effect immediately.

## Error codes

| Code | Meaning |
| - | - |
| `insufficient_scope` | Key lacks the route's scope. `required_scope` names it. |
| `mcp_not_allowed` | MCP access disabled on the key. |
| `api_key_expired` | Key passed its expiry. |
| `payment_cap_exceeded` | Amount above the key's per-payment cap. |
| `daily_cap_exceeded` | Amount would exceed today's cap. |
| `mode_mismatch` | Resource belongs to the other test/live environment. |

Every failed request is visible in **Logs → API requests** with the key id, request source (`api` or
`mcp`) and required scope.


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