ROKIConnect
Connectors Start API SDKs Migrate MCP Portal ES
DocumentationContinue with Roki (OAuth 2 + PKCE)

Continue with Roki (OAuth 2 + PKCE)

For partner platforms: connect a merchant without the merchant pasting a secret key into your product. The merchant signs in to the ROKI portal and approves; you receive tokens and call Connect with Authorization: Bearer {access_token}.

Verified 2026-10-28: /oauth/authorize and /oauth/token with an unknown client answer 401 with {"error":"invalid_client", "error_description": ...}; POST /oauth/account-lookup refuses no auth, a Bearer sk_* and an unknown client with 401 account_lookup_unauthorized. A real authorization needs a partner app registered by ROKI, which we do not have, so the rest of this section is ROKI's documented behaviour.

32.1 Before it works

32.2 Authorize

Generate a code_verifier per login attempt and keep it server-side; send only its challenge.

$verifier  = rtrim(strtr(base64_encode(random_bytes(32)), '+/', '-_'), '=');
$challenge = rtrim(strtr(base64_encode(hash('sha256', $verifier, true)), '+/', '-_'), '=');

Redirect the merchant's browser to:

https://aura.roki.systems/oauth/authorize
  ?client_id={CLIENT_ID}&redirect_uri={CALLBACK}&response_type=code
  &scope=connect&state={RANDOM}
  &code_challenge={CHALLENGE}&code_challenge_method=S256
  &locale=es&prompt=consent            <- both optional

Note the base: OAuth lives at the site root, not under /api/connect/v1. Verify state on the callback. A cancel comes back as error=access_denied with no code - do not call the token endpoint.

32.3 Scopes

connect is full access. Granular scopes, space-separated: connect.identity (GET /me), connect.payments (payments, embed, direct pay), connect.payment_methods, connect.webhooks, connect.obligations, connect.automatic_debit, connect.payment_authorizations, connect.recurring, connect.sales. The merchant can narrow them at Allow. A call outside the grant answers 403 with code: "insufficient_scope". Secret keys are never scope-limited.

32.4 Tokens

POST https://aura.roki.systems/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&client_id={CLIENT_ID}&redirect_uri={CALLBACK}
&code={CODE}&code_verifier={VERIFIER}

Returns token_type, expires_in (about an hour), access_token, refresh_token (about 30 days). The code is single-use. Refresh with grant_type=refresh_token, client_id and refresh_token - and store the new refresh token every time: they rotate, and the old one now answers invalid_grant. Omit scope on refresh to keep the grant; you can only narrow it.

Errors are OAuth-shaped - error (stable, English) plus error_description (localized): branch on error. invalid_client (unknown or revoked client), invalid_grant (redirect mismatch, reused code, rotated refresh token), invalid_scope.

32.5 After connecting

Call GET /me first (needs connect.identity or connect) and show "Connected as {business_name} ({environment})". Rotating the merchant's sk_* does not revoke OAuth tokens. The refresh token is valid only at /oauth/token, never as a Bearer.

POST /api/connect/v1/oauth/account-lookup lets your server ask whether an email already has a ROKI merchant account before starting the flow. HTTP Basic only - user client_id, password the partner secret ps_* ROKI issues with the app (never a Bearer); 60 requests per minute per client (429 account_lookup_rate_limited with Retry-After). exists: true does not mean Connect is ready; still run authorize.


Verified empirically against the production API on 2026-08-08. Authoritative schemas in openapi.yaml. Where this document and the live API disagree, the API wins.