Skip to content

Flint CLI

The Flint CLI (flint) calls the public API from your terminal. Each API command maps to one /v1 route, and flint api calls any documented route directly, so anything you can do over HTTP you can do from a shell, a script, or a CI job. Developers reach for it to:

  • Try a payment flow before writing any integration code.
  • Forward sandbox webhook events to a server on localhost with flint listen, without a public tunnel.
  • Script the API in CI, with JSON output, stable exit codes, and no stored API key.
  • Give an AI agent tools for your sandbox with flint mcp serve.

This guide describes CLI 0.20.6. The releases page lists what each version changed; read it before upgrading scripts across versions, because releases follow the public API and can rename commands and flags.

Install#

Shell
npm install -g @flintpay/cli

The npm package installs a prebuilt binary for your platform. On macOS and Linux you can use Homebrew instead:

Shell
brew install flint-pay/tap/flint

Without npm or Homebrew, the install script downloads the release archive for your platform and checks it against the release's checksums.txt:

cURL
curl -fsSL https://raw.githubusercontent.com/flint-pay/flint-cli/main/scripts/install.sh -o /tmp/flint-install.sh
sh /tmp/flint-install.sh

The script installs to /usr/local/bin when you can write to it and to ~/.local/bin otherwise, and says so if that directory isn't on your PATH. Set FLINT_INSTALL_DIR to choose the directory and FLINT_CLI_VERSION to pin a version, such as 0.20.6. On Windows, download the ZIP and checksums.txt from a release, check the ZIP with Get-FileHash -Algorithm SHA256, and put flint.exe in a directory on your PATH.

Check the install:

Shell
flint version
flint upgrade --check

flint version prints the CLI version and the API version it sends in Flint-Version. Each release pins one API version. If upgrading from 0.14.x fails because the old updater expects data.cli_version, run npm install -g @flintpay/cli@latest or brew upgrade flint.

If upgrading from 0.16.x, switch the commands that 0.17 removed or renamed. fulfillments transitions create and packages transitions create became one command per action, such as flint fulfillments mark-ready and flint packages mark-shipped. credit-notes refunds create and credit-notes refunds list became flint refunds create --refund-type credit_note and flint refunds list --credit-note-id. orders inventory-exception resolve is now orders resolve-inventory-exception. The 0.17 migration notes list every replacement.

If upgrading from 0.17.x, use api-keys create --sandbox-id for sandbox key minting. Checkout delivery quotes and selections now use the top-level delivery-quotes and delivery-selections commands. The 0.18 migration notes cover the removed commands, replacements, and request changes.

If upgrading from 0.18.x, use me credit-notes for buyer credit notes and payment-intents create --order-id for order-owned payment intents. Return-child creation uses return-inspections create --return-id, return-receipts create --return-id, return-dispositions create --return-id, and return-resolutions create --return-id. The 0.19 migration notes cover the breaking command, request, and response changes.

flint upgrade --check compares your version with the latest stable release and changes nothing; flint upgrade updates through npm or Homebrew when they own the install, or replaces a standalone binary after verifying its checksum.

Run in a container#

Flint CLI images use vX.Y.Z tags and a latest tag. Run a pinned image to check its CLI and API versions.

Shell
docker run --rm ghcr.io/flint-pay/flint-cli:v0.21.0 version

Put the Flint command and its arguments after the image name. Export your sandbox API key as FLINT_API_KEY to make it available in the container.

Shell
docker run --rm -e FLINT_API_KEY ghcr.io/flint-pay/flint-cli:v0.21.0 whoami

To keep a profile across runs, mount a directory writable by container user 65532 at /config. Pass -e XDG_CONFIG_HOME=/config -e FLINT_CREDENTIAL_STORE=file so the CLI stores the profile and credentials in that directory.

To forward webhooks to a receiver on the host, use flint listen --forward-to http://host.docker.internal:3000/webhooks/flint. On Linux Docker Engine, add --add-host=host.docker.internal:host-gateway before the image name and bind the receiver to an address reachable from the container, such as the host's bridge address.

Sign in#

Shell
flint login

flint login (short for flint auth login) opens the Flint dashboard and prints a code. Check that the browser shows the same code, choose the merchant and sandbox the CLI may use, and approve. The CLI saves the session in your OS keychain and refreshes it automatically. No API key is copied anywhere.

  • The approval starts with your default sandbox selected. You can add more sandboxes, more merchants, or live access before approving. Live access is labeled and needs its own approval; flint login --live asks for a live context up front.
  • --no-open prints the link without opening a browser. --profile NAME signs in to a separate profile. Login waits up to 10 minutes; --timeout 5m changes that.
  • flint login reuses a valid saved session. --new-session replaces it after you approve.
  • For an agent or a two-step script, flint login --no-wait --output json returns verification_url, user_code, expires_at, and next_command, then exits. A person approves the link, and running next_command finishes the login.

Then check the setup:

Shell
flint doctor

flint doctor checks your config, credential, connectivity, environment, merchant, scopes, and API version, and prints a fix for each failed check. If the server's current API version differs from the one your CLI requests, doctor says so; the CLI keeps sending its own version. flint doctor --fix repairs a stale default-profile setting and never touches credentials or anything on the server. flint whoami shows the active credential and context.

