Exchange a connect code for a grant token (PKCE)

​

Completes the account-connection handshake for applications that run where a credential can't be kept secret — browser extensions and mobile apps. Available only to applications CardNexus has enabled for the PKCE flow.

Before opening the connect link, generate a random code_verifier (43–128 characters) and add code_challenge — the base64url-encoded SHA-256 hash of the verifier — to the connect link's query parameters. After the user approves, exchange the code from the redirect here, together with the original verifier. No Authorization header is needed on this request.

The response carries the account's grant token. Send it as Authorization: Bearer on every request you make for that account; each /v1 endpoint then behaves exactly as if the account called it with its own key, limited to the granted permissions. Exchanging again after a reconnect replaces the previous token.

The code is single-use and expires 5 minutes after it is issued. This endpoint accepts up to 30 requests per minute from one IP address.

Body

required
application/json
  • The one-time code you received on the connect redirect, as the code query parameter. Valid for 5 minutes and usable once.

  • The PKCE code verifier your app generated before opening the connect link — the random string whose SHA-256 hash you sent as code_challenge. 43–128 characters.

  • Your application's slug — the segment in your connect link.

Responses

  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
  • application/json
Request Example for post/connect/token
curl https://public-api.cardnexus.com/v1/connect/token \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --data '{
  "slug": "",
  "code": "",
  "codeVerifier": ""
}'
{
  "accountToken": "cng_live_4f2d8c91e5b34a7f9e6c2d1a8b5f7e3c9a1d4e6f",
  "accountId": "65f3a2b1c8d4e9f7a6b5c4d3",
  "scopes": [
    "inventory:read",
    "inventory:write"
  ],
  "grantedAt": "2026-02-03T18:42:55.000Z"
}