Rivergate

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

Authentication

Three kinds of caller are accepted on /api/v1. All of them go through the same identity and authorization checks.

CallerHowCSRF
Browser sessionHttpOnly session cookie after OIDC sign-inRequired on mutations: send the rivergate_csrf cookie value as X-CSRF-Token
Personal API tokenAuthorization: Bearer TOKENNot used
Workload tokenAuthorization: Bearer TOKEN from a token exchangeNot 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 },
});

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" } }
StatusCodeMeaning
401unauthenticatedThe session or token is missing, expired, revoked or invalid.
403forbiddenAuthenticated, but outside your effective policies.
403csrf_failedA browser mutation lacked a valid CSRF header.
404not_foundThe resource is missing, or not available to you.
503service_unavailableA dependency or durable operation is unavailable. No secret value is returned if its read could not be audited.

Pagination

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 pathPurpose
GET /api/v1/organizationsList organizations you belong to.
POST /api/v1/organizationsCreate 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 /membersList members; grant or change a member’s role.
DELETE /members/{principal}Suspend a member and revoke their bindings.
GET · POST /policiesList or grant scoped policy bindings.
DELETE /policies/{binding}Revoke a binding.
GET /keysKey metadata for the organization.
GET /auditAudit events.

Projects, environments and secrets

Method and pathPurpose
GET · POST /projectsList or create projects.
GET · PUT · DELETE /projects/{project}Read, update or soft-delete a project.
GET · POST …/environmentsList or create environments.
GET · PUT · DELETE …/environments/{environment}Read, update or soft-delete an environment.
GET · POST …/secretsList secret metadata; create a secret.
GET · PUT · DELETE …/secrets/{secret}Read metadata, append a version, or soft-delete.
GET …/secrets/{secret}/valueCurrent value (explicit, audited).
GET …/secrets/{secret}/versionsVersion history, no values.
GET …/secrets/{secret}/versions/{version}A specific historical value (explicit, audited).
POST …/secrets/{secret}/rollbackMake a historical value the new current version.

Rotation and dynamic credentials

Method and pathPurpose
POST · GET /key-rotationsStart and inspect an organization key rotation.
POST · GET /projects/{project}/key-rotationsStart and inspect a project key rotation.
GET · PUT · DELETE …/secrets/{secret}/rotation-policyManage a replacement schedule.
GET …/secrets/{secret}/rotation-requestsList pending and completed replacement requests.
GET · POST …/dynamic-credential-providersList or register PostgreSQL providers.
POST …/dynamic-credential-providers/{provider}/leasesIssue a lease. Requires Idempotency-Key.
GET · DELETE …/dynamic-credential-leases/{lease}Inspect or revoke a lease.
POST …/dynamic-credential-leases/{lease}/renewRenew a lease. Requires Idempotency-Key.

Authentication and platform

Method and pathPurpose
POST /auth/local/login · /auth/local/passwordBootstrap and recovery sign-in; password change.
GET /auth/oidc/login · /auth/oidc/callbackOIDC sign-in.
GET · PUT /auth/oidc/provider · GET /auth/oidc/statusRead and configure the provider.
GET /auth/identitiesList identities.
POST /auth/identities/{principal}/system-adminGrant system administration.
PUT /auth/identities/{principal}/statusDisable or re-enable an identity.
GET /auth/session · POST /auth/logoutInspect 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/observabilityLive health and operational measurements (system administrators).
GET /health/live · /health/ready · /openapi.yamlProbes and the contract.

Operational notes