Create an account from the terminal#

Without a Flint account, run flint signup. It asks for your name and email, emails you a verification code, runs the API onboarding calls, and saves your first sandbox key for the profile. The CLI uses your OS keychain by default and never prints the key. To call the API with curl or an SDK as well, create a key on the dashboard's API keys page.

For a script on a headless machine, run signup in two calls. Use the verification code from the email in the second call.

Shell
flint signup --email dev@example.com --first-name Ada --last-name Lovelace --credential-store file --no-input --output json
flint signup --verification-code 482193 --credential-store file --no-input --output json

The first call returns data.status set to verification_required and saves the pending signup in the profile. The second finishes it with the same profile. On a headless machine, --credential-store file saves the key in a file with owner-only permissions. Omit the flag to use your OS keychain. A code allows five attempts; after that, or once it expires, start again without --verification-code. If the email belongs to an account with two-step verification, is unverified on an existing sign-in, or is linked to a different Flint sign-in, signup stops with 409 ALREADY_EXISTS; run flint login instead.

Choose where commands run#

One login can cover several contexts, each one a merchant's sandbox or live environment.

Shell
flint context list
flint context switch
flint context switch ctx_123
flint context switch ctx_456 --live

flint context switch without an ID opens a selector that labels live contexts. Making a live context the default by ID needs --live. Run a single command in another context with --context:

Shell
flint payment-intents list --context ctx_123

A project can pin its context in .flint/config.json (see Sandbox and live safety). The CLI uses --context first, then the project's pin, then the profile default. Switching the default doesn't affect a command, page fetch, or listener that is already running.

Add permissions or end a session#

Browser login grants permissions for shop operations: catalog, inventory, locations, promotions, gift cards, orders, returns, subscriptions, checkout, invoices, refunds, customers, settings, webhooks, reports, and analytics, plus financial reads and API key management. Payout and payout-setting writes, dispute responses, gift card codes and balance adjustments, customer sessions, workload identities, risk controls, platform operations, sandbox and test-clock management, and hardware need explicit scopes. The CLI checks a command's known scope requirements before sending it and names the missing scope. Add it to the active context:

Shell
flint reauth --scope developer.sandboxes.read

Before calling a command, inspect its scope_requirement with flint schema command COMMAND --output json. flint auth status and flint doctor summarize scope access, including blocked resource groups. Local scope refusals use INSUFFICIENT_SCOPE, with missing scopes in details[].missing_scopes.

Repeat --scope for several. The browser can approve part of a request, and the CLI reports what was granted. flint reauth without a scope reviews the whole session: add or remove contexts, or change permissions. Each existing context keeps its current permissions, including scopes added earlier with --scope, unless you uncheck them. New contexts start with the login permissions. Denying in the browser leaves the session as it was.

Access tokens last 15 minutes and refresh automatically. A session ends after 30 days without a refresh or 90 days after login, whichever comes first. To end one yourself:

Shell
flint logout --confirm

Logout revokes the session across all its contexts before deleting local credentials. If Flint doesn't confirm the revocation, logout fails and keeps the credentials so you can retry. You can also review and revoke sessions on the dashboard's CLI sessions page. CLI OAuth documents the HTTP flow.

Use an API key instead#

Shell
flint auth import

flint auth import reads a key at a hidden prompt, validates it, and stores it in the keychain. A script can pipe it in with flint auth import --stdin < key.txt. Logging out of an imported key removes it from the keychain and leaves the key itself active.

The CLI uses the OS keychain by default. On a headless machine, choose --credential-store file or set FLINT_CREDENTIAL_STORE=file to store credentials in a file with owner-only permissions. In CI, prefer a workload identity or set FLINT_API_KEY. An environment credential overrides the saved login and its contexts, and can't be combined with --context.

Use the CLI as your partner app#

Set FLINT_ACCESS_TOKEN to a short-lived partner app token obtained by your backend with the app's client credential. Keep the token out of shell history and logs. Select a connected merchant:

Shell
flint orders list --merchant mer_123
flint orders list --merchant mer_123 --sandbox test_123
flint mcp serve --merchant mer_123 --sandbox test_123

With a partner app token, --merchant sends Flint-Merchant-Id on every API request. FLINT_MERCHANT, flint config set merchant mer_123, and a project's merchant_id select the same target. --sandbox or FLINT_SANDBOX sends Flint-Sandbox-Id; a project sandbox_id also applies. Send a sandbox only with a test-mode token. Flint checks the merchant's grant and your app's permissions. A merchant-bound token can omit the merchant; Flint checks any explicit selection against its binding.

An MCP server without a pinned merchant accepts a top-level merchant control on flint_read, flint_write, and typed operation tools. For example, call flint_read with:

JSON
{"operation":"orders.list","merchant":"mer_123"}

Calls cannot replace a merchant selected in the server's flags, environment, project, or profile. Start an unpinned server to work across connected merchants. The CLI cannot verify a partner token's mode, so sensitive writes require confirmation. MCP also requires user approval through elicitation unless the server permits agent confirmation with --allow-destructive. Dry runs and confirmation output identify the selected merchant.

With API keys and other credentials, merchant and sandbox settings remain guards against the credential's own context.

Make a test payment#

Create a payment link and open it:

