Preview. Stack v4.0 has not been released, and what is documented here can still change before it does. The current release is v3.2.Go to v3.2
Reference

Authentication

Get OAuth2 bearer tokens for personal access or application client-credentials authentication.

Every request carries an OAuth2 bearer token. Tokens are scoped to one stack and expire; the SDKs refresh them for you, curl does not.

Get a token#

For a human on a laptop, fctl mints a personal token against your logged-in Cloud session. For a service, create an OAuth2 client in the stack and use the client-credentials grant. Personal tokens are for exploration — never ship one.

bash
curl -X POST "$FORMANCE_API_URL/api/auth/oauth/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=$FORMANCE_CLIENT_ID" \
  -d "client_secret=$FORMANCE_CLIENT_SECRET"

# => { "access_token": "eyJ…", "expires_in": 3600 }

Send it#

Set Authorization: Bearer on every call. On the Ledger 3.0 HTTP API, a missing or invalid token returns 401 with a short text/plain reason. A valid token that lacks the scope for the operation returns 403 with the body missing required scope; the HTTP response does not say which scope. The gRPC API returns PERMISSION_DENIED and names the required scope.

HeaderRequiredNotes
AuthorizationyesBearer <access_token>. Tokens last one hour by default.
Content-Typewith a bodyapplication/json. Ledger 3.0 list calls take their filter in the filter query parameter, not in a body.
Idempotency-Keysome writesClient-generated. Where honored, replays the original response on retry. Coverage is per-endpoint, not per-module. Ledger 3.0 accepts it on transaction and metadata writes, ledger creation and deletion, and the bulk route; Wallets writes accept it, and Webhooks delivery replay requires it. See Conventions.
bash
curl "$FORMANCE_API_URL/api/ledger/v3/" \
  -H "Authorization: Bearer $FORMANCE_TOKEN"

Scopes#

Scopes are granted per module and per verb. A client that only reads the ledger needs ledger:read; posting transactions needs ledger:write. Membership roles are separate and are managed from the Cloud console, not the stack.

In Ledger 3.0, ledger:read and ledger:write expand to granular scopes such as ledger:TransactionRead and ledger:TransactionWrite. Neither grants cluster operations such as backups: ledger:admin is the only aggregate scope that grants ledger:ClusterRead and ledger:ClusterWrite. See Understand scopes for the full list.

ScopeGrants
ledger:readList and retrieve ledgers, transactions, accounts, balances and volumes.
ledger:writeCreate and revert transactions, write metadata, run bulk actions.
payments:readRead connectors, payments, bank accounts and payment service users.
payments:writeInstall connectors and initiate payments.
wallets:readList and retrieve wallets, balances and holds.
wallets:writeCreate wallets, debit, credit and manage holds.
orchestration:readRead workflow definitions and execution instances.
orchestration:writeCreate and trigger workflows.
webhooks:readList webhook configurations and delivery attempts.
webhooks:writeCreate, update and delete webhook configurations.
reconciliation:readRead reconciliation policies and reports.
reconciliation:writeCreate reconciliation policies and run reconciliations.
auth:readRead OAuth2 clients and their configuration.
auth:writeCreate and manage OAuth2 clients and secrets.
search:readQuery the full-text search index (Enterprise Edition).
search:writeIndex documents into the full-text search service (Enterprise Edition).