Python SDK
Install and start using the Python SDK.
Intro
The env zero API SDK provides access to the env zero API REST APIs.
This document describes the resources that make up the official env zero REST API.
Base URL
https://api.env0.com
Content types
All requests should be in JSON format and include the accept: application/json header.
Authentication
HTTP Basic authentication. Send the API Key ID as the username and the API Key Secret as the password. Keys are created under Organization Settings -> API Keys (Admin or User scope) or Personal Settings -> API Keys (Personal scope).
Scope of this document
This specification covers the environment drift-governance surface of the env zero API and the environment, deployment, template, configuration and project endpoints that support it. It was reconstructed from the OpenAPI fragments published on https://docs.envzero.com and is a subset of the full API.
Error responses
401 and 403 responses return { "message": string } and are documented on every operation. The upstream documentation does not define response bodies for other non-2xx status codes, so none are asserted here.
Installation
Add the SDK to your project from its folder, with whichever package manager your project uses. Give each tool a path containing a slash, such as ../env-zero-api — a bare folder name is looked up on PyPI instead, and resolves to whatever project holds that name there:
pip install <path-to-sdk>uv add <path-to-sdk>poetry add <path-to-sdk>Quick Start
Synchronous client
Construct EnvZeroApiClient with keyword arguments, and call close() when you are done. Every argument is optional.
from env_zero_api import EnvZeroApiClient
from env_zero_api.core import BasicAuthCredentials
client = EnvZeroApiClient(env0_api_key=BasicAuthCredentials(username="YOUR_USERNAME", password="YOUR_PASSWORD"))
client.close()Alternatively, scope it — with EnvZeroApiClient(...) as client: closes the pool on exit.
Asynchronous client
AsyncEnvZeroApiClient mirrors EnvZeroApiClient with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences — for example, the transport argument is custom_async_http_client.
from asyncio import run
from env_zero_api import AsyncEnvZeroApiClient
from env_zero_api.core import BasicAuthCredentials
async def main() -> None:
client = AsyncEnvZeroApiClient(
env0_api_key=BasicAuthCredentials(username="YOUR_USERNAME", password="YOUR_PASSWORD")
)
await client.aclose()
run(main())Alternatively, scope it — async with AsyncEnvZeroApiClient(...) as client: closes the pool on exit.