Shell
flint payment-links create \
  --name "Design consultation" \
  --item-name "Design consultation" \
  --amount 2500 \
  --currency USD \
  --open

Amounts are integers in the currency's smallest unit, so 2500 is $25.00 (Money & currency). --open opens the link in your browser from an interactive terminal; the URL prints either way, and --field url prints only the URL. Pay with:

Test cardAny future expiry, any CVC.

The payment appears under Payments in your sandbox's dashboard. Accept your first payment walks through the same payment with curl.

A payment link is reusable. For a one-time hosted checkout, create a checkout session:

Shell
flint checkout-sessions create --quick-pay-name "T-shirt" --amount 2500 --currency USD --open

Pay from the terminal#

To skip the browser, create an order and pay its balance with a sandbox payment source token. order.json holds an order create body:

JSON
{
  "line_items": [
    {
      "type": "custom",
      "name": "Design consultation",
      "quantity": 1,
      "unit_price_money": {"amount": 2500, "currency": "USD"},
      "fulfillment": {"requirement": "none"}
    }
  ],
  "tax": {"enabled": false}
}
Shell
flint orders create --input order.json
flint orders pay @last.ord \
  --input '{"action": "pay", "payment_source": {"credential_type": "stripe_payment_method", "stripe": {"payment_method": "pm_card_visa"}}}' \
  --idempotency-key consult-order-pay-1

@last.ord is the order you just created (Refer to the last resource).

pm_card_visa succeeds. flint help test-cards prints the other sandbox tokens and their card numbers offline, and Testing covers declines and 3D Secure.

--payment-source-token on flint orders pay does something different: it confirms payment intents that already exist on the order, sending action: "confirm_payment_intents". Pass pi_123=pm_card_visa for each one.

Send a request body#

Every top-level scalar and scalar array in a request body has a generated flag named after its API field, such as --customer-id or --enabled-events. Help lists allowed values and required flags. For nested objects, pass the API request body as JSON: --input order.json for a file, --input - for stdin, or inline JSON:

Shell
flint customers create --input '{"email": "jane@example.com"}'

Flags replace matching fields in --input; repeated array flags replace the whole array. Conflicting flags for one scalar fail with DUPLICATE_FLAG, and flags cannot change a union tag already set by --input. --dry-run=client reports replaced fields as overridden_fields. On readable, version-guarded PATCH routes, --add-FIELD and --remove-FIELD merge scalar arrays, for example flint webhook-endpoints update whep_123 --add-enabled-events refund.succeeded. Path IDs and controls such as --idempotency-key and --live are always flags, never body fields. Before sending, the CLI checks the merged body against the operation's schema. A missing required field, wrong type, invalid value, or unknown field fails locally with exit code 2 and INVALID_REQUEST_BODY. error.details.problems lists each one with its JSON path, such as $.emial, and a suggestion when the name looks misspelled.

Shell
flint schema input orders.create --output json
flint orders create --input order.json --dry-run=client --output json

flint schema input prints the body's JSON Schema. Add --example to print a documented request body as raw JSON. --dry-run=client runs the same checks and prints the method, path, headers, and body the CLI would send, without calling the API. A dry run can't check server rules, such as whether a referenced ID exists. To send fields the CLI's schema doesn't know, use flint api.

Refer to the last resource#

Shell
flint payment-intents get @last.pi
flint orders get @last.ord

@last is the most recent resource this profile created or changed, within the current credential, merchant, and environment. Add a type to narrow it: @last.pi for a payment intent, @last.ord for an order, @last.cs for a checkout session, @last.ref for a refund. Each command's help says which @last forms an argument accepts.

Reads don't update history, so you can create, read, and then act on the same resource. Every process using the profile shares the history, so use explicit IDs for commands that run in parallel. flint history lists what is stored, and flint history --clear --confirm empties it.

Forward webhooks to localhost#

flint listen streams your sandbox's webhook events as Flint creates them and posts each one to a local URL, signed the way Flint signs production deliveries:

Shell
flint listen --forward-to http://localhost:8080/webhooks/flint
Text
Ready. Forwarding webhook events to http://localhost:8080/webhooks/flint. Press Ctrl-C to stop.
Endpoint: whep_1kmn0aExample (created for flint listen; later runs reuse it). Signed by Flint; delivery is at-least-once.
Verify deliveries as JWTs with this endpoint ID as the audience: FLINT_WEBHOOK_ENDPOINT_ID=whep_1kmn0aExample
Forwarding one eventResponse
Flintflint listenYour local serverGET /v1/webhook-events/streamreadyan event, as it is createdPOST /v1/webhook-endpoints/{id}/sign-deliverythe exact body and headers, with a JWTPOST the Flint-signed delivery2xx, or a failure the CLI prints
  1. flint listen sends GET /v1/webhook-events/stream to Flint
  2. Flint returns ready to flint listen
  3. Flint sends an event, as it is created to flint listen
  4. flint listen sends POST /v1/webhook-endpoints/{id}/sign-delivery to Flint
  5. Flint returns the exact body and headers, with a JWT to flint listen
  6. flint listen sends POST the Flint-signed delivery to Your local server
  7. Your local server returns 2xx, or a failure the CLI prints to flint listen

