TypeScript SDK

Install and start using the TypeScript 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

The SDK compiles to dist/ before it can be referenced — run its build script once in the SDK folder, then add it to your project by path:

Terminal
npm install <path-to-sdk>

Quick Start

Create one client and reuse it. Configure its behaviour through ClientOptions.

TypeScript
import { EnvZeroApiClient } from "env-zero-api";

const client = new EnvZeroApiClient({
  env0ApiKey: { username: "YOUR_USERNAME", password: "YOUR_PASSWORD" },
});

Nothing in ClientOptions is required — new EnvZeroApiClient() compiles — and each option left out falls back to its default. This API declares one environment, so there is no environment to select and no host to state at the construction site.

From CommonJS

The package ships both dialects from a single entry, so require works with full types. In a TypeScript CommonJS file use the import ... = require(...) form — a plain destructuring require runs fine but gives you any.

TypeScript
import sdk = require("env-zero-api");

const client = new sdk.EnvZeroApiClient({
  env0ApiKey: { username: "YOUR_USERNAME", password: "YOUR_PASSWORD" },
});

On this page