REST API
A single versioned JSON API is the integration boundary for the dashboard, CLI, SDK and Operator. Nothing talks to the database directly.
Overview
- Base path. Resource routes live under
/api/v1. Authentication routes live under/auth. - Contract. The canonical OpenAPI 3.1 document is api/openapi.yaml in the core repository. A running API serves it at
GET /openapi.yaml. - Format. Requests and responses are JSON.
- Transport. Use HTTPS for every deployed instance. Never put secret values in URLs, query strings, headers or logs.
- Caching. Responses use
Cache-Control: no-store.
Authentication
Three kinds of caller are accepted on /api/v1. All of them go through the same identity and authorization checks.
| Caller | How | CSRF |
|---|---|---|
| Browser session | HttpOnly session cookie after OIDC sign-in | Required on mutations: send the rivergate_csrf cookie value as X-CSRF-Token |
| Personal API token | Authorization: Bearer TOKEN | Not used |
| Workload token | Authorization: Bearer TOKEN from a token exchange | Not used |
Details are in Authentication.
Create a personal token
Tokens are issued only from a signed-in browser session, with CSRF validation. Sign in to the dashboard, then open /health/live on the API origin in a new tab and run this in the browser developer console. It copies the token to your clipboard without printing it.
const csrfCookie = document.cookie.split("; ").find((p) => p.startsWith("rivergate_csrf="));
if (!csrfCookie) throw new Error("Rivergate CSRF cookie is missing");
const csrf = decodeURIComponent(csrfCookie.slice("rivergate_csrf=".length));
const response = await fetch("/auth/tokens", {
method: "POST",
credentials: "same-origin",
headers: { "Content-Type": "application/json", "X-CSRF-Token": csrf },
body: JSON.stringify({ name: "rivergate-cli", expires_in_days: 30 }),
});
const result = await response.json();
if (!response.ok) throw new Error(result.error?.code ?? "token creation failed");
await navigator.clipboard.writeText(result.token);
console.log(result.item);
Paste the token straight into rivergate auth login through standard input. To revoke it later, call DELETE /auth/tokens/{id} from the same signed-in context with the CSRF header, using the item.id printed above.
await fetch(`/auth/tokens/${result.item.id}`, {
method: "DELETE",
credentials: "same-origin",
headers: { "X-CSRF-Token": csrf },
});
- Tokens expire within 90 days, are shown once, and inherit your current permissions.
GET /auth/tokenslists token metadata only.- These are user tokens. Keep expiry short and grant the user only the access that client needs.
Errors
Errors use one shape. Messages are safe to show to callers, and the request ID lets you correlate with server logs.
{ "error": { "code": "forbidden", "message": "Operation not permitted", "request_id": "REQUEST_ID" } }
| Status | Code | Meaning |
|---|---|---|
| 401 | unauthenticated | The session or token is missing, expired, revoked or invalid. |
| 403 | forbidden | Authenticated, but outside your effective policies. |
| 403 | csrf_failed | A browser mutation lacked a valid CSRF header. |
| 404 | not_found | The resource is missing, or not available to you. |
| 503 | service_unavailable | A dependency or durable operation is unavailable. No secret value is returned if its read could not be audited. |
Pagination
- Lists return an
itemsarray. - Secrets use
cursor(the last returned secret ID) andlimit(maximum 100). - Version history uses
beforeandlimit. - Metadata and version listings never include values or ciphertext.
Reading and writing a secret
BASE=/api/v1/organizations/ORG_ID/projects/PROJECT_ID/environments/ENVIRONMENT_ID
# Create (returns metadata only)
curl -sS -X POST "https://rivergate.example.com$BASE/secrets" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
--data @secret-request.json
# Read the current value (explicit, audited)
curl -sS "https://rivergate.example.com$BASE/secrets/SECRET_ID/value" \
-H "Authorization: Bearer $TOKEN"
Keep secret-request.json owner-only and delete it afterwards. Request bodies may be up to 6 MiB; secret values up to 1 MiB.
Route reference
Paths below are relative to /api/v1/organizations/{organization} unless shown in full. See the OpenAPI contract for schemas.
Organizations and access
| Method and path | Purpose |
|---|---|
GET /api/v1/organizations | List organizations you belong to. |
POST /api/v1/organizations | Create an organization (system identity administration). Makes the caller its initial owner and creates its key. |
GET · PUT / | Read or rename an organization. Slug and ID are immutable. |
GET · POST /members | List members; grant or change a member’s role. |
DELETE /members/{principal} | Suspend a member and revoke their bindings. |
GET · POST /policies | List or grant scoped policy bindings. |
DELETE /policies/{binding} | Revoke a binding. |
GET /keys | Key metadata for the organization. |
GET /audit | Audit events. |
Projects, environments and secrets
| Method and path | Purpose |
|---|---|
GET · POST /projects | List or create projects. |
GET · PUT · DELETE /projects/{project} | Read, update or soft-delete a project. |
GET · POST …/environments | List or create environments. |
GET · PUT · DELETE …/environments/{environment} | Read, update or soft-delete an environment. |
GET · POST …/secrets | List secret metadata; create a secret. |
GET · PUT · DELETE …/secrets/{secret} | Read metadata, append a version, or soft-delete. |
GET …/secrets/{secret}/value | Current value (explicit, audited). |
GET …/secrets/{secret}/versions | Version history, no values. |
GET …/secrets/{secret}/versions/{version} | A specific historical value (explicit, audited). |
POST …/secrets/{secret}/rollback | Make a historical value the new current version. |
Rotation and dynamic credentials
| Method and path | Purpose |
|---|---|
POST · GET /key-rotations | Start and inspect an organization key rotation. |
POST · GET /projects/{project}/key-rotations | Start and inspect a project key rotation. |
GET · PUT · DELETE …/secrets/{secret}/rotation-policy | Manage a replacement schedule. |
GET …/secrets/{secret}/rotation-requests | List pending and completed replacement requests. |
GET · POST …/dynamic-credential-providers | List or register PostgreSQL providers. |
POST …/dynamic-credential-providers/{provider}/leases | Issue a lease. Requires Idempotency-Key. |
GET · DELETE …/dynamic-credential-leases/{lease} | Inspect or revoke a lease. |
POST …/dynamic-credential-leases/{lease}/renew | Renew a lease. Requires Idempotency-Key. |
Authentication and platform
| Method and path | Purpose |
|---|---|
POST /auth/local/login · /auth/local/password | Bootstrap and recovery sign-in; password change. |
GET /auth/oidc/login · /auth/oidc/callback | OIDC sign-in. |
GET · PUT /auth/oidc/provider · GET /auth/oidc/status | Read and configure the provider. |
GET /auth/identities | List identities. |
POST /auth/identities/{principal}/system-admin | Grant system administration. |
PUT /auth/identities/{principal}/status | Disable or re-enable an identity. |
GET /auth/session · POST /auth/logout | Inspect or end a session. |
GET · POST /auth/tokens · DELETE /auth/tokens/{token} | Personal API tokens. |
/auth/workload/… | Kubernetes cluster trust, mappings and token exchange. See Operator. |
GET /api/v1/system/observability | Live health and operational measurements (system administrators). |
GET /health/live · /health/ready · /openapi.yaml | Probes and the contract. |
Operational notes
- The API does not apply distributed rate limiting and has no request idempotency keys for secret writes (dynamic credential operations do require them). Apply rate limits at your ingress.
- Request logs never include request bodies.
- Use the
request_idin an error to find the matching server log line.