The listener receives events for the environment your credential belongs to, starting when it connects. Forwarding needs a sandbox credential, because Flint signs forwarded deliveries for sandbox endpoints only. With a live credential or --live, --forward-to fails with TEST_MODE_REQUIRED before any request. Each forwarded request carries the merchant webhook envelope at your API version, including event_source and sandbox_id. Transport errors, timeouts, 429, and 5xx are retried up to three attempts; deduplicate by webhook event ID. Your handler's 2xx response counts as delivered, and the CLI prints the status code and latency for each event.

Verify forwarded deliveries#

Copy the endpoint ID the listener prints into your app's environment as FLINT_WEBHOOK_ENDPOINT_ID=whep_.... It's the JWT audience, not a secret. Later runs reuse the same endpoint, so you configure your handler once. Production uses the ID of its own registered endpoint. Then verify the delivery exactly as you do in production:

TypeScript
const { event } = await flint.verifyWebhookAsync(rawBody, req.headers, {
  endpointIds: [process.env.FLINT_WEBHOOK_ENDPOINT_ID!],
});

For a receiver without a Flint SDK, use the Python, Go, or Node with jose example in Verify the signature.

The listener endpoint#

Without --webhook-endpoint-id, the first run creates one sandbox webhook endpoint for the CLI, and later runs reuse it. It's shared by every profile, forwarding URL, and teammate in that sandbox, and it receives every event type. The CLI keeps it when the listener exits, because its ID is the JWT audience. Its registered URL is a placeholder that never resolves. Flint delivers this endpoint's events only through the listener stream, so the endpoint has no deliveries of its own, and the Dashboard marks it "Used by flint listen". To remove the endpoint, run flint webhook-endpoints delete whep_... --confirm; the next run creates a new one with a new ID.

To create the default wildcard endpoint on first use, run the CLI with a full-access sandbox API key. If you use a restricted credential, create a sandbox endpoint with the specific event types your credential can read and pass its ID with --webhook-endpoint-id.

To test the subscriptions of an endpoint you registered, pass --webhook-endpoint-id whep_.... The endpoint must be active and have jwt in its signing_methods, or the command fails with WEBHOOK_ENDPOINT_NOT_USABLE before connecting. The listener then forwards only that endpoint's enabled_events, and the CLI never changes it. Running with --event-type for an event the endpoint doesn't subscribe to fails with EVENT_TYPE_NOT_ENABLED before the stream opens.

If Flint can't sign an event for the endpoint, such as one whose type the endpoint doesn't subscribe to, the listener prints a skipped record and continues. Skipped events don't count toward --max-events. flint listen doesn't sign with a local secret: --print-secret and --webhook-secret fail with LOCAL_SIGNING_REMOVED, and FLINT_WEBHOOK_SECRET is ignored.

Narrow and resume the stream#

Narrow the stream to one event type, and resume after a restart from the last event you processed:

Shell
flint listen \
  --forward-to http://localhost:8080/webhooks/flint \
  --event-type payment_intent.succeeded \
  --cursor whev_123

Repeat --event-type or pass comma-separated types; flint help events lists them. Newer event names are passed through to the server. --cursor resumes after that event ID. If the cursor's events are no longer available, the listener prints a gap record. When your credential can't read the resource an event is about, the listener prints the event as withheld, with the scope it needs; add it with flint reauth --scope.

--forward-to accepts localhost, loopback IPs, and host.docker.internal. Without it, the listener prints events instead of forwarding them, and --live is available. An environment supports up to five listeners at once.

To use the listener in a test, bound the run with --max-events N, --for DURATION, or both:

Shell
flint listen --forward-to http://localhost:8080/webhooks/flint \
  --event-type customer.created --max-events 1 --for 2m --output json

A bounded run exits 0 when every delivery succeeded, 1 if any failed, 5 if it never connected, and 6 if --for ran out before --max-events events arrived. In JSON output, the first record is a listener record with webhook_endpoint_id, and the last is a checkpoint record with cursor and counts of forwarded, failed, skipped, and withheld events. A script can read the endpoint ID from the first record. After a failure the checkpoint also has replay_cursor: fix your handler and pass that value to --cursor to replay from the first failed event.

flint listen is for development. To deliver events to a deployed service, register a webhook endpoint.

Trigger sandbox events#

flint trigger EVENT creates sandbox resources through the public API to produce a webhook event. It prints expected events, resource IDs, request IDs, and a resume command with per-step idempotency keys. Live and unverified credentials are refused before a write.

Shell
flint trigger --list
flint trigger customer.created

--list works offline. Use --for DURATION to change how long a trigger waits. The default is 2 minutes, or 5 minutes for subscription and test-clock recipes; an expired wait exits 6.

Shell completion#

flint completion bash|zsh|fish prints an offline script for commands, flags, and allowed values. Load the script for your shell, for example:

Shell
source <(flint completion bash)

Wait for an async result#

Some results arrive after the request returns, such as a refund the processor settles later. Instead of polling by hand, wait for a field to reach a value:

Shell
flint refunds create --payment-intent-id pi_123 --refund-type full --idempotency-key consult-refund-1
flint refunds get @last.ref --wait-for status=succeeded --for 60s

