API key security
Every Flint API key acts as your merchant with every scope it holds, and a flint_live_ key moves real money. Keep your keys on your server, limit what each one can do, rotate them without downtime, and know what to do the moment one leaks. To send a key and read the authentication errors, see Authentication.
Keep keys on your server#
Flint has no publishable key. Every flint_test_ and flint_live_ key is a secret key, so it belongs only in server-side code and server-side configuration.
Important: Never put a key in client code
Anything you ship to a browser, mobile app, or desktop client is public, however it is obfuscated. Treat a key that has appeared in frontend JavaScript, a mobile binary, or a public repository as leaked, and revoke it.
Buyer-facing flows never need a key on the buyer's device:
- Hosted checkout and payment links send the buyer to a Flint page at the session's or link's
url, which your server creates. See Checkout sessions. - Embedded payments mount Stripe Elements from the order's
payment_collection, which holds no secrets. The browser sends a single-use Stripe credential to your backend, and your backend calls Flint. See Embedded payments. - Headless checkout and customer accounts run through your backend, which holds the checkout credential or customer session secret and relays only the calls your pages need. See Headless checkout security.
If your frontend needs data that only your key can read, add a server endpoint that fetches it. Don't move the key to the client.
Know which values are secret#
The first four values below are secrets. The last three are identifiers: use them in logs, dashboards, alerts, and support requests to name a credential without exposing it.
| Value | Looks like | If someone else gets it |
|---|---|---|
| API key | flint_test_..., flint_live_... | They can call the API as your merchant with every scope the key holds |
| Webhook signing secret | whsec_... | They can sign fake deliveries that your HMAC webhook handler accepts as real |
| Checkout credential | ckat_... | They can change and pay one checkout session's order |
| Customer session secret and refresh token | flint_cses_..., flint_cref_... | They can act as one buyer on /v1/me |
| API key ID | key_... | Nothing. Safe to log |
Key prefix, key_prefix | flint_live_5c1e9a07 | Nothing. Safe to log; it matches the start of the secret so you can tell keys apart |
| Webhook endpoint ID | whep_... | Nothing. Safe to log |
Secrets never belong in logs, error messages, analytics events, tickets, screenshots, or prompts to AI tools. Your requests to Flint carry their credential in the Authorization header, so redact that header in your request logging, proxies, and error reporters.
Flint stores only a hash of each API key, so the full secret_key appears only in the response that creates the key, and in an idempotent replay of that same create request. Flint can't show it again. If you lose a key, create a replacement and revoke the old one.
Store keys outside your code#
Load keys from the environment or a secrets manager, such as AWS Secrets Manager, Vault, Doppler, or your platform's equivalent, and keep the values out of the repository:
# .env (never committed)
FLINT_API_KEY=flint_live_...
FLINT_WEBHOOK_SECRET=whsec_...
# .gitignore
.env
.env.*
Warning: Public env vars ship to the browser
Frontend bundlers compile variables with a public prefix, such as VITE_, NEXT_PUBLIC_, REACT_APP_, PUBLIC_, or EXPO_PUBLIC_, into the JavaScript they ship, where anyone can read them. Never give a Flint secret one of those prefixes. Name it FLINT_API_KEY and read it only in server code.
Where the key runs decides where it should live:
- CI and cloud workloads. If the runner can get an OIDC token, use a workload identity instead of a stored key. The runner exchanges its token for a Flint access token that expires within an hour, so there is no long-lived secret to leak. Otherwise, keep the key in the CI provider's secret store and make sure job logs mask it.
- Local development.
flint auth importfrom the CLI stores a key in your OS keychain instead of a dotfile. - Servers. Inject the key at deploy time from your secrets manager.
Treat a committed key as leaked. Deleting it in a later commit doesn't remove it from history, clones, forks, or CI caches, and automated scanners watch public repositories for new secrets. This applies to private repositories too: revoke the key rather than rewriting history.
Scan for Flint prefixes. Add secret scanning to pre-commit hooks and CI, with a rule for each prefix in this table. Each one is a bearer secret: anyone who holds it can use it until it expires or you revoke it.
| Starts with | Credential | Lifetime |
|---|---|---|
flint_test_, flint_live_ | API key | Until you revoke it or its expires_at passes |
whsec_ | Webhook signing secret | Until you rotate it |
fps_ | Partner app client secret | Until you rotate it; the previous secret keeps working for 24 hours by default |
devsess_v1. | Onboarding session token | 24 hours, with no refresh |
devver_v1. | Email verification token during onboarding | 15 minutes |
ckat_v1. | Checkout credential (checkout_auth_token) | 30 days |
cklt_v1. | Checkout launch token in a checkout URL's checkout_token fragment | 30 days, or 5 minutes when Flint issues it after a payment provider redirect |
flint_cses_ | Customer session secret | 1 hour by default, from 5 minutes to 24 hours, and never past the session's refresh expiry |
flint_cref_ | Customer session refresh token | Single use; 7 days by default, from 1 hour to 30 days |
fcat_ | CLI access token | 15 minutes at most |
fcrt_ | CLI refresh token | Replaced on each refresh; the session ends 30 days after its last token was issued, or 90 days after login |
fwat_ | Workload identity access token | 1 hour at most |
fpat_ | Partner app token | 900 seconds; partner apps mint a new one, with no refresh token |
aslaunch_v1. | Merchant account session launch token | 4 hours |
Scope keys to the job#
A key's scopes decide what a leak costs. Give each workload its own key, named for where it runs and holding only the scopes that job needs:
- One key per service or integration, such as "Storefront backend", "Reporting worker", or "CI runner". When one leaks you revoke it without touching the others, and each key's
last_used_atdescribes a single workload. - A
restrictedkey for production. It holds exactly thescopesyou list, and Flint never adds more. Afullkey gains every scope Flint adds for its mode, including key management, and aread_onlykey gains every new read scope. Both suit a local development or agent key you control. See Key access. - Only the scopes the job calls. Each operation in the API reference lists the scopes it accepts. A write scope satisfies its matching read scope where the scope catalog says so, so
commerce.orders.writealso coverscommerce.orders.read. - No management scopes on application keys. A key with
accounts.api_keys.writecan mint new keys, and one withwebhooks.writecan point events at a new URL. Manage keys from the dashboard's API keys page or the CLI signed in as you, and leave those scopes off the keys your services run with.
A key can't grant more than it has. Over the API, a key can grant only scopes it holds, and can update or revoke only keys whose scopes it holds; otherwise the request returns 403 INSUFFICIENT_SCOPE. Only a freshly verified Dashboard or onboarding session, or a full key in the new key's mode, can grant full or read_only, or accounts.api_keys.write, accounts.workload_identities.write, commerce.gift_cards.secrets.write, or commerce.license_keys.secrets.write. A restricted key can't pass on key management even when it holds accounts.api_keys.write. So a leaked restricted key can't mint a broader one, or another key that mints keys. See credentials that can mint keys.
A reporting service that reads orders and payments needs two scopes. Create its key with a credential that holds accounts.api_keys.write and both scopes:
curl -X POST https://api.withflintpay.com/v1/api-keys \
-H "Authorization: Bearer $FLINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Reporting worker",
"access": "restricted",
"scopes": ["commerce.orders.read", "payments.payment_intents.read"]
}'
{
"data": {
"api_key_id": "key_01KX3V8Q2M5T7R9B4N6C1D3F5H",
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"name": "Reporting worker",
"key_prefix": "flint_live_5c1e9a07",
"secret_key": "flint_live_5c1e9a07...",
"access": "restricted",
"scopes": ["commerce.orders.read", "payments.payment_intents.read"],
"status": "active",
"partner_app_install_id": null,
"created_by": {
"resource_type": "user",
"resource_id": "usr_01K0P7W6A4N9F3J2T8Q5R1C6XM"
},
"version": 1,
"created_at": "2026-10-28T15:04:05Z",
"updated_at": "2026-10-28T15:04:05Z"
},
"request_id": "req_01KX3V8Q9D2F4H6J8K0M2N4P6R"
}
Store secret_key in your secrets manager now. The new key is minted in the calling key's mode: a live key creates live keys, and a test key creates keys bound to its own sandbox. If this key leaks, the holder can read order and payment data. They can't create refunds, change payouts, or issue new keys.
Link keys you give to platforms#
When a connected platform needs an API key, create a restricted key with partner_app_install_id set to that platform's install. Revoking the install then revokes the key and deletes merchant webhook endpoints linked to the same install. Without a link, removing the app leaves the key and its endpoints working until you separately revoke or delete them.
Set the link only at creation, with a live credential or a Dashboard session. The install must be active and authorized for the key's environment. Each install can have up to 25 active linked keys and 25 linked endpoints per environment. Don't send null on create; omit the field for a key you intend to keep independent of an app.
Keys and endpoints a linked key creates inherit its link. Linked keys can't create workload identities, partner app client credentials, customer access links, or delivery rate callbacks. They also can't create a sandbox with issue_test_key: true, rotate a partner app's client secret, regenerate an invoice public link, or copy webhook endpoints. Workload identity updates that change the subject, claim conditions or scopes, or reactivate the identity, are refused too. See linked-key restrictions.
Reinstalling an app doesn't restore its old keys or endpoints. When replacing a linked key from a credential that isn't itself linked, set the same install ID on the replacement. What revoking an install ends covers environment grants and unlinked access you still need to end.
Expire temporary keys#
A contractor's engagement, a one-off migration script, a load test, or a demo has an end date. Set expires_at when you create the key, and it stops authenticating on schedule whether or not anyone remembers it:
curl -X POST https://api.withflintpay.com/v1/api-keys \
-H "Authorization: Bearer $FLINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Catalog migration",
"access": "restricted",
"scopes": ["commerce.products.write"],
"expires_at": "2026-12-01T00:00:00Z"
}'
expires_atis an RFC 3339 timestamp in the future. A past time or an unparseable value returns400 INVALID_REQUESTwithparamexpires_at. Omit it and the key never expires.- When the time passes, the key's
statusbecomesexpiredand every request with it returns401 INVALID_CREDENTIALwithdetails[0].reasonexpired. - If the work runs long,
PATCH /v1/api-keys/{api_key_id}with a laterexpires_atextends the key, and a futureexpires_atreactivates a key that has already expired. Send"expires_at": nullto remove the expiry. A revoked key can't be updated.
curl -X PATCH https://api.withflintpay.com/v1/api-keys/key_01KX4A2B6C8D0E2F4G6H8J0K2M \
-H "Authorization: Bearer $FLINT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"expires_at": "2026-12-15T00:00:00Z"}'
Rotate keys without downtime#
Rotation limits how long a key that leaked without anyone noticing stays useful. API keys have no rotate endpoint. You create a replacement, deploy it, and revoke the old key, and both keys authenticate during the switchover, so traffic never stops:
Instead of revoking in the last step, you can set the old key's expires_at to the end of your rollout window. It stops working on schedule even if nobody comes back to revoke it.
Rotate whenever someone with access to production secrets leaves, and after a security incident at a vendor that held the key, such as your CI provider, log aggregator, or host. A fixed schedule on top of that, such as every quarter, keeps rotation routine.
Audit your keys#
last_used_at makes a periodic audit quick. List active keys with the least recently used first. Keys that have never been used have no last_used_at and sort before the rest:
curl "https://api.withflintpay.com/v1/api-keys?status=active&sort_by=last_used_at&sort_direction=asc" \
-H "Authorization: Bearer $FLINT_API_KEY"
{
"data": [
{
"api_key_id": "key_01KWK4Q8Z1MB7F0T2S9R3V6HAX",
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"name": "Load test (March)",
"key_prefix": "flint_live_9f8e7d6c",
"access": "restricted",
"scopes": ["commerce.orders.write"],
"status": "active",
"partner_app_install_id": null,
"last_used_at": "2026-03-30T16:41:22Z",
"created_by": {
"resource_type": "user",
"resource_id": "usr_01K0P7W6A4N9F3J2T8Q5R1C6XM"
},
"version": 1,
"created_at": "2026-03-12T08:30:00Z",
"updated_at": "2026-03-12T08:30:00Z"
},
{
"api_key_id": "key_01KWJ93G11C7MF8REX91MDS0CD",
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"name": "Storefront backend",
"key_prefix": "flint_live_1a2b3c4d",
"access": "restricted",
"scopes": ["commerce.orders.write", "payments.payment_intents.write"],
"status": "active",
"partner_app_install_id": null,
"last_used_at": "2026-10-28T09:14:07Z",
"created_by": {
"resource_type": "user",
"resource_id": "usr_01K0P7W6A4N9F3J2T8Q5R1C6XM"
},
"version": 2,
"created_at": "2026-04-18T12:00:00Z",
"updated_at": "2026-06-02T10:00:00Z"
}
],
"next_page_token": "eyJjIjoia2V5XzAxS1dKOTMifQ",
"request_id": "req_01KX3VB1C3E5G7J9K1M3P5R7T9"
}
A key holder sees only keys in its own mode: a live key lists live keys, and a test key lists keys bound to its sandbox. Follow next_page_token until it is absent to see every key. The first key here was made for a load test in March and hasn't been used since. A key nobody uses can only cause harm, so revoke it:
curl -X POST https://api.withflintpay.com/v1/api-keys/key_01KWK4Q8Z1MB7F0T2S9R3V6HAX/revoke \
-H "Authorization: Bearer $FLINT_API_KEY"
Webhook signing secrets#
New webhook endpoints sign deliveries with JWTs that you verify against Flint's public keys, so they have no shared secret to protect. An endpoint whose signing_methods include hmac has its own whsec_ secret, one per endpoint. A leaked whsec_ doesn't let anyone call your API, but it lets them sign fake events that your handler accepts, such as an order.paid that makes a fulfillment handler ship an unpaid order. Store whsec_ values like keys, and rotate them as soon as one may have leaked.
Secrets belong to one endpoint, and endpoints belong to one mode. A sandbox endpoint's secret doesn't verify deliveries to your live endpoint, so register the live endpoint when you go live and deploy its secret. Webhooks covers signature verification, raw-body handling, and rotation in practice.
If a key leaks#
Subscribe to api_key.created, api_key.updated, and api_key.revoked to monitor credential changes. Events include the key's created_by reference and never include its secret. Register endpoints in each sandbox you monitor and in live mode. Passing expires_at sends no event. See API key events.
Run this playbook for a key committed to a repository, pasted into a ticket or chat, printed in a build log, or one you can't account for. A few minutes of errors while you deploy a replacement can be fixed; an attacker holding a live key can move money. If you're unsure whether a key leaked, revoke it anyway.
If a session or mailbox leaks#
An onboarding session token (devsess_v1.), a CLI login, or access to the mailbox you sign in with acts as you, not as a key. Its requests and the keys it creates are recorded with your user ID (usr_...) as the user caller and creator, the same as your Dashboard writes:
- Secure the mailbox, and sign out of the Dashboard and the CLI. An onboarding session can't be ended early; it stops working 24 hours after it was issued.
- Review its requests with
GET /v1/api-request-logs?caller_type=user&caller_id=usr_...in each environment. Onboarding session requests are logged in the default sandbox, apart from sandbox management requests, which are logged in live mode. - List the keys accountable to that user with
GET /v1/api-keys?created_by_user_id=usr_...in each environment, or on the Dashboard's API keys page, and revoke any you didn't make. The filter includes keys their API keys or workload identities created. Then follow Remove what it created for each revoked key. - Review sandboxes you didn't create on the Dashboard's Sandboxes page, and archive them, which revokes their keys.
Flint has no cascading revoke: revoking a key or ending a session leaves what it created working until you revoke each item.
Errors#
These are the errors key handling produces. The Authentication guide lists every authentication error.
Checklist#
- Keys live in server-side environment variables or a secrets manager, never in code, client bundles, or commits.
- CI and cloud workloads use workload identities where they can, and otherwise the provider's secret store with masked logs.
- Secret scanning watches commits for every Flint secret prefix.
- Each service has its own
restrictedkey, named for where it runs, with only the scopes it calls and no key or webhook management scopes. - Temporary access has an
expires_at. - Rotation has an owner and a schedule, and also runs when people leave and after vendor incidents.
- Keys with a stale
last_used_atget revoked. whsec_secrets are stored and rotated like keys.- Everyone on call knows how to revoke a key from the dashboard.