varsafe API
varsafe stores environment variables — database URLs, API keys, signing secrets — encrypted at rest, and hands them to the process that needs them without writing a .env file to disk.
When to use this API
- Inject a project environment into a process or pipeline (
GET /secrets/inject). - Read one secret value at the moment it is needed (
GET /secrets/value), rather than caching a whole environment. - Create, update or delete secrets from automation (
POST /secrets,POST /secrets/bulk). - Discover what a credential may do before acting (
GET /me/cli,GET /capabilities).
If you are an AI agent, prefer the Model Context Protocol endpoint at POST /mcp over these REST routes: it exposes the same capabilities as typed tools with per-tool scope enforcement and a consent step. See https://docs.varsafe.dev/guides/mcp.
Authentication
Read the security field on each operation — it is derived from what the guards and handlers actually accept, and it is not uniform.
Most routes take an API token (Authorization: Bearer …), created self-serve in the dashboard and scopable to a project, an environment and read-only access. Routes carrying x-varsafe-cli-scopes also accept a CLI grant from the device authorization flow and enforce the listed scopes. Four routes are narrower: GET /me/cli and POST /auth/cli/logout answer only to a CLI grant, because both describe or revoke that grant itself; POST /auth/cli/device/token and GET /auth/cli/device/events authenticate with the device code rather than an account. GET /me accepts a session or a CLI grant but not an API token. The MCP endpoint at POST /mcp uses OAuth 2.1, or an API token, with the scope vocabulary in components.securitySchemes.varsafeMcpOAuth.
Responses
Every operation documents its success body with a JSON Schema under components.schemas, and every failure with the body the server actually sends: ErrorResponse (branch on its code) for REST routes, OAuthErrorResponse and JsonRpcErrorResponse for the MCP transport. The schemas are generated from the same Zod definitions the handlers are type-checked against and that the @varsafe/shared package exports. Objects list the properties sent today; a later release may add one, so ignore properties you do not recognise. Streaming routes (text/event-stream) describe their events in prose.
Scope of this document
This is the programmatic surface: the routes a token, a CLI grant or an agent may call. Dashboard-only and administrative routes are intentionally not described here. The same document is served at https://varsafe.dev/openapi.json and https://api.varsafe.dev/openapi.json.
https://api.varsafe.devCapabilities
What this deployment supports, so a client can adapt instead of probing.
CliDeviceAuth
Device authorization grant — how a CLI or an unattended agent obtains a credential.
- POSTStart device authorization
/auth/cli/device - POSTExchange a device code for a CLI credential
/auth/cli/device/token - GETStream device-approval events
/auth/cli/device/events
CliSession
Lifecycle of a CLI grant, including self-revocation.
Environments
Environments within a project — development, staging, production, and any others.
Health
Liveness and readiness probes.
Keypairs
Per-environment keypairs used to encrypt values into a committable .env file.
- GETGet an environment public key
/environments/{envId}/keypair - POSTGet or create an environment sealing key
/environments/{envId}/sealing-key - POSTOpen an encrypted .env file
/environments/{envId}/sealed-values/open
McpTransport
Model Context Protocol endpoint over Streamable HTTP.
- POSTMCP transport (JSON-RPC request)
/mcp - GETMCP transport (no event stream)
/mcp - DELETEMCP transport (end session)
/mcp
Me
The identity and authority behind the calling credential.
- GETVerify the calling credential
/me/verify - DELETERevoke the calling API token
/me/token - GETGet the current identity
/me - GETGet the CLI grant behind the credential
/me/cli
OAuthProviderWellKnown
RFC 8414 and RFC 9728 discovery documents for the OAuth 2.1 flow.
- GETOAuth 2.1 authorization server metadata
/.well-known/oauth-authorization-server - GETProtected resource metadata
/.well-known/oauth-protected-resource - GETProtected resource metadata for the MCP endpoint
/.well-known/oauth-protected-resource/mcp
Projects
Projects, the top-level grouping that owns environments and secrets.
PublicOpenApi
This contract, as a machine-readable document.
SecretComposition
How secrets reference one another through ${KEY} templates.
Secrets
Reading, writing and resolving secrets. The core of the API.
- POSTCreate a secret
/secrets - GETList secrets
/secrets - POSTCreate or update secrets in bulk
/secrets/bulk - GETList secrets with values
/secrets/with-values - GETRead one secret value
/secrets/value - GETResolve an environment for injection
/secrets/inject - GETDiff two environments
/secrets/diff - DELETEDelete a secret
/secrets/{secretId} - POSTDelete secrets in bulk
/secrets/delete-bulk