--wait-for FIELD=VALUE is available on get commands. The CLI polls with backoff, starting at one second and growing to ten, for up to --for (default two minutes), and exits 0 with the resource once the field matches. It exits 6 with WAIT_CONDITION_UNMET when time runs out, or with WAIT_CONDITION_IMPOSSIBLE as soon as the resource reaches a final state that can't match, such as a failed refund. Both errors include details.conditions, details.observed, and details.last, the last resource it read.

Script the CLI#

For scripts and agents, add --output json, or set FLINT_OUTPUT=json once. JSON mode prints one JSON document on stdout and never prompts, so a command can't hang waiting for a terminal. Progress, diagnostics, and prompts go to stderr, which keeps stdout clean for piping.

Shell
flint payment-intents list --status succeeded --created-after 7d --output json

Output follows the API's envelope: the resource or list under data, with next_page_token on lists. Three flags shape it:

  • --field PATH reads inside the resource (data), or each list element: --field url. Scalars print unquoted, objects and arrays as compact JSON, and lists one line per element.
  • --select FIELDS keeps the named fields of each resource and preserves envelope fields such as next_page_token and request_id.
  • --jq EXPR sees the whole response, for example --jq .next_page_token.

--field, --select, and --wait-for paths are checked before sending. Drop a leading data.; it fails with OUTPUT_FIELD_ROOT, while unknown fields fail with UNKNOWN_OUTPUT_FIELD. Declared absent or null fields resolve to null. A webhook event's own data field remains part of its resource path.

Time filters such as --created-after accept RFC 3339 timestamps, rolling durations such as 2h, 7d, or 2w, and dates (YYYY-MM-DD). Dates, today, yesterday, and this_week start at midnight in the merchant's time zone as the CLI reads it from the API, with weeks starting on Monday. The time zone is cached for one hour; without permission to read it, or offline without a cache, the CLI uses UTC and prints a note. For dates that don't depend on that setting, pass RFC 3339 timestamps with an explicit offset. Body time flags also accept now and signed durations such as +14d or -2h; timestamps inside --input stay as written. Set FLINT_NO_INPUT=1, or pass --no-input, to turn off prompts in human mode too.

Lists and pagination#

A list command returns one page. To get more:

  • --page-token TOKEN fetches the page after the one that returned next_page_token. The token is omitted on the last page.
  • --all fetches every page and merges them into one envelope.
  • --limit N collects up to N items, requesting at most 100 per page, and keeps next_page_token so you can continue later.

Pagination covers the API side.

Idempotency keys#

--idempotency-key KEY sets the idempotency key on a write. Routes that require one, such as flint refunds create, flint orders pay, and flint payment-intents create, fail locally with IDEMPOTENCY_KEY_REQUIRED until you pass it, including with --dry-run=client:

JSON
{
  "error": {
    "code": "IDEMPOTENCY_KEY_REQUIRED",
    "details": {},
    "message": "--idempotency-key is required for this operation. Save a key with the action before sending and reuse the same key on retry; a key generated for one command cannot protect a later run from repeating the action.",
    "param": "--idempotency-key",
    "retryable": false,
    "type": "usage_error"
  }
}

Save the key alongside the action before the first attempt, so a rerun of the same script reuses it. On writes where the key is optional, the CLI generates one (flint-cli-...) and reuses it across its own retries. Routes that take no key get none.

Errors and retries#

Errors in JSON mode use an {"error": {...}} envelope with type, code, message, and details, which is always an object. param names the flag or field when one is at fault. request_id and http_status appear when the error came from the API. remediation, when present, lists next actions. retry_after_ms reports a Retry-After header.

--timeout, fixed at MCP server startup, defaults to a total 150-second budget, including retries. Each attempt gets the remaining budget. Reads and keyed writes make at most 3 attempts, honoring Retry-After; writes that take no key are sent once.

retryable is true when sending the same request again is safe and may succeed: no usable response arrived, Flint returned remediation.retry: "same_request", or a response without a Flint error envelope had HTTP 429, 500, 502, 503, or 504. If retries end with an unknown outcome, the error instead reports details.outcome: "unknown", details.retry: "none", and retryable: false. It retains attempt facts, request IDs, the write's details.idempotency_key, and recovery_reads. Read the resource before deciding whether to retry; an empty recovery list does not prove that a write had no effect. For known operations that accept idempotency keys, reusing the same key is safe and returns the original result. Error handling describes the API's retry remedies.

CLI-local timeout, cancellation, and invalid API-key format codes are CLIENT_TIMEOUT, CLIENT_CANCELED, and CREDENTIAL_FORMAT_INVALID. Scripts matching the previous local codes REQUEST_TIMEOUT, REQUEST_CANCELED, or INVALID_CREDENTIAL must update those matches. API errors named INVALID_CREDENTIAL still pass through unchanged.

Exit codes#

Branch on the exit code instead of parsing stderr:

CodeMeaning
0Success
1API error, or a failed webhook delivery from flint listen
2Usage error: bad flag, missing argument, or a request body that fails local validation
3Authentication or configuration problem, including HTTP 403
4Confirmation required and not given
5Network failure or timeout, including a listener that never connected
6Wait condition unmet or impossible, or fewer events than --max-events
70Internal CLI error

flint help exit-codes prints the same table offline, and flint help errors describes the error envelope.

Run in CI#

