| Method | Use case | Format |
|---|---|---|
| API key | Server-to-server integrations | Authorization: Bearer sk_... |
| JWT token | Dashboard sessions and user-facing flows | Authorization: Bearer eyJ... |
API keys
API keys are long-lived credentials scoped to your organization. They are the recommended method for authenticating server-side API calls.Getting an API key
You can create an API key from your dashboard or via the API. You need a valid user session (JWT token) to create a key.- API
- Dashboard
Using the API key
Pass your API key as a Bearer token in theAuthorization header of every request.
Your API key must start with
sk_. Requests using a key that does not include this prefix will be rejected.Test vs live keys
Your API key is automatically scoped to the environment your organization is currently in:- Test keys — Used while your account is in test mode. Prefixed
sk_test_. No real money moves. - Live keys — Used once your account is verified and live payments are enabled. Prefixed
sk_live_.
One active key per organization
You can have at most one active API key per organization at a time. If you need to rotate your key:- Create a new key — this will fail if an active key already exists.
- Revoke the existing key first, then create the new one.
Revoking a key
401 Unauthorized error.
JWT tokens
JWT tokens are short-lived credentials issued after a successful user login. They are used by the Syncgram Pay dashboard and are suitable for user-facing flows, but are not recommended for server-to-server integrations due to their short lifetime (15 minutes).Obtaining a token
Login is a two-step process: Step 1 — Submit credentials:access_token (15-minute lifetime) and a refresh_token (30-day lifetime).
Refreshing a token
When your access token expires, exchange the refresh token for a new one:Refresh tokens are rotated on every use. The old refresh token is invalidated when a new one is issued.
Error responses
If your request is not authenticated correctly, the API returns one of the following errors:401 Unauthorized
Returned when no token is provided, the token is invalid, or the token has expired.- Missing
Authorizationheader - Expired access token (use
/auth/refreshto get a new one) - Revoked API key
403 Forbidden
Returned when the token is valid but the request is not permitted for your account or role.- Attempting to access a resource that belongs to a different organization
- Your account has not completed onboarding required for this action
Security best practices
- Store API keys in environment variables, never in source code or version control.
- Rotate your API key periodically by revoking the old key and creating a new one.
- Use the test environment (
sk_test_keys) during development. - Never share your API key publicly or log it in application output.