Client credentials
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.
On this page
Create a client
In the console → Machines → OAuth clients, or with the API:
curl -X POST https://<ref>.data.sypnia.com/auth/v1/admin/oauth/clients \
-H "apikey: syp_sk_…" -H "content-type: application/json" \
-d '{ "name": "billing-worker", "token_endpoint_auth_method": "private_key_jwt",
"jwks": { "keys": [ { "kty": "OKP", "crv": "Ed25519", "x": "…", "kid": "bw-1" } ] },
"scopes": ["data:read", "data:write"], "dpop_bound_access_tokens": true }'The answer has the client_id (cli_…). With a key pair, the private key never leaves your service: the engine only knows the public half.
| Authentication | When |
|---|---|
private_key_jwt | Recommended. Nothing secret is stored by the engine; keys rotate by adding a new public key. |
client_secret_basic / client_secret_post | When a key pair is not possible. The secret (syp_cs_…) is shown once and stored as an argon2id hash. |
Get a token
Sign a short JWT with your private key (RFC 7523) and send it:
POST /auth/v1/oauth/token
content-type: application/x-www-form-urlencoded
grant_type=client_credentials
&client_id=cli_8fK2…
&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
&client_assertion=<JWT: iss=sub=cli_8fK2…, aud=https://<ref>.data.sypnia.com/auth/v1/oauth/token, exp=now+60, jti=random>
&scope=data:read data:write{ "access_token": "eyJ…", "token_type": "DPoP", "expires_in": 900, "scope": "data:read data:write" }- The assertion lives at most 5 minutes and its
jtiworks once. scopemust be within the client’s allowed scopes;resource(RFC 8707) picks the audience when the client may call several.- Client tokens last 15 minutes by default; ask for a new one when it expires. There is no refresh token for client credentials.
What the token can do
The client calls the Data API and SQL like anyone else. By default it runs as the authenticated role with sub set to its client_id, so your row-level security applies to machines too: write policies with sypnia.client_id(). A client with project:admin runs as service_role.
@sypnia/data/server does all of this for you:
import { createClient } from '@sypnia/data/server';
const sypnia = createClient(url, { client: { id: 'cli_8fK2…', privateKey: process.env.SYPNIA_CLIENT_KEY!, dpop: true } });