In CI, authenticate with a workload identity instead of a stored key. The identity trusts your platform's OIDC tokens for a given issuer, subject, and audience, and fixes the merchant, environment, and scopes. The CLI exchanges the job's token for a Flint access token that lasts up to an hour, and stores nothing. Create one on the dashboard's Workload identities page or with flint workload-identities create, and restrict it to your repository and branch or environment. Its wid_ ID isn't a secret. Workload identities has a recipe for each platform.

On GitHub Actions, the setup-flint action installs the CLI and configures the identity:

YAML
permissions:
  contents: read
  id-token: write

jobs:
  smoke-test:
    runs-on: ubuntu-latest
    steps:
      - uses: flint-pay/setup-flint@v1
        with:
          workload-identity-id: ${{ vars.FLINT_WORKLOAD_IDENTITY_ID }}
      - run: flint payment-intents list --limit 10 --output json

Elsewhere, install the CLI and set FLINT_WORKLOAD_IDENTITY_ID and FLINT_NO_INPUT=1. The CLI finds the token in FLINT_OIDC_TOKEN or FLINT_OIDC_TOKEN_FILE, on GitHub Actions, on GitLab CI, in a Kubernetes token projected at /var/run/secrets/flint/token, and, in CLI releases newer than the one this guide describes, on Google Cloud, Azure, and AWS; see Workload identities for each platform. For GitLab, issue the token into FLINT_OIDC_TOKEN:

YAML
id_tokens:
  FLINT_OIDC_TOKEN:
    aud: https://api.withflintpay.com

The audience defaults to the API origin and must match the identity's audience. A live identity needs --live on every command, like a live API key.

If your platform can't issue an OIDC token, keep an API key in its secret store and expose it as FLINT_API_KEY. To hand the CLI's credential to another tool in the same job, such as an SDK script, flint auth token --output json prints a short-lived access_token with its expires_at. Treat it as a secret. API keys can't be exported this way; give the other tool the key itself.

VariablePurpose
FLINT_WORKLOAD_IDENTITY_IDWorkload identity to exchange the job's OIDC token with
FLINT_API_KEYAPI key, when a workload identity isn't available
FLINT_ACCESS_TOKENAn access token you already have; takes precedence over FLINT_API_KEY
FLINT_OIDC_SOURCEWhere to find the OIDC token: auto (default), token, token_file, github_actions, gitlab_ci, kubernetes, or none
FLINT_OIDC_AUDIENCE, FLINT_OIDC_SCOPEOverride the requested audience, or narrow the scopes
FLINT_OUTPUT, FLINT_NO_INPUTjson output and no prompts for every command
FLINT_PROFILEProfile to use
FLINT_MERCHANT, FLINT_SANDBOXPartner targets, or merchant and sandbox guards for other credentials
FLINT_BASE_URLAnother API server, such as a local development server

Environment credentials take precedence over the saved login in this order: FLINT_ACCESS_TOKEN, then FLINT_API_KEY, then FLINT_WORKLOAD_IDENTITY_ID. Sandbox and live requests both go to https://api.withflintpay.com; the credential decides the environment. A browser-login session stays bound to the server it signed in to and rejects a different FLINT_BASE_URL, so sign in to a development server with a separate profile.

Sandbox and live safety#

The CLI reads the environment from the credential, so no mode flag can drift out of sync with the key.

  • Live API keys and workload identities fail with LIVE_ACKNOWLEDGEMENT_REQUIRED (exit 3) on every command until you pass --live. Passing --live with a sandbox credential fails too.
  • A live context from flint login was approved in the browser, so its commands run without --live.
  • Sandbox confirmation is required for irreversible operations, except payment collection (pay, confirm, capture, collect). Live or unverified environments require confirmation for sensitive or irreversible operations. An interactive terminal asks "Continue? [y/N]"; scripts need --confirm, which is accepted on every mutation. Without it, a gated command exits 4 with CONFIRMATION_REQUIRED, PRODUCTION_CONFIRMATION_REQUIRED, or UNVERIFIED_ENVIRONMENT_CONFIRMATION_REQUIRED. Ordinary writes and reversible overwrites do not prompt.
  • --preview on a destructive command prints the request it would send, whether your credential has the scopes, and whether the change can be undone, without sending anything.
  • Merchant tokens in FLINT_ACCESS_TOKEN are checked with Flint before a write. When its environment can't be verified, sensitive commands need --confirm and fail with UNVERIFIED_ENVIRONMENT_CONFIRMATION_REQUIRED otherwise.

To keep a misconfigured credential from acting on the wrong account, pin the merchant:

Shell
flint config set merchant mer_123

For API keys and other merchant credentials, when the credential's merchant doesn't match, commands fail with MERCHANT_GUARD_MISMATCH before sending anything. Use --merchant or FLINT_MERCHANT for one command or one shell, and flint config unset merchant to clear it.

To share the guard with everyone working in a repository, commit .flint/config.json at the project root. The CLI looks for it in the working directory and each parent:

JSON
{
  "profile": "acme",
  "merchant_id": "mer_123",
  "sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
  "context_id": "ctx_123"
}

Every field is optional. sandbox_id makes commands fail with SANDBOX_GUARD_MISMATCH unless the credential belongs to that sandbox, and context_id pins a browser-login context. Unknown config keys and unknown profiles fail instead of being ignored. Flags override environment variables, which override the project file, which overrides your global config. flint config get prints the resolved values and, under sources, where each came from. The file holds no secrets.

