Documentation menu

Tools

Python client

load_env and the Envpass client for Python 3.9+.

Terminal
pip install envpass-cli    # or: uv add envpass-cli

The package supports Python 3.9+ and has no dependencies. Import it as envpass.

Load values into os.environ

Python
from envpass import load_env

load_env("prod", service="api")

load_env reads the token from ENVPASS_TOKEN or the CLI login and scope from its arguments, ENVPASS_* variables or .envpass.json. Existing variables are kept unless you pass override=True. It returns the loaded values as a dict.

Client

Python
from envpass import Envpass

client = Envpass(token="ep_live_...")

entries = client.resolve({"environment": "prod"})
# [{"key": "DATABASE_URL", "value": "postgres://...", "source": "shared"}, ...]

text = client.resolve_text({"environment": "prod"}, "dotenv")
me = client.me()

Any REST endpoint is available through request:

Python
workspaces = client.request("GET", "/api/v1/workspaces")["workspaces"]
client.request(
    "PUT",
    f"/api/v1/workspaces/{workspace_id}/projects/{project_id}/secrets",
    body={"environmentId": env_id, "entries": [{"key": "FEATURE_FLAG", "value": "on"}]},
)

Django and FastAPI

Call load_env before settings are read:

Python
# settings.py or main.py
from envpass import load_env

load_env()  # uses .envpass.json and ENVPASS_TOKEN

Errors

Methods raise envpass.EnvpassError with status and code:

Python
from envpass import EnvpassError

try:
    client.resolve({"environment": "prod"})
except EnvpassError as error:
    if error.code == "forbidden":
        print("This token can't read prod")