Skip to content

Authentication & API keys

Secret API keys, test vs live mode, scopes, rotation, expiry and IP allowlists.

Every request is authenticated with a secret API key sent as a Bearer token:

HTTP
GET /api/v1/account HTTP/1.1
Authorization: Bearer sk_test_51Hx…
curl https://swaglists.com/api/v1/account \
  -H "Authorization: Bearer $API_KEY"

HTTP Basic authentication with the key as the username and an empty password also works (curl -u "$API_KEY:"), for tools that only support Basic auth.

Danger

Secret keys can create orders that spend your credits. Use them only on your server. Never put them in browser JavaScript, mobile apps, public repositories or URLs. Store them in environment variables or a secrets manager.

Test and live keys

Test mode Live mode
Key prefix sk_test_ sk_live_
Data Separate test orders, webhooks, events and wallet Real orders
Credits Free test credits (POST /test/wallet/fund) Credits you buy
Production Simulated — nothing is printed or shipped Real production and shipping
Customer emails Never sent Sent if enabled
Test helpers (/test/…) Available 403 test_mode_only

Both modes use the same base URL — the key decides the mode. Products, designs and files are shared between modes, so a product you created in test mode can be ordered live without changes. Everything else (orders, webhook endpoints, events, wallet) is separate: a live key cannot see test orders and vice versa.

Creating a live key requires a verified email address (see the going live checklist). Live keys work while live mode is enabled for your account; if it is not (for example while support reviews a new account), they return 403 live_mode_disabled.

Creating keys

Create keys in the dashboard under Developers → API keys (owners, admins and developers can). For each key you choose:

  • Mode — test or live.
  • Access — full access, read-only, orders only, or individual scopes.
  • Expiry (optional) — the key stops working at that date (at most 5 years ahead).
  • IP allowlist (optional) — the key only works from these addresses.

The full secret is shown once, when the key is created. We store only a hash; if you lose a key, roll it or create a new one. The dashboard shows a key's prefix and last four characters so you can recognize it, and the Logs page shows every request made with it.

Scopes

Give each integration only what it needs. A :write scope includes the matching :read scope; * is full access.

Scope Grants
* Full access to every endpoint (required by POST /test/wallet/fund).
account:read GET /account.
catalog:read Catalog products, categories, variants and wholesale prices.
files:read List and retrieve files.
files:write Upload and delete files (includes files:read).
products:read Your products, variants and SKUs.
products:write Create, update and archive products and variants (includes products:read).
orders:read Orders, order events, shipping rates and order estimates.
orders:write Create, update, confirm and cancel orders; advance test orders (includes orders:read).
wallet:read Wallet balance, transactions and top-ups.
webhooks:read Webhook endpoints and events.
webhooks:write Create, update, delete and test webhook endpoints, rotate secrets (includes webhooks:read).

A request outside the key's scopes fails with 403 insufficient_scope; the error's required_scope tells you which scope is missing.

Rotating keys

Roll a key (Developers → API keys → Roll) to replace its secret, for example when a team member leaves or a secret may have leaked. You choose when the old secret stops working: now, in 1 hour, 24 hours or 7 days. During the overlap both secrets work, so you can deploy the new secret without downtime:

  1. Roll the key with an overlap (e.g. 24 hours) and copy the new secret.
  2. Deploy the new secret to your servers.
  3. Check Developers → Logs to confirm no requests use the old key anymore.

Revoke a key to stop it immediately. Rolled, revoked and expired keys return 401 invalid_api_key with a message saying why.

IP allowlists

An allowlist accepts up to 50 IPv4/IPv6 addresses or CIDR ranges (for example 203.0.113.7 or 10.0.0.0/8). Requests from other addresses fail with 403 ip_not_allowed.

Warning

Use your server's public egress address. Behind NAT, a load balancer or a serverless platform, outgoing requests may come from a different (or changing) address than your server's own. If your platform has no static egress IP, do not use an allowlist.

Errors

Status Code Meaning
401 missing_api_key No Authorization header.
401 invalid_api_key Unknown, revoked or expired key, or a malformed header.
403 insufficient_scope The key lacks a scope.
403 live_mode_disabled Live key used before live mode is enabled.
403 ip_not_allowed Request from an address not on the allowlist.
403 account_suspended The account is suspended.
403 test_mode_only A test helper was called with a live key.