Call any route#

When a route has no dedicated command, or you need to send a field the CLI's schema doesn't know, call it directly:

Shell
flint api get /v1/payment-intents/pi_123
flint api post /v1/payment-intents \
  --input '{"amount_money":{"amount":5000,"currency":"USD"},"payment_options":["card"]}' \
  --idempotency-key consult-pi-2
flint api get "/v1/orders?status=open" --all

flint api takes a method and a documented /v1 path with IDs filled in and an optional query string. It skips local body validation and keeps everything else: authentication, live acknowledgement, confirmation, idempotency keys, retries, and the error envelope. For a GET, --all merges every page into one envelope, and --paginate prints each page as its own JSON line. Both work only with flint api get.

Debug a request#

--debug prints each request's method, path, attempt, idempotency key, HTTP status, API version, and trace ID to stderr. When the API returns an error, the CLI prints its request_id. Look up that request's log, then open it by its rlog_ ID:

Shell
flint api-request-logs list --request-id req_01KWM63CW5B1NVAAJ4896D22Y3
flint api-request-logs get rlog_01KWM6WAHJAXHCHE87C0KBBY7G

flint api-request-logs list --status-bucket server_error lists recent failures instead.

To see why a resource is in an unexpected state, flint resource-timelines get lists the requests, webhook deliveries, and payment attempts that touched it, in order:

Shell
flint resource-timelines get pi_123

Follow new requests as they are recorded:

Shell
flint api-request-logs list --follow --created-after 10m --output ndjson

The command polls every 2 seconds. With --output json, bound it with --max-events or --for.

Debugging covers request logs and timelines in depth.

Getting help#

flint help search ranks the installed command, event, and reference-topic catalog offline. It needs no credential and makes no network request:

Shell
flint help search webhook signature verification

It returns up to eight results with links to command help. Add --output json to read them in a script. FLINT_HELP_URL is no longer read.

For a question about your integration, flint support open builds a Flint Help composer link with your context filled in and opens it. You review and post from the browser; the CLI never posts on its own.

Shell
flint support open --request-id req_01KWM63CW5B1NVAAJ4896D22Y3 --area webhooks

The link carries the request ID, the resource ID from --resource, the product area, and your credential's environment. --area takes a product area such as payments, webhooks, or api; flint support open --help lists them all. --title and --body prefill the thread, --private asks for a private thread, --ai-agent marks the thread as opened by an agent, and --no-open prints the link instead of opening it.

Agents and MCP#

flint mcp serve runs a local MCP server over stdio that exposes CLI commands as tools, so an AI agent can create and inspect resources with your credential. It uses the same credential as the CLI: your saved login, the profile in FLINT_PROFILE or --profile, or FLINT_API_KEY. Sign in or import a key in your terminal before starting the server.

Shell
claude mcp add --transport stdio flint -- flint mcp serve

For a client that reads an mcpServers file, such as Cursor's .cursor/mcp.json:

JSON
{
  "mcpServers": {
    "flint": {
      "command": "flint",
      "args": ["mcp", "serve"],
      "env": {"FLINT_PROFILE": "default"}
    }
  }
}

Keep live keys out of shared config files. Point the server at a profile, or use a sandbox key (flint_test_...).

The default server exposes five discovery tools, about 6 KB for tools/list:

ToolUse
flint_searchFind operations by task.
flint_describeInspect arguments, results, nested schemas, or webhook payloads.
flint_readRun a read operation.
flint_writeRun a write operation.
flint_helpRead resource groups and the safety, errors, events, and test-cards topics.

Find an operation, inspect it, then call it:

JSON
{"name":"flint_search","arguments":{"query":"refund an order"}}
{"name":"flint_describe","arguments":{"operation":"refunds.create"}}
{"name":"flint_write","arguments":{"operation":"refunds.create","arguments":{"order_id":"ord_123","refund_type":"full"},"idempotency_key":"refund-ord-123-1","dry_run":true}}

Operation IDs follow CLI names, such as orders.list and merchant.get. Execution controls (dry_run, confirm, live, idempotency_key, select) are top-level tool arguments, outside the operation's arguments; the old _flint object is removed. Reads return one compact JSON text block plus notes when needed, capped at 49,152 bytes. Narrow a large result with select, filters, or page_size; lists default to 10 items. Completed writes return their result with a warning if oversized.

CLI releases after the one this guide describes mask credentials in MCP read and write results, including API keys, client secrets, webhook signing secrets, and bearer links. An API key result includes its ID and a masked prefix. When a result contains a secret, the notes show the path to a private JSON file on the machine running Flint (mode 0600 on Unix). Open the file yourself, move the values to the intended destination, and delete the file when you are done. Invoice PDF downloads use the same private handoff and save directly as PDFs.

--tools orders,refunds.create opts into typed tools for those groups or operation IDs, plus search, describe, and help restricted to that scope. --tools all exposes the full typed set. Typed mode has no flint_read or flint_write. Names use underscores for both dots and hyphens, such as payment_intents_create; old dotted or hyphenated tool names and --tools default are removed. Keep the client's server name at most five characters so prefixed names fit 64 characters. The compact JSON tools/list result is 53,307 bytes for --tools orders and 854,282 bytes for --tools all. Each tool is under 10,000 bytes.

