Skip to content

REST API v1

Use the REST API to load resolved environment values at runtime. The base URL is https://api.envlet.dev.

Send your environment token as a bearer token on every request:

Terminal window
curl --fail-with-body \
--request GET \
--url "https://api.envlet.dev/v1/values" \
--header "Authorization: Bearer $ENVLET_TOKEN"

The token identifies one project environment and one identity. Envlet applies that identity’s policy before it returns any values. Shared values stay unchanged, overrides replace shared values, and withheld keys are absent.

GET /v1/values returns every value that the token identity may read.

Terminal window
curl --fail-with-body \
--request GET \
--url "https://api.envlet.dev/v1/values" \
--header "Authorization: Bearer $ENVLET_TOKEN"

A successful JSON response has this shape:

{ "values": { "KEY": "value" } }

The values object maps each environment variable name to its resolved value. A withheld key does not appear in the object. An override appears in place of the shared value.

Set the format query parameter to dotenv to get a text/plain dotenv body.

Terminal window
curl --fail-with-body \
--request GET \
--url "https://api.envlet.dev/v1/values?format=dotenv" \
--header "Authorization: Bearer $ENVLET_TOKEN"

The response contains one KEY=value assignment per line. Use format=json or omit the parameter to get the JSON response. Any other format value returns invalid_request.

GET /v1/values/:name returns one resolved environment value. Replace :name with the variable name.

Terminal window
curl --fail-with-body \
--request GET \
--url "https://api.envlet.dev/v1/values/DATABASE_URL" \
--header "Authorization: Bearer $ENVLET_TOKEN"

A successful response has this shape:

{ "name": "DATABASE_URL", "value": "..." }

The endpoint returns 404 not_found when the variable is absent. It returns the same response when the identity’s policy withholds the variable. This rule prevents the identity from learning whether a withheld variable exists.

Errors use this JSON envelope:

{ "error": { "code": "unauthorized", "message": "bearer token is invalid" } }

Use the HTTP status for request flow and the code for program logic. Expired tokens have a separate code so your system can alert before you replace the token.

HTTP status Code Meaning
401 unauthorized The bearer token is missing or invalid.
401 token_expired The bearer token has expired.
404 not_found The requested value is absent or withheld.
400 invalid_request The request is invalid, such as an unsupported format value.