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 asAuthorization: Beareron/v1/meroutes untilexpires_at.refresh_token(flint_cref_) works once: send it toPOST /v1/customer-sessions/refreshfor a newsecretandrefresh_token, untilrefresh_token_expires_at.
Set each lifetime on create, in seconds:
| Request field | Default | Range |
|---|---|---|
expires_in_seconds | 1 hour | 300 to 86,400 (24 hours) |
refresh_expires_in_seconds | 7 days | 3,600 to 2,592,000 (30 days) |
refresh_token_expires_atis 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_secondslifetime, counted from the refresh. A secret never outlives its session. Ifrefresh_token_expires_atcomes before the secret's lifetime would end,expires_atequals it. - A lifetime outside its range, including
0, or anulllifetime returns400 INVALID_REQUESTwithparamnaming the field. Leave a field out to use its default. - Omit
capabilitiesfor 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 grantedcapabilities, and refresh cannot widen an explicit grant. Missing capabilities return403 INSUFFICIENT_SCOPE, reasonscope_not_granted, withmissing_scopes.
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" }'
{
"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.writecreates 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-Keyis required. The code path that keeps a buyer signed in never has to hold your secret key. - The session's current
secretcalls the/v1/meroutes its capabilities permit, includingPOST /v1/me/session/revoketo 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 -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 sessionactiveThe secret works untilexpires_at, and the refresh token can rotate it untilrefresh_token_expires_at.revokedFinalNone of the session's credentials work.revoked_atis when it was first revoked.
Each of these ends a session:
- Sign-out.
POST /v1/me/session/revokerevokes the session with its newest secret, even afterexpires_at. A repeat returns the firstrevoked_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_countcounts 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:
| Route | Reason | What to do |
|---|---|---|
/v1/me | expired | Refresh, then resend the call. |
/v1/me | unknown | Refresh once with the token you hold and the session's fixed key. If that fails, sign the buyer in again. |
| Refresh | expired | The session ended. Sign the buyer in again. |
| Refresh | revoked | A 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#
/v1/customer-sessionsIdempotentRequires 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 enumOperation capabilities granted to this session. Omit for full access; an empty list grants no operations except self-revocation. Refresh preserves this list.
account.readaccount.manageaccount.deleteorders.readreturns.readreturns.createsubscriptions.readsubscriptions.managepayments.createpayment_methods.readpayment_methods.manageaddresses.readaddresses.managegift_cards.readgift_cards.managelicense_keys.readlicense_keys.manage
customer_idstringRequiredID of the customer the session acts as. Calls made with the session's secret see only this customer's data.
expires_in_secondsintegerHow 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_secondsintegerHow 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.
dataobjectRequiredResource, collection, or operation result returned by this request.
refresh_tokenstringSingle-use refresh token. Returned only on create and refresh; retry rotation with the same Idempotency-Key. Returned only to the credential that created it, and omitted when another credential replays the request.
secretstringCurrent server-held customer session secret. Returned only on create and refresh. Returned only to the credential that created it, and omitted when another credential replays the request.
capabilitiesarray of stringRequiredGranted operation capabilities. Default sessions report the full capability catalog. Refresh never widens an explicit grant.
created_atstringRequiredWhen the session was created.
customer_idstringRequiredID of the customer the session acts as.
customer_session_idstringRequiredID of this session. Use it to tell sessions apart; it is not a credential.
expires_atstringRequiredWhen the current secret stops authenticating account calls.
refresh_token_expires_atstringRequiredWhen the refresh token expires.
revoked_atstringWhen the session was first revoked. Present exactly when status is revoked.
statusenumRequiredactive means the session can be refreshed and its secret works until expires_at; revoked means none of its credentials work.
activerevoked
supported_actionsarray of enumRequiredLifecycle actions Flint accepts now, independent of the caller's permissions. Contains revoke for active and revoked sessions because repeating a revocation succeeds.
Not returned with a customer session
revoke
metaobjectAdditional information about this response.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
request_idstringRequiredIdentifier 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#
/v1/customer-sessions/{customer_session_id}/revokeIdempotentRequires 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_idstringRequiredFlint 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.
dataobjectRequiredThe customer session, including its status and credential expiry times.
capabilitiesarray of stringRequiredGranted operation capabilities. Default sessions report the full capability catalog. Refresh never widens an explicit grant.
created_atstringRequiredWhen the session was created.
customer_idstringRequiredID of the customer the session acts as.
customer_session_idstringRequiredID of this session. Use it to tell sessions apart; it is not a credential.
expires_atstringRequiredWhen the current secret stops authenticating account calls.
refresh_token_expires_atstringRequiredWhen the refresh token expires.
revoked_atstringWhen the session was first revoked. Present exactly when status is revoked.
statusenumRequiredactive means the session can be refreshed and its secret works until expires_at; revoked means none of its credentials work.
activerevoked
supported_actionsarray of enumRequiredLifecycle actions Flint accepts now, independent of the caller's permissions. Contains revoke for active and revoked sessions because repeating a revocation succeeds.
Not returned with a customer session
revoke
metaobjectMetadata about this response, including idempotency replay and warnings when present.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
request_idstringRequiredID 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#
/v1/customer-sessions/refreshKey requiredNo 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_tokenstringRequiredThe `refresh_token` returned when the session was created or last refreshed. It works once; the response carries the next one.
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#
/v1/customers/{customer_id}/sessions/revokeIdempotentRequires 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_idstringRequiredFlint 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.
dataobjectRequiredResource, collection, or operation result returned by this request.
customer_idstringRequiredID of the customer whose sessions were revoked.
revoked_countintegerRequiredNumber of sessions this call revoked. Sessions that were already revoked are not counted.
metaobjectAdditional information about this response.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
request_idstringRequiredIdentifier 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?