Skip to content

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 modeLive mode
Key prefixflint_test_...flint_live_...
Where it runsThe one sandbox the key is bound toYour live account
MoneyNone moves. Card charges are simulated.Real charges
CardsTest cards onlyReal cards
EmailBuyer emails are sent for real, with [Test] in the subject and a banner saying no money moved. Use addresses you control.Sent to your buyers
TextsNot sent. Codes confirm as described in Test codes in a sandbox.Sent to your buyers
Response headersFlint-Mode: test and Flint-Sandbox-Id: test_...Flint-Mode: live

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 organization and its memberships are 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 manage sandboxes, because that takes a live key.

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 environment and sandbox_id of the credential that sent the request.

CredentialEnvironmentTo work somewhere else
Live key (flint_live_...)LiveIssue a test key for the sandbox.
Test key (flint_test_...)The sandbox it was created forUse a key bound to the other sandbox, or a live key for live.
Onboarding session tokenThe merchant's default sandbox, never liveIssue a key for the other sandbox. For live, create a live key or run flint login --live.
CLI OAuth access tokenThe one merchant and environment of its approved contextSelect or approve another context; see CLI OAuth.
Workload identity access token (fwat_...)The identity's environmentCreate an identity in the other environment; see workload identities.
Partner install tokenThe install's grant: one sandbox in test mode, or liveAuthorize the install for the other mode or sandbox; 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 revokes every key bound to the sandbox, so one run's reset would break the other's requests.

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:

  • GET/v1/sandboxesRequired API key scopes: developer.sandboxes.read or developer.sandboxes.writeReference for GET /v1/sandboxes

    Lists active sandboxes, or archived ones with status=archived.

  • POST/v1/sandboxesRequired API key scope: developer.sandboxes.writeReference for POST /v1/sandboxes

    Creates an empty sandbox, and with issue_test_key: true, a test key bound to it.

  • GET/v1/sandboxes/{sandbox_id}Required API key scopes: developer.sandboxes.read or developer.sandboxes.writeReference for GET /v1/sandboxes/{sandbox_id}

    Returns one sandbox, active or archived, with its reset links.

  • POST/v1/sandboxes/{sandbox_id}/api-keysRequired API key scopes: accounts.api_keys.write and developer.sandboxes.writeReference for POST /v1/sandboxes/{sandbox_id}/api-keys

    Issues a test key bound to an active sandbox.

  • POST/v1/sandboxes/{sandbox_id}/resetRequired API key scope: developer.sandboxes.writeReference for POST /v1/sandboxes/{sandbox_id}/reset

    Clears a sandbox you created and returns its replacement.

  • DELETE/v1/sandboxes/{sandbox_id}Required API key scope: developer.sandboxes.writeReference for DELETE /v1/sandboxes/{sandbox_id}

    Archives a sandbox you created.

These routes take a live credential. A test key can't manage sandboxes, including its own: on any of these routes it gets 403 FORBIDDEN with details[0].reason live_mode_required. The developer.sandboxes.read and developer.sandboxes.write scopes exist only on live keys. Reading needs either one, and creating, resetting, archiving, and issuing keys need developer.sandboxes.write.

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 access restricted, the live key must hold every scope it grants, because a key can delegate only scopes it holds.
  • Granting full or read_only takes a full-access live key; see who can grant full or read-only access.

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.

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. test_key_name is optional and defaults to the sandbox name followed by Test Key. Without issue_test_key, sending access, scopes, or test_key_name returns 400 INVALID_REQUEST with details[0].code NOT_ALLOWED.

cURL
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"]
  }'
