Machines and agents
How services, CLIs, MCP clients and AI agents sign in to a project with standard OAuth 2.0, and which credential to use when.
Much of what touches a backend today is not a person: services, scheduled jobs, CLIs, MCP clients, AI agents. Sypnia Data treats them as first-class callers, with standard protocols, not home-made ones. Each project is an OAuth 2.0 authorization server at /auth/v1/oauth, described at /.well-known/oauth-authorization-server.
Which credential, when
| Who is calling | Use | Why |
|---|---|---|
| A service of yours, acting as itself | Client credentials with a key pair | No shared secret; tokens last minutes |
| A CLI or an AI agent acting for you | The device flow | You approve in the browser; nothing is pasted |
| An MCP client (Claude, Cursor) | MCP with OAuth | The protocol MCP specifies |
| A quick script or an integration | A personal access token | One string, scoped, revocable |
| Your app in a browser or a phone | The publishable key plus the user’s session | Row-level security decides |
| A trusted server that needs everything | A secret key | Full access; never in a browser |
Any token can be made sender-constrained with DPoP: it then works only with a proof signed by the caller’s private key.
A service signs in as itself with a key pair (private_key_jwt) or a secret, and gets a short token with the scopes it needs.
Make a token useless to anyone who steals it, by binding it to the caller's private key with DPoP (RFC 9449).
The device flow, for CLIs and AI agents
How a CLI or an AI agent signs in for you without anyone pasting a secret, keeps a session that can last forever, and how you revoke it.
Personal access tokens and API keys
Long-lived tokens that act as a user, and the publishable and secret keys of a project, with their formats, scopes and how to revoke them.
Connect Claude, Cursor or any MCP client to Sypnia Data with OAuth, at one address for every project, and the tools it can call.
Scopes
A machine token carries scopes. The built-in ones:
| Scope | Allows |
|---|---|
data:read, data:write | the Data API, as the client’s database role |
sql:read, sql:write | the SQL endpoint (read-only or not) |
auth:admin | the auth admin API (users, sessions) |
project:admin | everything, as service_role |
Projects can define their own scopes and check them in policies with sypnia.scopes().
Who may hold the privileged scopes
sql:read, sql:write, auth:admin and project:admin reach the owner role or the admin API, so nobody gets them by signing up:
- A machine client (client credentials) gets them from its registration, which only an admin creates with the secret key.
- A person gets them only if an admin lists them in the user’s
app_metadata.scopeswith the secret key:PUT /auth/v1/admin/users/{id}with{"app_metadata": {"scopes": ["sql:read"]}}. Without that, a PAT, a device approval or a consent that asks for one fails with403 scope_not_allowed. A token issued earlier loses the scope at its next use (within 60 seconds) once the admin takes it back. - With no
scopenamed, the device flow and the authorization code flow ask only for the non-privileged scopes of the client. - Open dynamic client registration never grants them.
Changes to the account itself (password, e-mail, PATs, sessions, linked identities) need the person’s own session. A PAT or an app acting for the person cannot make them.