Authentication and keys

Create a workspace API key, choose what it can do, and send its key id, secret and an Idempotency-Key with Subscriptions REST API requests.

Last updated: 2026-11-09

Every request carries a workspace API key: its key id in the X-Chargezen-Key-Id header and its secret as a bearer token in Authorization.

Create a key

1

Open API keys

In Chargezen, go to Settings → API keys and add a key.

2

Choose what it can do

Under What it can do, turn on what your server needs (see the table below).

3

Copy the secret

The secret is shown once, when the key is created. Store it with your server's other secrets.

In ChargezenKey permissionAllows
Read customers, products and subscriptionsworkspace:readEvery GET
Change subscriptionssubscriptions:writeEvery POST under a subscription, including order now
Create subscriptionssubscriptions:createPOST /customers/{customer_id}/subscriptions

A key acts as you

A key that reads or changes subscriptions acts as the teammate who gave it that access, with that teammate's current role. Each request also needs the matching permission in that role:

  • Finding customers: managing customers, viewing subscriptions or viewing CheckoutOS.
  • Listing and reading subscriptions, listing plans and checking a new subscription: viewing subscriptions.
  • Upcoming orders, swap options, every change, order now and creating: managing subscriptions.

If you remove the teammate from the workspace or take away the permission, the key stops working for those requests and answers PERMISSION_REQUIRED.

Send the key

Every request
curl "https://api.chargezen.com/v1/customers/8f14e45f-ceea-467f-a0e6-0e1c2f4b9d3a/subscriptions/48213" \
  -H "X-Chargezen-Key-Id: $CHARGEZEN_KEY_ID" \
  -H "Authorization: Bearer $CHARGEZEN_SECRET"

Idempotency-Key on every POST

Every POST needs an Idempotency-Key header: any unique string, and a UUID is best. To retry a request, send it again with the same key.

  • Create, cancel, order now and payment-method requests are tied to that key, so they never happen twice.
  • The other changes set a target state (paused, a quantity, an address), so repeating them is harmless.
Retry with the same key
KEY=$(uuidgen)
curl -X POST "https://api.chargezen.com/v1/customers/8f14e45f-ceea-467f-a0e6-0e1c2f4b9d3a/subscriptions/48213/cancel" \
  -H "X-Chargezen-Key-Id: $CHARGEZEN_KEY_ID" \
  -H "Authorization: Bearer $CHARGEZEN_SECRET" \
  -H "Idempotency-Key: $KEY"
# The connection dropped? Send the same request with the same $KEY.
Keep the secret on your server

The key acts as a teammate. Never put it in a storefront, an app bundle or anything a shopper can read.

When a key is refused

StatusCodeWhat happened
401API_KEY_REQUIREDThe key id or the bearer secret is missing.
401API_KEY_INVALIDThe key id and secret don't match an active key.
403API_KEY_SCOPE_REQUIREDThe key isn't allowed to do this. The message names the permission it needs.
403PERMISSION_REQUIREDThe teammate the key acts for lost access to the workspace, or their role lacks the permission.
422IDEMPOTENCY_KEY_REQUIREDA POST came without an Idempotency-Key header.
Was this page helpful?

Need more help? Contact support