Skip to main content
POST
Exchange or refresh tokens

Authorizations

Authorization
string
header
required

Your app's client_id as the username and its client secret (appsk_live_... or appsk_test_...) as the password. You can send client_secret in the body instead. See Connect a business.

Scopes

connected_accounts:write

Body

grant_type
enum<string>
required

Use authorization_code to exchange a code, or refresh_token to rotate credentials.

Available options:
authorization_code,
refresh_token
Example:

"authorization_code"

client_id
string
required

The public ID of the app registered by the platform authenticating this request.

Example:

"cwb_Kb2tCV58C3AmqN7PKT4vS8YW"

code
string

The single-use code from the callback; required for authorization_code.

Example:

"dQ6Bt0y2QmJc_XO-x-zZS1POIRsOPdCmDueYpYBEvyI"

code_verifier
string

The original PKCE verifier; required for authorization_code.

Example:

"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"

redirect_uri
string

The exact registered callback used to start authorization; required for authorization_code.

Example:

"https://platform.example/bachs/callback"

refresh_token
string

The current refresh token; required for refresh_token.

Example:

"9w42ebfsXyghxLDgN0ZM0h6tYYyjrW0nXUTvVLnup2g"

client_secret
string

Your app's client secret, when you do not send it as HTTP Basic. Never send it from a browser.

Response

Scoped business credentials, or the legacy account reference. Tokens are never returned by the browser callback.

account_id
string
required

The existing business authorized by the merchant.

Example:

"acct_8Qz4k2Bp6NvR7dHc"

livemode
boolean
required

When true, these credentials belong to the live environment.

Example:

false

token_type
string

The authorization scheme used with the access token. Returned for app authorizations.

Example:

"Bearer"

access_token
string

The approved business credential; send it in the Authorization header and store it only on your server.

Example:

"sk_sandbox_9cfa0c7e_o7ozvw-rhGzcnD214SWK33C2C1s44Q4UA3kTmxRWcZs"

refresh_token
string

The rotating refresh credential; store each replacement atomically with its access token.

Example:

"9w42ebfsXyghxLDgN0ZM0h6tYYyjrW0nXUTvVLnup2g"

expires_in
integer

Seconds until the access token expires, normally 3600 and shorter near the connection expiry.

Example:

3600

scope
string

The approved permissions, separated by spaces.

Example:

"payments:read"

webhook_endpoint_id
string

The automatic webhook subscription ID, returned only during code exchange when an endpoint is configured.

Example:

"whe_7Qm2cN6vR4pK8dLs"

webhook_signing_secret
string

The webhook verification secret, returned only during code exchange when an endpoint is configured.

Example:

"whsec_68e0eec57fcfdba7aff2465787b23ceca5325257d72c5426aa735305ce193da3"