The person who starts the server sets its limits:

  • --read-only removes write tools and refuses writes, including direct calls and dry runs.
  • The profile, pinned merchant, context, and timeout are fixed at startup. Partner tokens can select a merchant per call when the server has no pinned merchant. Credential class also limits discovery and calls; merchant keys cannot reach buyer-session operations.
  • Live access needs --allow-live at startup and live: true on each live call.
  • Sensitive or irreversible writes require confirm: true in every environment. In sandbox, the agent checks the effect and confirms without a user prompt. In live or unverified environments, the server also asks you through MCP elicitation. Without elicitation, CONFIRMATION_NEEDS_USER supplies an exact terminal command that prompts you; use the same credential and project directory. --allow-destructive permits agent confirmation in live or unverified environments.
  • dry_run: true validates a write without sending it and returns its effect, resource IDs, and formatted amounts. Required idempotency keys are checked even on dry runs. Reuse the same key for retries of the same request.
  • config set, config unset, and auth logout are unavailable through MCP.

The hosted docs MCP server is a different thing: it is read-only and serves documentation and schemas. Give an agent both to let it read the docs and act in your sandbox.

An agent that runs the CLI directly can discover the whole surface as JSON instead of scraping help text:

Shell
flint schema commands customers --output json
flint schema command payment-intents.create --output json
flint schema input payment-intents.create --output json
flint schema output payment-intents.create --output json
flint schema events --output json

It can list a group's commands, read the input schema of the one it needs, build the body, and validate it with --dry-run=client before making the call. AI agents covers prompts, SKILL.md, and the docs server.

MCP error codes#

When a tool call fails, read error.code and cli.next_actions in its JSON text result. An action with actor: "user" needs the person running the agent. When cli.outcome is unknown, check whether the write took effect before trying it again. Reuse the same idempotency key if you retry the same request.

When cli.origin is api, Flint passes through the API error and its remediation. When cli.origin is cli, the CLI reports argument validation as INVALID_REQUEST, with the input path in error.details[].param. Other local errors include the codes below. Call flint_help with {"topic":"errors"} for help from your installed version.

CodeWhat to do
UNKNOWN_OPERATIONFind the operation with flint_search. If the operation is newer than your CLI, upgrade the CLI.
OPERATION_NOT_AVAILABLERead the message and error.details[].reason when present. The server can recognize an operation that its configuration or credential cannot run.
UNKNOWN_EVENT_TYPECall flint_help with {"topic":"events"} and use an event type it lists.
UNDOCUMENTED_API_OPERATIONChoose an operation from the embedded API contract. Unknown raw API routes require terminal flint api.
INVALID_FLAG_VALUE, UNSUPPORTED_FLAG, CONFLICTING_FLAGSCheck the operation's arguments with flint_describe. Correct the named control or remove it if it is unsupported.
MERCHANT_SELECTION_PINNEDUse the merchant selected at server startup or ask the server owner to start it for the intended merchant.
LIVE_ACCESS_DISABLEDUse a sandbox credential or ask the server owner to explicitly enable live access.
LIVE_ACKNOWLEDGEMENT_REQUIREDAfter confirming the target environment, send live: true with the live call.
CONFIRMATION_REQUIREDReview the requested effect, then include confirm: true if you approve it.
CONFIRMATION_NEEDS_USERAsk the user to approve the operation. If the client lacks elicitation, the user can run the terminal command in cli.next_actions.
CONFIRMATION_DECLINEDApproval was not obtained. Stop the operation.
RESULT_TOO_LARGENarrow a read with filters, page_size, or select. If the result belongs to a write, check its outcome before retrying.
CLIENT_TIMEOUT, CLIENT_CANCELEDCheck the outcome before retrying a write. The request may have reached Flint before the timeout or cancellation.
CREDENTIAL_FORMAT_INVALIDCheck the credential configured for the server, then restart it with a supported credential.
SCHEMA_SNAPSHOT_INVALIDThe CLI could not read its embedded contract. Reinstall or upgrade the CLI.
MCP_COMMAND_FAILEDInspect the error message and follow cli.next_actions.

OPERATION_NOT_AVAILABLE can include one of these reasons:

ReasonMeaning
read_only_serverThe server started with --read-only. Writes and write dry runs require a server with write access.
outside_tool_scopeThe operation is outside the startup --tools selection. Ask the server owner to include it.
credential_typeThe credential or MCP tool set cannot call the operation. Use a supported credential or run the operation in the terminal if it is CLI-only.
wrong_toolUse the flint_read or flint_write tool named in the error. Use your original arguments when the suggested call contains redacted values.

Command reference#

CLI commands lists every command with its arguments, flags, examples, and API route. In the terminal, flint help lists starting points and resource groups, flint <resource> --help lists a group's commands, and flint <command> --help documents one command. flint schema commands --output json returns the full catalog for your installed version.

Next steps#

WebhooksRegister an endpoint and verify JWT or HMAC signatures in production.TestingTest cards, declines, disputes, refunds, and subscription clocks in a sandbox.SDKsThe same API from Node.js or PHP.

Was this helpful?