Skip to content

Customer sessions

A customer session is a credential for one buyer. After your own login signs the buyer in, your backend creates a session for their Flint customer, then calls /v1/me with its secret. Flint returns and changes only that customer's data, whatever IDs the request contains.

Use customer sessions when you build the buyer's account on your own pages: order history, subscriptions, saved cards, returns. To send a signed-in buyer into Flint's hosted account instead, create a customer access link. Customer sessions walks through the whole flow with sample code.

Two credentials per session#

Create and refresh each return two credentials. Flint shows them in no other response, so store both in your server-side session record as soon as they arrive.

  • secret (flint_cses_) is the working credential. Send it as Authorization: Bearer on /v1/me routes until expires_at.
  • refresh_token (flint_cref_) works once: send it to POST /v1/customer-sessions/refresh for a new secret and refresh_token, until refresh_token_expires_at.

Set each lifetime on create, in seconds:

Request fieldDefaultRange
expires_in_seconds1 hour300 to 86,400 (24 hours)
refresh_expires_in_seconds7 days3,600 to 2,592,000 (30 days)
  • refresh_token_expires_at is fixed at creation and is how long the buyer stays signed in. Refreshing doesn't extend it; when it passes, the buyer signs in again and you create a new session.
  • Each refresh gives the new secret the same expires_in_seconds lifetime, counted from the refresh. A secret never outlives its session. If refresh_token_expires_at comes before the secret's lifetime would end, expires_at equals it.
  • A lifetime outside its range, including 0, or a null lifetime returns 400 INVALID_REQUEST with param naming the field. Leave a field out to use its default.
  • Omit capabilities for full buyer access, or send an explicit list such as ["orders.read", "returns.read", "returns.create"]. An empty list permits only self-revocation. The capability list defines each operation group; capabilities do not imply each other. Create, refresh, and revoke responses report the granted capabilities, and refresh cannot widen an explicit grant. Missing capabilities return 403 INSUFFICIENT_SCOPE, reason scope_not_granted, with missing_scopes.
cURL
curl -X POST https://api.withflintpay.com/v1/customer-sessions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "customer_id": "cus_1kmn0aExample" }'
Response
{
  "data": {
    "customer_session_id": "cses_1kmn0aExample",
    "customer_id": "cus_1kmn0aExample",
    "status": "active",
    "secret": "flint_cses_example",
    "expires_at": "2026-10-28T18:00:00Z",
    "refresh_token": "flint_cref_example",
    "refresh_token_expires_at": "2026-11-04T17:00:00Z",
    "created_at": "2026-10-28T17:00:00Z"
  },
  "request_id": "req_01KWM6WAHG3N9Q8T2V5XRZ7C4D"
}

The session opens in the environment of the API key you send. A sandbox key finds only that sandbox's customers, and a customer_id it can't find returns 404 RESOURCE_NOT_FOUND.

Warning: Both credentials stay on your server

Handle the secret and the refresh token like an API key. Keep them out of browser code, mobile bundles, cookies, URLs, and logs. Flint has no browser credential for /v1/me: the browser calls your backend, and your backend relays the call to Flint.

Which credential each call takes#

  • A secret API key with customers.sessions.write creates a session, revokes one by ID, and revokes every session for a customer.
  • No credential refreshes a session. The refresh token in the body is the credential, and Idempotency-Key is required. The code path that keeps a buyer signed in never has to hold your secret key.
  • The session's current secret calls the /v1/me routes its capabilities permit, including POST /v1/me/session/revoke to sign the buyer out.

Partner app access tokens can't call the customer session routes.

Refresh rotates both credentials#

When a /v1/me call fails because the secret expired, or shortly before expires_at, trade the refresh token for a new pair. Each refresh ends the secret and refresh token it replaces. The session keeps its customer_session_id, created_at, and refresh_token_expires_at.

cURL
curl -X POST https://api.withflintpay.com/v1/customer-sessions/refresh \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: refresh-cses_1kmn0aExample" \
  -d '{ "refresh_token": "flint_cref_example" }'

