Skip to content
Esc
↑↓navigate↵open⌘Jpreview

Create a secret

Creates one secret in a project environment. Fails rather than overwrites when the key already exists.

POST/secrets
Authorization
AuthorizationBearer token (varsafe API token) · headerrequired

A team-scoped API token, created self-serve in the dashboard and presented as Authorization: Bearer <token>. A token can be restricted to specific projects and environments and to read-only access. Intended for CI pipelines and unattended automation.

or
AuthorizationBearer token (varsafe CLI grant) · headerrequired

An opaque, database-backed credential obtained through the device authorization grant (POST /auth/cli/device) and revocable on the spot. Presented as Authorization: Bearer <token>. A route accepts it only when it declares CLI access; the scopes it must hold are listed per operation under x-varsafe-cli-scopes.

or
__Secure-varsafe.session_tokenAPI key · cookierequired

The browser session cookie issued to the dashboard (named varsafe.session_token without the __Secure- prefix on non-production deployments). Listed for completeness: it authorizes the same routes, but programmatic callers should use an API token or a CLI grant.

Request body
requiredapplication/json
projectIdstring<uuid>required
matches ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
environmentstringrequired
min length 1 · max length 50 · matches ^[a-z0-9][a-z0-9-]*$
keystringrequired
min length 1 · max length 255 · matches ^[A-Z][A-Z0-9_]*$
kindstring
Allowed:literaltemplate
valuestring
max length 65536
sourcestring
max length 65536
expectedVersioninteger
min 0 · max 9007199254740991
Responses
201

Success.

idstring<uuid>required
projectIdstring<uuid>required
environmentstringrequired
min length 1 · max length 50 · matches ^[a-z0-9][a-z0-9-]*$
keystringrequired
min length 1 · max length 255
versionintegerrequired
max 9007199254740991
createdAtstring<date-time>required
updatedAtstring<date-time>required
400

The request failed validation. field names the offending input.

statusCodeintegerrequired

HTTP status code, repeated in the body.

min -9007199254740991 · max 9007199254740991
codestringrequired

Stable machine-readable error code, e.g. SECRET_NOT_FOUND or FORBIDDEN. Branch on this, never on the message.

messagestringrequired

Human-readable explanation. Wording may change.

fieldstring

The offending request field, present on validation failures.

401

No credential was presented, or it is invalid or revoked.

statusCodeintegerrequired

HTTP status code, repeated in the body.

min -9007199254740991 · max 9007199254740991
codestringrequired

Stable machine-readable error code, e.g. SECRET_NOT_FOUND or FORBIDDEN. Branch on this, never on the message.

messagestringrequired

Human-readable explanation. Wording may change.

fieldstring

The offending request field, present on validation failures.

403

The credential is valid but lacks the required scope, role or team access.

statusCodeintegerrequired

HTTP status code, repeated in the body.

min -9007199254740991 · max 9007199254740991
codestringrequired

Stable machine-readable error code, e.g. SECRET_NOT_FOUND or FORBIDDEN. Branch on this, never on the message.

messagestringrequired

Human-readable explanation. Wording may change.

fieldstring

The offending request field, present on validation failures.

404

The resource does not exist, or is not visible to this credential.

statusCodeintegerrequired

HTTP status code, repeated in the body.

min -9007199254740991 · max 9007199254740991
codestringrequired

Stable machine-readable error code, e.g. SECRET_NOT_FOUND or FORBIDDEN. Branch on this, never on the message.

messagestringrequired

Human-readable explanation. Wording may change.

fieldstring

The offending request field, present on validation failures.

429

Rate limited. Retry after the interval named in the response.

statusCodeintegerrequired

HTTP status code, repeated in the body.

min -9007199254740991 · max 9007199254740991
codestringrequired

Stable machine-readable error code, e.g. SECRET_NOT_FOUND or FORBIDDEN. Branch on this, never on the message.

messagestringrequired

Human-readable explanation. Wording may change.

fieldstring

The offending request field, present on validation failures.

500

Unexpected server error. The body never carries internal detail.

statusCodeintegerrequired

HTTP status code, repeated in the body.

min -9007199254740991 · max 9007199254740991
codestringrequired

Stable machine-readable error code, e.g. SECRET_NOT_FOUND or FORBIDDEN. Branch on this, never on the message.

messagestringrequired

Human-readable explanation. Wording may change.

fieldstring

The offending request field, present on validation failures.

Try it
Server
Authorization
Bodyapplication/json
Request
curl -X POST 'https://api.varsafe.dev/secrets' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "projectId": "5a8591dd-4039-49df-9202-96385ba3eff8",
  "environment": "string",
  "key": "string",
  "kind": "literal",
  "value": "string",
  "source": "string",
  "expectedVersion": 0
}'
Response
{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "projectId": "5a8591dd-4039-49df-9202-96385ba3eff8",
  "environment": "string",
  "key": "string",
  "version": 1,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z"
}