JSON
{
  "data": {
    "sandbox": {
      "sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
      "name": "CI",
      "status": "active",
      "is_default": false,
      "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 within 24 hours and only while the key still works; see 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 every credential can call:

cURL
curl -i https://api.withflintpay.com/v1/auth-context \
  -H "Authorization: Bearer YOUR_NEW_TEST_KEY"
HTTP
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. Issue them with the sandbox's API keys route. Send access restricted with scopes for a key whose scopes never change, or, from a full-access live key, full or read_only for a key that holds every test-mode scope of that access level, including scopes Flint adds later. name is optional and defaults to the sandbox name followed by Test Key.

cURL
curl -X POST https://api.withflintpay.com/v1/sandboxes/test_01KWJS7ZW5YAC86HMHWTCV93GX/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"
  }'
JSON
{
  "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.sandboxes.write. 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. A test key that holds accounts.api_keys.write can also create keys in its own sandbox with POST /v1/api-keys, and 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
curl "https://api.withflintpay.com/v1/sandboxes" \
  -H "Authorization: Bearer YOUR_LIVE_API_KEY"
JSON
{
  "data": [
    {
      "sandbox_id": "test_01KNB061AGD0CYYF16M5QAQE3N",
      "name": "Default Test",
      "status": "active",
      "is_default": true,
      "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,
      "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 sandbox
Final values do not change again
  • active
    Its keys authenticate, and you can issue keys for it, reset it, or archive it.
  • archivedFinal
    Archived by an archive or a reset. Its keys return 401 INVALID_CREDENTIAL with reason revoked, and its data can't be read. There is no unarchive.

Reset a sandbox#

A reset gives you a clean sandbox with the same name. Flint clears the sandbox's data, including its test clocks, archives it, and returns a replacement with a new sandbox_id. The replacement keeps the same test payment account, so card payments don't need setting up again, but check readiness.payments before the first payment as you would for a new sandbox.

Send an Idempotency-Key. A retry with the same key within 24 hours returns the original replacement instead of an error about the now-archived sandbox.

cURL
curl -X POST https://api.withflintpay.com/v1/sandboxes/test_01KWJS7ZW5YAC86HMHWTCV93GX/reset \
  -H "Authorization: Bearer YOUR_LIVE_API_KEY" \
  -H "Idempotency-Key: reset-ci-2026-09-04"
JSON
{
  "data": {
    "sandbox_id": "test_01KX0B3M9Q4R7T2V5W8Y1Z6A3C",
    "replaces_sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
    "name": "CI",
    "status": "active",
    "is_default": false,
    "created_at": "2026-09-04T14:20:33Z",
    "updated_at": "2026-09-04T14:20:33Z"
  },
  "request_id": "req_01KWM6ZHRMW9K5XV66R5X74VRN"
}

The replacement's replaces_sandbox_id names the sandbox you reset, and the archived sandbox's replaced_by_sandbox_id, on GET /v1/sandboxes/{sandbox_id}, names its replacement. Both are omitted when no reset links the sandbox. After several resets, each sandbox links only to its immediate predecessor and replacement, so to recover the current ID after losing a reset response, follow replaced_by_sandbox_id until a sandbox has none.

Three things need redoing after a reset:

  • Keys. Keys bound to the old sandbox return 401 INVALID_CREDENTIAL with details[0].reason revoked. Issue new keys against the new sandbox_id.
  • Webhook endpoints. They're deleted with the rest of the data. Register your endpoint again with a new key, and set your receiver's expected JWT audience to the new endpoint's ID. New endpoints sign with JWTs and have no shared secret. If your receiver verifies HMAC, request "signing_methods": ["hmac"] when you register and store the returned secret; see Verify an HMAC delivery.
  • IDs. Products, plans, customers, test clocks, and everything else from before the reset no longer exist. Re-create what your tests depend on.

The default sandbox can't be reset: the request returns 409 ACTION_NOT_ALLOWED with reason unsupported_state.

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 test payment account, while a new sandbox needs its payments set up first. Store a live key with developer.sandboxes.write, accounts.api_keys.write, and the scopes your tests need as a CI secret, and look the sandbox up by name, because its ID changes on every reset.

  1. Find the CI sandbox#

    List active sandboxes with the live key and pick the one named CI. Active names are unique, so there is at most one.

  2. Reset it#

    POST /v1/sandboxes/{sandbox_id}/reset with an Idempotency-Key that includes the run ID, so a retried step returns the same replacement. Keep the new sandbox_id.

  3. Issue the run's key#

    POST /v1/sandboxes/{sandbox_id}/api-keys with access restricted and the scopes the tests need, including merchants.profile.read for the readiness check. Pass secret_key to the tests as a masked secret. The next run's reset revokes it.

  4. Prepare the sandbox#

    With the new key, register any webhook endpoint the tests receive on, create the catalog they use, and wait for readiness.payments.status to be ready on GET /v1/merchant before the first card payment.

With the Node SDK, the first three steps look like this:

TypeScript
import { Client } from "@flintpay/node";

const flint = new Client({
  baseUrl: "https://api.withflintpay.com",
  apiKey: process.env.FLINT_LIVE_API_KEY!,
});
const runId = process.env.CI_RUN_ID!;

async function findActiveSandbox(name: string) {
  for await (const sandbox of flint.developer.listSandboxesItems({ status: ["active"] })) {
    if (sandbox.name === name) return sandbox;
  }
  throw new Error(`No active sandbox named ${name}. Create it once with POST /v1/sandboxes.`);
}

const current = await findActiveSandbox("CI");
const fresh = await flint.developer.resetSandbox(current.sandbox_id, {}, {
  idempotencyKey: `ci-reset-${runId}`,
});
const key = await flint.developer.createSandboxAPIKey(
  fresh.sandbox_id,
  {
    name: `ci-${runId}`,
    access: "restricted",
    scopes: ["commerce.orders.read", "commerce.orders.write", "merchants.profile.read", "webhooks.write"],
  },
  { idempotencyKey: `ci-key-${runId}` },
);

// Hand key.secret_key to the test process, for example as FLINT_API_KEY.

If a retried reset step uses a new idempotency key, the old ID is already archived and the reset returns 409 ACTION_NOT_ALLOWED with reason archived. Looking the sandbox up by name again finds the replacement.

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
curl -X DELETE https://api.withflintpay.com/v1/sandboxes/test_01KWJS7ZW5YAC86HMHWTCV93GX \
  -H "Authorization: Bearer YOUR_LIVE_API_KEY" \
  -H "Idempotency-Key: archive-qa-sandbox"
JSON
{
  "data": {
    "sandbox_id": "test_01KWJS7ZW5YAC86HMHWTCV93GX",
    "name": "CI (Archived WTCV93GX)",
    "status": "archived",
    "is_default": false,
    "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:

JSON
{
  "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#

  • HTTP 400
    A malformed sandbox_id, with param sandbox_id. Or a request that issues a test key left out access or sent restricted without scopes (details[0].code REQUIRED), sent scopes with full or read_only (NOT_ALLOWED), sent key fields without issue_test_key (NOT_ALLOWED), or asked for a live-only scope (NOT_ALLOWED on scopes). Fix the field param names
  • HTTP 401
    details[0].reason is mode_mismatch for a test key with no sandbox binding, and revoked for a key whose sandbox was reset or archived. Use a key bound to an active sandbox
  • HTTP 403
    live_mode_required: a test credential called a sandbox route; use a live key. merchant_role_insufficient: the onboarding session's user isn't a merchant owner or admin. full_access_required: only a full-access key can grant full or read_only
  • HTTP 403
    The live key lacks developer.sandboxes.write, or accounts.api_keys.write when issuing a key, or a scope it's trying to grant. Add the scopes to the key or use one that holds them
  • HTTP 403
    An onboarding session granting full or read_only access, or gift card scopes that need it, without a fresh identity verification. Verify again, then retry
  • HTTP 404
    No sandbox with that ID in your merchant account, with param sandbox_id. Check the ID against GET /v1/sandboxes
  • HTTP 409
    An active sandbox already has that name. details[0].current_resource names it. Pick another name, or archive or reuse the existing sandbox
  • HTTP 409
    Reason archived: the sandbox is archived, so it can't be reset, archived again, or given keys. Reason unsupported_state: the default sandbox can't be reset or archived. Use a sandbox you created

From the CLI#

The CLI manages sandboxes with a live credential. It reads the mode from the credential, and a live API key needs --live on each command:

Shell
flint sandboxes list --live
flint sandboxes create --name qa-scenarios --live
flint sandboxes create --name ci --access restricted --issue-test-key true --scopes commerce.orders.read --scopes merchants.profile.read --live
flint sandboxes api-keys create test_01KWJS7ZW5YAC86HMHWTCV93GX --name qa --access restricted --scopes customers.read --live
flint sandboxes reset test_01KWJS7ZW5YAC86HMHWTCV93GX --live --confirm

--scopes selects restricted access on sandboxes api-keys create. To issue a key while creating a sandbox, pass --issue-test-key true and choose --access explicitly. In the SDKs, the same routes are on developer: listSandboxes, getSandbox, createSandbox, createSandboxAPIKey, resetSandbox, and deleteSandbox.

Next steps#

TestingTest cards, declines, 3D Secure, refunds, disputes, and subscription renewals in your sandbox.Sandboxes API referenceEvery sandbox route, field, and response shape.AuthenticationKeys, access levels, scopes, and the Authorization header.Going liveSwap in a live key and re-create your configuration in live mode.

Was this helpful?