Send one fixed Idempotency-Key per session, such as refresh- plus the customer_session_id. Flint scopes the key to the refresh token, so every request with the same token and key gets the same new pair for as long as Flint holds the key. Two server instances that refresh at once get one rotation, a retry after a lost response returns the pair the first request created, and a 409 IDEMPOTENCY_KEY_IN_PROGRESS means to retry with the same key and token. The next refresh sends the new token, so the same key starts a new rotation. Send one fixed Idempotency-Key per session has a complete refresh function.

Important: Reusing a rotated refresh token revokes the session

A refresh token that was already exchanged, sent with a different Idempotency-Key, returns 401 INVALID_CREDENTIAL with details[0].reason: "revoked", and Flint revokes the session, including the secret the buyer is using. Flint treats it as a stolen token. Sign the buyer out, have them sign in again, and don't retry.

Status and what ends a session#

status on customer session
Final values do not change again
  • active
    The secret works until expires_at, and the refresh token can rotate it until refresh_token_expires_at.
  • revokedFinal
    None of the session's credentials work. revoked_at is when it was first revoked.

Each of these ends a session:

  • Sign-out. POST /v1/me/session/revoke revokes the session with its newest secret, even after expires_at. A repeat returns the first revoked_at.
  • Revoke by ID. Revokes one session from your backend. A repeat keeps the first revoked_at.
  • Revoke every session for the customer. Use it when the buyer changes their password, when you close their account, or when you suspect a takeover. revoked_count counts only the sessions this call revoked.
  • Reuse of a rotated refresh token. Flint revokes the session.
  • A confirmed email change. Flint revokes the customer's sessions and emailed access links at that store. The buyer stays signed in to Flint and their other stores.
  • The end of the refresh window, or a deleted customer. The credentials stop working.

Customer sessions and Flint's hosted account sign-in are independent. Revoking customer sessions doesn't sign the buyer out of Flint's hosted account, and signing out there doesn't revoke your customer sessions.

Review a leaked session#

Buyer requests appear in request logs with a customer_session caller. If a session leaks, revoke the customer's sessions with POST /v1/customers/{customer_id}/sessions/revoke, then review GET /v1/api-request-logs?customer_id=cus_... with an API key that holds developer.request_logs.read. The filter covers requests across the customer's sessions; each log's caller identifies the session.

Handle credential failures#

A failed session credential returns 401 INVALID_CREDENTIAL, and details[0].reason says what to do:

RouteReasonWhat to do
/v1/meexpiredRefresh, then resend the call.
/v1/meunknownRefresh once with the token you hold and the session's fixed key. If that fails, sign the buyer in again.
RefreshexpiredThe session ended. Sign the buyer in again.
RefreshrevokedA rotated token was reused. Sign the buyer in again.

On refresh, 409 IDEMPOTENCY_KEY_IN_PROGRESS means another request with the same token and key is still running: retry with the same key and token. A /v1/me call with no bearer credential returns 401 AUTHENTICATION_REQUIRED. Handle the failures covers each route's other errors, and calls made with a session secret also count against per-session and per-customer rate limits.

Next steps#

Customer sessionsCreate, refresh, and revoke sessions, with a complete refresh function.Build your own customer accountFind the customer, relay /v1/me calls, and build each account page.Customer account APIEvery /v1/me route a session secret can call.

Create a customer session#

POST/v1/customer-sessionsIdempotent

Requires scope customers.sessions.write

Rate limit: sensitive_write

Mints a server-side, customer-scoped credential after the merchant has authenticated the buyer. Keep secret and refresh_token on your server. For hosted sign-in, create a customer access link instead.

Request body

capabilitiesarray of enum

Operation capabilities granted to this session. Omit for full access; an empty list grants no operations except self-revocation. Refresh preserves this list.

  • account.read
  • account.manage
  • account.delete
  • orders.read
  • returns.read
  • returns.create
  • subscriptions.read
  • subscriptions.manage
  • payments.create
  • payment_methods.read
  • payment_methods.manage
  • addresses.read
  • addresses.manage
  • gift_cards.read
  • gift_cards.manage
  • license_keys.read
  • license_keys.manage
