> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# OAuth

Let your users connect their Zernio workspace to your app with OAuth 2.1, then call the Zernio API on their behalf with the access they granted.

Add "Connect with Zernio" to your app. Users approve access on a Zernio consent screen, and your app gets a token for their workspace.

Zernio is an OAuth 2.1 authorization server. The Claude and ChatGPT connectors use it too.

## First call

Register your app once. Registration is open: no form, no review.

```bash
curl -sS -X POST https://zernio.com/api/oauth/register \
  -H 'Content-Type: application/json' \
  -d '{
    "client_name": "Acme Scheduler",
    "redirect_uris": ["https://app.acme.com/oauth/zernio/callback"],
    "token_endpoint_auth_method": "client_secret_post",
    "grant_types": ["authorization_code", "refresh_token"],
    "scope": "posts:read posts:write accounts:read email"
  }'
```

```json
{
  "client_id": "late_cid_928aeb6e...",
  "client_name": "Acme Scheduler",
  "client_secret": "62d699...",
  "client_id_issued_at": 1796425564,
  "client_secret_expires_at": 0,
  "redirect_uris": ["https://app.acme.com/oauth/zernio/callback"],
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"],
  "token_endpoint_auth_method": "client_secret_post",
  "scope": "posts:read posts:write accounts:read email"
}
```

Then send users to the consent screen, exchange the code, and call the API. The [quickstart](/oauth/quickstart) walks through every request.

## OAuth or an API key

| | API key | OAuth |
|---|---|---|
| Whose workspace | Yours | Your users' |
| Who creates the credential | You, in the dashboard | Your user, by approving the consent screen |
| What it can reach | What the key allows | Only the scopes the user granted |
| Lifetime | Until you revoke it | 1-hour access tokens, 30-day refresh tokens |
| Revoked by | You | Your user (Connected apps) or your app |

Use an API key for your own backend and scripts on your own account. Use OAuth when your product acts on someone else's Zernio workspace.

Never ask users to paste their API key into your app.

## How it works

1. Your app registers a client and gets a `client_id`.
2. Your app sends the user to `https://zernio.com/oauth/authorize` with a PKCE challenge.
3. The user signs in, picks a workspace, reviews the access and clicks **Authorize**.
4. Zernio redirects back with a one-time `code`.
5. Your server exchanges the code for an access token and a refresh token.
6. Your app calls `https://zernio.com/api/v1` with `Authorization: Bearer <access_token>`.

## How it behaves

- Flow: authorization code with PKCE (`S256`). PKCE is required for every client, with or without a secret.
- An access token reaches the same endpoints as an API key, limited to the granted [scopes](/oauth/scopes). It works on `https://zernio.com/api/v1` and `https://api.zernio.com/v1`.
- A token acts in one workspace: the one the user picked on the consent screen. `GET /v1/auth/verify` returns its `workspaceId`. For several workspaces, send the user through consent once per workspace.
- Access tokens last 1 hour. Refresh tokens last 30 days and rotate on every refresh.
- All OAuth apps a user has connected share one limit of 600 requests a minute. A `429` carries `Retry-After`.
- Tokens can never manage API keys, invites, connected apps, workspace members, SSO or account deletion.
- Ids and tokens start with `late_`, the API's former name.
- Discovery metadata: `https://zernio.com/.well-known/oauth-authorization-server` (RFC 8414).

## Related

- [Quickstart](/oauth/quickstart)
- [Scopes](/oauth/scopes)
- [Consent screen](/oauth/consent-screen)
- [Errors](/oauth/errors)
- [Security](/oauth/security)