Principal types
DynamoSQL recognizes two principal types:| Type | Description | How to authenticate |
|---|---|---|
| Portal user | Human user who logged in via the DynamoSQL portal | Passkey or password + TOTP; portal issues a session |
| API client | Machine-to-machine service account created in the portal | OAuth 2.0 client credentials grant |
/v1/query endpoint is intended for API clients. Portal users typically interact through the portal’s SQL editor.
OAuth 2.0 client credentials
API clients authenticate with the Cognito token endpoint using the client credentials grant:access_token (JWT) and expires_in (seconds). Tokens are valid for one hour.
Required scopes
| Scope | Required for |
|---|---|
query:execute | POST /v1/query with mode: "execute" |
query:plan | POST /v1/query with mode: "plan" |
query:plan only.
Passing the bearer token
Include the token in theAuthorization header on every request:
Token refresh
Tokens cannot be refreshed with the client credentials grant. When a token expires, simply request a new one using the same credentials exchange. Cache the token and re-request it when you receive a401 response.
Tenant scoping
Every JWT issued by Cognito carries atenantId claim. The Lambda handler reads this claim and scopes all DynamoDB access to that tenant’s tables. You cannot query another tenant’s data.
The tenantId field in the request body is optional. If provided, it must match the tenantId in the JWT — a mismatch returns 403.
Non-production environment
Useauth.dev.dynamosql.com and api.dev.dynamosql.com for testing. Credentials are separate per environment.