customer_idstringRequired

ID of the customer the session acts as. Calls made with the session's secret see only this customer's data.

expires_in_secondsinteger

How long the secret authenticates account calls, in seconds. Defaults to 3600 (one hour). Refreshing issues a new secret with a new window.

refresh_expires_in_secondsinteger

How long the refresh token can be exchanged for a new secret, in seconds. Defaults to 604800 (seven days).

Response · 201

The customer session and one-time credentials.

dataobjectRequired

Resource, collection, or operation result returned by this request.

metaobject

Additional information about this response.

request_idstringRequired

Identifier of this API request, used to correlate logs and support requests.

curl -X POST https://api.withflintpay.com/v1/customer-sessions \
  -H "Flint-Version: 2026-09-07" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: a-unique-key" \
  -d '{
    "customer_id": "cus_01KEZF7C003ACYXT6Q5EQZ78EE",
    "expires_in_seconds": 3600,
    "refresh_expires_in_seconds": 604800
  }'

Revoke a customer session#

POST/v1/customer-sessions/{customer_session_id}/revokeIdempotent

Requires scope customers.sessions.write

Rate limit: sensitive_write

Revokes one customer session in the selected merchant environment. This does not revoke an independent Flint Account buyer session.

Path parameters

customer_session_idstringRequired

Flint customer session ID. Must be a valid ID with prefix cses_. Malformed IDs return 400 INVALID_REQUEST with detail INVALID_VALUE; well-formed IDs that do not exist return 404 RESOURCE_NOT_FOUND.

Response · 200

The revoked customer session.

dataobjectRequired

The customer session, including its status and credential expiry times.

metaobject

Metadata about this response, including idempotency replay and warnings when present.

request_idstringRequired

ID of this API request. Include it when asking Flint to investigate the response.

curl -X POST https://api.withflintpay.com/v1/customer-sessions/cses_01KEZF7C00FBVRP25FZTW7KWZV/revoke \
  -H "Flint-Version: 2026-09-07" \
  -H "Authorization: Bearer YOUR_API_KEY"

Refresh a customer session#

POST/v1/customer-sessions/refreshKey required

No API key required

Rate limit: per IP

Rotates a customer session secret and refresh token without a merchant API key. Reusing a rotated refresh token revokes the session family. Use one fixed idempotency key per session: Flint scopes the key to the refresh token, so concurrent refreshes replay the same pair. On `IDEMPOTENCY_KEY_IN_PROGRESS`, retry with the same key and token.

Request body

refresh_tokenstringRequired

The `refresh_token` returned when the session was created or last refreshed. It works once; the response carries the next one.

Response · 200

The rotated customer session credentials.

Same response as Create a customer session.

curl -X POST https://api.withflintpay.com/v1/customer-sessions/refresh \
  -H "Flint-Version: 2026-09-07" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: a-unique-key" \
  -d '{
    "refresh_token": "flint_cref_YmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmJiYmI"
  }'

Revoke a customer's sessions#

POST/v1/customers/{customer_id}/sessions/revokeIdempotent

Requires scope customers.sessions.write

Rate limit: sensitive_write

Revokes every customer session for one customer in the selected merchant environment. Flint Account buyer sessions remain independent.

Path parameters

customer_idstringRequired

Flint customer ID. Must be a valid ID with prefix cus_. Malformed IDs return 400 INVALID_REQUEST with detail INVALID_VALUE; well-formed IDs that do not exist return 404 RESOURCE_NOT_FOUND.

Response · 200

The number of newly revoked sessions.

dataobjectRequired

Resource, collection, or operation result returned by this request.

metaobject

Additional information about this response.

request_idstringRequired

Identifier of this API request, used to correlate logs and support requests.

curl -X POST https://api.withflintpay.com/v1/customers/cus_01KEZF7C006X9JK6NZNA2SM9XD/sessions/revoke \
  -H "Flint-Version: 2026-09-07" \
  -H "Authorization: Bearer YOUR_API_KEY"

Was this helpful?