Sandboxes & test mode
A sandbox is where you build and test against Flint without moving money. Test and live traffic use the same API at the same hostname, https://api.withflintpay.com, and the key you send decides where a request runs. A flint_test_... key runs in test mode, in the one sandbox it's bound to. A flint_live_... key runs in live mode, against real money. Nothing else in the request selects the mode or the sandbox.
Every account starts with one sandbox, and a test key from the dashboard already works in it. Create more sandboxes to give CI or QA data of its own, and reset one to start over with clean test data.
Test mode and live mode#
| Test mode | Live mode | |
|---|---|---|
| Key prefix | flint_test_... | flint_live_... |
| Where it runs | The one sandbox the key is bound to | Your live account |
| Money | None moves. Card charges are simulated. | Real charges |
| Cards | Test cards only | Real cards |
Buyer emails are sent for real, with [Test] in the subject and a banner saying no money moved. Use your own team address. | Sent to your buyers | |
| Texts | Not sent. Codes confirm as described in Test codes in a sandbox. | Sent to your buyers |
| Response headers | Flint-Mode: test and Flint-Sandbox-Id: test_... | Flint-Mode: live |
Each sandbox can send buyer email to 100 distinct non-team recipients per UTC day across To and CC addresses. Repeat emails to the same address count once, ignoring letter case. After the limit, email can still go to team addresses and recipients already used that day; use your own team address to test without this limit. A team address is your merchant email, support email, or an active team member's email; matching ignores letter case.
Test and live data never mix. An order created with a test key doesn't exist for a live key or for a key bound to another sandbox. An ID created in a sandbox, such as a prod_... or whep_..., left in production configuration returns 404 RESOURCE_NOT_FOUND in live mode, so re-create your products, plans, and webhook endpoints when you go live.
What a sandbox is#
A sandbox is a self-contained test copy of your merchant account. Each one has its own orders, customers, products, saved payment methods, subscriptions, invoices, test clocks, webhook endpoints, merchant settings, risk and fulfillment settings, idempotency keys, and request logs. Nothing in one sandbox is visible from another. Your team access is shared across every environment.
Every merchant gets one sandbox automatically, named Default Test, with is_default: true. It can't be reset or archived, so treat it as your long-lived development sandbox and put disposable work in sandboxes you create.
Flint sets up test card payments in the default sandbox when the account is created, and in each sandbox you create when you create it. For a short time afterward, readiness.payments.status on GET /v1/merchant can be pending. Before relying on a sandbox for card payments, read it with a key for that sandbox and wait for ready; Testing shows the check.
Each test key is bound to exactly one sandbox when it's created, and that binding never changes. Every test-mode response carries a Flint-Sandbox-Id header naming the sandbox the request ran in, so you can always confirm which sandbox a key reaches.
If you're signed in to these docs, the test key filled into the code samples is bound to your default sandbox. It can create orders and take test payments, but it can't read or reset the sandbox, because it doesn't hold the developer.sandboxes scopes.
Catalog and environment copies skip promotion codes bound to a customer, so recreate the code for that customer in the target environment; promotions and unbound codes copy with their per-customer limit and rules.
Which environment a credential reaches#
Every credential is bound to one environment, live or one sandbox, when it's issued. That environment applies to every request the credential makes, and a request can't switch it: to work in another sandbox, send a credential bound to that sandbox. GET /v1/auth-context returns the mode and, in test mode, sandbox_id of the credential that sent the request.
| Credential | Environment | To work somewhere else |
|---|---|---|
Live key (flint_live_...) | Live | Issue a test key for the sandbox. |
Test key (flint_test_...) | The sandbox it was created for | Use a key bound to the other sandbox, or a live key for live. |
| Onboarding session token | The merchant's default sandbox, never live | Issue a key for the other sandbox. For live, create a live key or run flint login --live. |
| CLI OAuth access token | The one merchant and environment of its approved context | Select or approve another context; see CLI OAuth. |
Workload identity access token (fwat_...) | The identity's environment | Create an identity in the other environment; see workload identities. |
| Partner app token | The token's mode. Flint-Merchant-Id selects the merchant, and its grant for that mode fixes the sandbox in test mode. Flint-Sandbox-Id, if sent, must name that sandbox | Mint a token for the other mode, or have the merchant authorize the install there; see partner app installs. |
The onboarding session token acts in the default sandbox, and it can also manage the merchant's sandboxes during setup, as Managing sandboxes describes.
When to create another sandbox#
Create a sandbox for each use whose data must not mix with another's. A common split is your default sandbox for local development, one sandbox for CI, and one for QA or partner testing. Each has its own customers, catalog, and webhook endpoints, and resetting one leaves the others untouched.
Two CI pipelines that run at the same time need a sandbox each. A reset deletes the sandbox's data, so one run's reset would delete the customers, orders, and payments the other run is using, and the other run's requests get 409 OPERATION_IN_PROGRESS while the reset runs.
Sandbox names are unique among your active sandboxes. Archiving a sandbox frees its name.
Managing sandboxes#
You can manage sandboxes on the dashboard's Sandboxes page, which the environment menu in the top bar links to as Manage sandboxes, or over the API:
Listing, creating, and archiving sandboxes take a live credential. A test credential (a test key, a sandbox CLI login, or a sandbox workload token) can read and reset only its own sandbox:
| Route | Live credential | Test credential |
|---|---|---|
GET /v1/sandboxes | Any sandbox of the merchant | 403 FORBIDDEN, reason live_mode_required |
POST /v1/sandboxes | Creates a sandbox | 403 FORBIDDEN, reason live_mode_required |
GET /v1/sandboxes/{sandbox_id} | Any sandbox of the merchant | Its own sandbox. Any other sandbox_id returns 404 RESOURCE_NOT_FOUND, whether or not it exists |
POST /v1/sandboxes/{sandbox_id}/reset | Any sandbox of the merchant | Its own sandbox. Any other sandbox_id returns 404 RESOURCE_NOT_FOUND |
DELETE /v1/sandboxes/{sandbox_id} | Any sandbox except the default | 403 FORBIDDEN, reason live_mode_required |
Reading needs developer.sandboxes.read or developer.sandboxes.write, and creating, resetting, and archiving need developer.sandboxes.write. Both scopes are available to live and test keys, and full-access keys of either mode hold them. Test keys for an existing sandbox come from POST /v1/api-keys with its sandbox_id.
A request that issues a test key also needs accounts.api_keys.write, and what the new key's access can be depends on the caller:
- With
accessrestricted, the live key must hold every scope it grants, because a key can delegate only scopes it holds. - Granting
fullorread_only, oraccounts.api_keys.write,accounts.workload_identities.write,commerce.gift_cards.secrets.write, orcommerce.license_keys.secrets.write, takes a full-access live key or a freshly verified onboarding session token, as described next. A restricted key can't grant those scopes even when it holds them; see credentials that can mint keys.
During API-first setup, the onboarding session token can call the same routes when its user is a merchant owner or admin. Other users get 403 FORBIDDEN with reason merchant_role_insufficient when they create, reset, or archive. The session can grant full, read_only, or scopes outside the low-risk read allowlist within 300 seconds of email verification. After that, those grants return 403 IDENTITY_VERIFICATION_REQUIRED with the verification time in details[0].verified_at. Verify the email again, then retry.
Create a sandbox#
Send a name. To get a test key bound to the new sandbox in the same response, add issue_test_key: true with the key's access, and scopes when access is restricted. The response carries the new key once, with its secret. test_key_name is optional and defaults to the sandbox name followed by Test Key. test_key_expires_at is optional: a future RFC 3339 time when the key stops working, validated like expires_at on POST /v1/api-keys. Without issue_test_key, sending access, scopes, test_key_name, or test_key_expires_at returns 400 INVALID_REQUEST with details[0].code NOT_ALLOWED.
initial_onboarding sets the onboarding state the sandbox starts in, and returns to when you reset it. The sandbox echoes it in every response.
complete, the default: Flint verifies the sandbox's test account with test identity data, so it can take test card payments without anyone onboarding.not_started: Flint prefills nothing, and requirements stay due. Use it to rehearse onboarding, such as building an embedded onboarding UI. Readiness reportsonboarding_not_startedwith thecreate_merchant_account_sessionaction until you run the onboarding loop with a key for the sandbox and enter the sandbox verification values.
curl -X POST https://api.withflintpay.com/v1/sandboxes \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_LIVE_API_KEY" \
-H "Idempotency-Key: create-ci-sandbox" \
-d '{
"name": "CI",
"issue_test_key": true,
"test_key_name": "ci-runner",
"access": "restricted",
"scopes": ["commerce.orders.read", "commerce.orders.write", "merchants.profile.read"]
}'
{
"data": {
"sandbox": {
"sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
"name": "CI",
"status": "active",
"is_default": false,
"initial_onboarding": "complete",
"reset_failed_at": null,
"created_at": "2026-08-30T09:15:07Z",
"updated_at": "2026-08-30T09:15:07Z"
},
"api_key": {
"api_key_id": "key_01KWJS8006FVHT8CRWDKBWA1T9",
"name": "ci-runner",
"key_prefix": "flint_test_2686d60a",
"sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
"access": "restricted",
"scopes": ["commerce.orders.read", "commerce.orders.write", "merchants.profile.read"],
"status": "active",
"version": 1,
"created_at": "2026-08-30T09:15:07Z"
},
"secret_key": "flint_test_2686d60a..."
},
"request_id": "req_01KWM6AKTD5FEMEYXE1VFP5843"
}
data.sandbox.sandbox_id is the ID the reset, archive, and API keys routes take. data.api_key and data.secret_key are present exactly when issue_test_key is true; otherwise data holds only sandbox.
Warning: Save secret_key now
secret_key is the new test key, and only this response shows it. A replay with the same Idempotency-Key returns it only under the rules for responses with one-time secrets. If you lose it, issue another key for the sandbox.
A new sandbox starts empty, with no catalog, customers, or webhook endpoints. Confirm the key reaches it with GET /v1/auth-context, which API keys, CLI logins, workload identities, partner apps, and onboarding sessions can call:
curl -i https://api.withflintpay.com/v1/auth-context \
-H "Authorization: Bearer YOUR_NEW_TEST_KEY"
HTTP/1.1 200 OK
Flint-Mode: test
Flint-Sandbox-Id: test_01KWJS7ZW5YAC86HMHWTCV93GX
Then, before the first card payment, read GET /v1/merchant with the new key until readiness.payments.status is ready. That read needs merchants.profile.read, which is why the example key holds it.
Issue a key for an existing sandbox#
A sandbox can have many test keys, for example one per developer or one per CI run. Create them with POST /v1/api-keys and the sandbox's sandbox_id, from a live credential or a Dashboard session. Send access restricted with scopes for a key whose scopes never change, or, from a full-access live key or a freshly verified session, full or read_only for a key that holds every test-mode scope of that access level, including scopes Flint adds later. name is required and expires_at is optional, as for any key.
curl -X POST https://api.withflintpay.com/v1/api-keys \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_LIVE_API_KEY" \
-H "Idempotency-Key: local-dev-key-maria" \
-d '{
"name": "local-dev-maria",
"access": "full",
"sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX"
}'
{
"data": {
"api_key_id": "key_01KWJS80E4G3CYMKRA955524FF",
"name": "local-dev-maria",
"key_prefix": "flint_test_ca7f32e8",
"secret_key": "flint_test_ca7f32e8...",
"sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
"access": "full",
"scopes": ["accounts.api_keys.read", "accounts.api_keys.write", "commerce.orders.read", "commerce.orders.write", "merchants.profile.read"],
"status": "active",
"version": 1,
"created_at": "2026-08-30T09:20:41Z"
},
"request_id": "req_01KWM6RFA74M15JRQMQ33B80M6"
}
scopes lists what the key holds today, shortened here. A full-access test key never holds the live-only scopes, such as developer.partner_apps.write, and holds developer.sandboxes.write, which reaches only its own sandbox. Asking for a live-only scope on a restricted test key returns 400 INVALID_REQUEST with details[0].code NOT_ALLOWED and param scopes.
secret_key is shown only in this response, as with sandbox creation. sandbox_id must be the sandbox's public ID; an unknown ID returns 404 RESOURCE_NOT_FOUND and an archived sandbox 409. A test key that holds accounts.api_keys.write can create keys only in its own sandbox: it may omit sandbox_id or send its own, and any other sandbox returns 404. An onboarding session must send sandbox_id, and can name any of the merchant's active sandboxes. Any key is revoked with POST /v1/api-keys/{api_key_id}/revoke; see Manage keys over the API.
List and look up sandboxes#
GET /v1/sandboxes returns active sandboxes, the default sandbox first and then the newest. Archived sandboxes are left out unless you ask for them with status=archived, or status=active,archived for both. Page with page_size, up to 100, and the next_page_token from the previous response, sent back as page_token with the same status filter.
curl "https://api.withflintpay.com/v1/sandboxes" \
-H "Authorization: Bearer YOUR_LIVE_API_KEY"
{
"data": [
{
"sandbox_id": "test_01KNB061AGD0CYYF16M5QAQE3N",
"name": "Default Test",
"status": "active",
"is_default": true,
"initial_onboarding": "complete",
"reset_failed_at": null,
"created_at": "2026-05-12T16:02:41Z",
"updated_at": "2026-05-12T16:02:41Z"
},
{
"sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
"name": "CI",
"status": "active",
"is_default": false,
"initial_onboarding": "complete",
"reset_failed_at": null,
"created_at": "2026-08-30T09:15:07Z",
"updated_at": "2026-08-30T09:15:07Z"
}
],
"request_id": "req_01KWM6X5TT92MDR6WJFK1G6593"
}
GET /v1/sandboxes/{sandbox_id} returns one sandbox, including an archived one. A sandbox has two statuses:
status on sandboxReset a sandbox#
A reset deletes the sandbox's data and keeps its identity and connections.
A reset keeps the sandbox_id, name, is_default, and initial_onboarding; every credential bound to the sandbox, including API keys, workload identities, CLI logins, and connected app installs; its webhook endpoints, with the same IDs, URLs, events, API versions, and signing secrets; its test payment account and payment readiness; its payment method, checkout, and custom domains; and its processing fee assignments.
It deletes everything else, including the catalog, customers, orders, payments, invoices, subscriptions, test clocks, settings, locations, risk lists, request logs, events, deliveries, and idempotency keys.
When initial_onboarding is not_started, the sandbox also returns to not_started: it loses its test payment account and its onboarding starts over, even if you finished onboarding before the reset. Check readiness.payments before the first payment, as you would for a new sandbox.
Reset with a live key, or with a test key bound to the sandbox that holds developer.sandboxes.write:
curl -X POST https://api.withflintpay.com/v1/sandboxes/test_01KWJS7ZW5YAC86HMHWTCV93GX/reset \
-H "Authorization: Bearer YOUR_TEST_API_KEY" \
-H "Idempotency-Key: reset-ci-2026-09-04"
{
"data": {
"sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
"name": "CI",
"status": "active",
"is_default": false,
"initial_onboarding": "complete",
"reset_failed_at": null,
"created_at": "2026-08-12T09:02:11Z",
"updated_at": "2026-09-04T14:20:33Z"
},
"request_id": "req_01KWM6ZHRMW9K5XV66R5X74VRN"
}
The response is the same sandbox, with status active and a new updated_at. A reset takes a few seconds, and the request returns once it finishes:
- Requests during a reset. A request that starts while the reset runs, with any credential bound to the sandbox or naming it in
sandbox_id(such as minting a key for it), gets409 OPERATION_IN_PROGRESSwithdetails[0].reasonsandbox_resettingand aRetry-Afterheader. Send the same request again afterRetry-After; it then runs against the reset sandbox. The SDKs and the CLI retry it for you. - Requests already running. A request that started before the reset finishes against the old data, and its result doesn't survive the reset. Its response can reach you after the reset returns.
- Webhooks. Deliveries and scheduled retries of events from before the reset stop with
suppression_reasonsandbox_reset, except for one attempt that may already be sending. Event streams end with adisconnectframe with reasonsandbox_reset; reconnect to stream the reset sandbox's events. A reset sends no event of its own. - Idempotency. A retry with the same
Idempotency-Keywithin 24 hours returns the recorded response without resetting again. After 24 hours, the same key resets the sandbox again. A request with a new key resets the sandbox again, or resumes a reset that stopped after deletion started. Idempotency keys that the sandbox's credentials sent before the reset don't replay their old responses. - Concurrent resets. A second reset, or an archive, while a reset runs gets
409 OPERATION_IN_PROGRESSwithRetry-After. - Reset limit. Each sandbox can be reset once every 10 seconds and 500 times per UTC day. The limit is shared by every credential that can reset the sandbox. Past it, the request gets
429 RATE_LIMIT_EXCEEDEDwithRetry-After. A retry with the sameIdempotency-Keydoesn't count again.
After a reset, re-create the products, plans, customers, test clocks, and anything else your tests depend on. IDs from before the reset return 404 RESOURCE_NOT_FOUND, and checkout links and payment links from before the reset stop working.
The default sandbox resets like any other and stays the default. Its keys, including the key filled into these docs, keep working, and so do onboarding sessions and the Dashboard.
Give CI a clean sandbox for each run#
Reset one dedicated sandbox at the start of each run, rather than creating and archiving a sandbox per run. A reset keeps the sandbox's ID, keys, webhook endpoints, and test payment account, while a new sandbox needs its payments set up first. CI needs one secret: a test key bound to the sandbox that holds developer.sandboxes.write and the scopes your tests need. No live key is involved.
With the Node SDK, the reset step uses the same test key the tests use:
import { Client } from "@flintpay/node";
const flint = new Client({
baseUrl: "https://api.withflintpay.com",
apiKey: process.env.FLINT_API_KEY!,
});
const runId = process.env.CI_RUN_ID!;
// The key's own sandbox. The ID stays the same across resets.
const context = await flint.authContext.get();
await flint.sandboxes.reset(context.sandbox_id!, {}, {
idempotencyKey: `ci-reset-${runId}`,
});
// The tests keep using FLINT_API_KEY against the clean sandbox.
If a retried reset step uses a new idempotency key, it resets the sandbox again, which is harmless at the start of a run.
Failed resets retry after 1, 2, 4, 8, 16, 32, and 60 minutes. Flint allows at most eight attempts, counting each when it starts, including interrupted attempts. If none succeeds, Flint stops retrying and sets reset_failed_at on the sandbox:
- If deletion has not started, the sandbox keeps its previous data and credentials and accepts requests again. You can reset it again or archive it.
- If deletion has started, requests return
409 ACTION_NOT_ALLOWEDwith reasonsandbox_reset_failed, withoutRetry-After. Send anotherPOST /v1/sandboxes/{sandbox_id}/resetwith a new idempotency key to resume the reset. You can also archive a non-default sandbox with a live credential; both sets of data are then deleted in the background. Credential events wait until you retry or archive.
A successful reset clears reset_failed_at. Otherwise the timestamp records the last reset that stopped. null means no reset has stopped, or a later reset succeeded. The sandbox's status remains active until you archive it.
Archive a sandbox#
Archive a sandbox you no longer need. Its status becomes archived, every key bound to it returns 401 INVALID_CREDENTIAL with details[0].reason revoked, and its name is freed for a new sandbox. Flint renames the archived sandbox to its old name followed by (Archived and the last eight characters of its ID.
curl -X DELETE https://api.withflintpay.com/v1/sandboxes/test_01KWJS7ZW5YAC86HMHWTCV93GX \
-H "Authorization: Bearer YOUR_LIVE_API_KEY" \
-H "Idempotency-Key: archive-qa-sandbox"
{
"data": {
"sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
"name": "CI (Archived WTCV93GX)",
"status": "archived",
"is_default": false,
"initial_onboarding": "complete",
"reset_failed_at": null,
"created_at": "2026-08-30T09:15:07Z",
"updated_at": "2026-09-04T15:02:18Z"
},
"request_id": "req_01KWM6DADJQCCSXYM48KKWKZJM"
}
There is no unarchive. To keep working under the same name, create a new sandbox. Archiving an already archived sandbox returns 409 ACTION_NOT_ALLOWED with reason archived, and archiving the default sandbox returns 409 ACTION_NOT_ALLOWED with reason unsupported_state.
The sandbox-bound key requirement#
Every test key must be bound to a sandbox. A test key with no sandbox binding can't authenticate any request, and Flint returns 401 instead of guessing which sandbox you meant:
{
"error": {
"type": "authentication_error",
"code": "INVALID_CREDENTIAL",
"message": "Test mode API keys must be sandbox-bound before they can authenticate public API requests.",
"request_id": "req_01KWM6NQTTNZHEZRM8YQJXCEBV",
"details": [
{
"code": "INVALID_CREDENTIAL",
"message": "Test mode API keys must be sandbox-bound before they can authenticate public API requests.",
"reason": "mode_mismatch"
}
]
}
}
The error's remediation.next_actions names the fix, issue_developer_sandbox_test_key. Replace the key with one bound to a sandbox: create it on the dashboard's API keys page with that sandbox selected in the environment menu, or issue one with a live key.
Errors#
From the CLI#
The CLI reads the mode from the credential. Listing, creating, and archiving take a live credential, and a live API key needs --live on each command. A test credential resets its own sandbox without --live:
flint sandboxes list --live
flint sandboxes create --name qa-scenarios --live
flint sandboxes create --name ci --access restricted --issue-test-key true --scopes developer.sandboxes.write --scopes merchants.profile.read --live
# In CI, with FLINT_API_KEY set to the sandbox's test key:
flint sandboxes reset test_01KWJS7ZW5YAC86HMHWTCV93GX --confirm
To issue a key while creating a sandbox, pass --issue-test-key true and choose --access explicitly. In the Node SDK, the same routes are on sandboxes: list, get, create, reset, and delete. Test keys for an existing sandbox come from apiKeys.create with sandbox_id.