Docs Ordnary Web Services Ordnary Serverlite
API tokens
Create tokens for your apps, choose between read-only and read and write, limit a token to one database, and rotate or revoke it.
Your apps authenticate to the Query API with API tokens. Create them in the console under Ordnary Serverlite, API tokens. A token starts with osq_, so it is easy to recognise in code and in secret scanners.
Access
| Feature | Read only | Read and write |
|---|---|---|
| SELECT, WITH ... SELECT, VALUES, EXPLAIN | ||
| INSERT, UPDATE, DELETE | ||
| CREATE, ALTER, DROP (migrations) | ||
| PRAGMA, transactions |
One database or all
A token can reach every database of the account, or be limited to one. Limit it whenever you can: a token for your production app has no business reaching your staging database. Deleting a database also revokes the tokens limited to it.
Good practice
Do
- One token per app or environment, named after it.
- Read only for dashboards, reports and anything in a browser.
- The token in an environment variable or secret store.
- Revoke a token the moment it may have leaked.
Don't
- One read and write token shared by everything.
- A read and write token in front-end code.
- The token committed to a repository.
- Waiting to see whether a leaked token gets used.
Rotate a token
- 1
Create a new token
With the same access and database as the old one.
- 2
Deploy it
Replace the secret in your app's environment and deploy.
- 3
Check Last used
Once the old token's Last used date stops moving, nothing uses it anymore.
- 4
Revoke the old token
Revoking takes effect immediately.