REST API v1
Use the REST API to load resolved environment values at runtime.
The base URL is https://api.envlet.dev.
Authentication
Section titled “Authentication”Send your environment token as a bearer token on every request:
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 all values
Section titled “Get all values”GET /v1/values returns every value that the token identity may read.
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.
Dotenv format
Section titled “Dotenv format”Set the format query parameter to dotenv to get a text/plain dotenv body.
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 one value
Section titled “Get one value”GET /v1/values/:name returns one resolved environment value.
Replace :name with the variable name.
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
Section titled “Errors”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. |