curl --request GET \
--url https://api.env0.com/audit/events \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.env0.com/audit/events"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.env0.com/audit/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.env0.com/audit/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.env0.com/audit/events"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Basic <encoded-value>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.env0.com/audit/events")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.env0.com/audit/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"events": [
{
"actorId": "<string>",
"actionName": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"id": "<string>",
"organizationId": "<string>",
"actor": {
"email": "<string>",
"user_id": "<string>",
"username": "<string>",
"created_at": "<string>",
"updated_at": "<string>",
"app_metadata": {
"organizations": [
{
"id": "<string>",
"role": "<string>",
"name": "<string>"
}
],
"isApiKey": true,
"isAutogeneratedTerraformDeployer": true,
"apiKeyType": "oidc",
"createdBy": "<string>",
"organizationId": "<string>",
"isSystemUser": true,
"readOnly": true
},
"picture": "<string>",
"name": "<string>",
"last_login": "<string>",
"given_name": "<string>",
"family_name": "<string>",
"blocked": true,
"identities": [
{
"provider": "<string>",
"connection": "<string>",
"user_id": "<string>",
"isSocial": true,
"access_token": "<string>",
"refresh_token": "<string>"
}
]
},
"projectId": "<string>",
"ipAddress": "<string>",
"payload": {},
"source": "<string>",
"onBehalfOf": "<string>",
"attributedTo": "<string>",
"attributedToUser": {
"email": "<string>",
"user_id": "<string>",
"username": "<string>",
"created_at": "<string>",
"updated_at": "<string>",
"app_metadata": {
"organizations": [
{
"id": "<string>",
"role": "<string>",
"name": "<string>"
}
],
"isApiKey": true,
"isAutogeneratedTerraformDeployer": true,
"apiKeyType": "oidc",
"createdBy": "<string>",
"organizationId": "<string>",
"isSystemUser": true,
"readOnly": true
},
"picture": "<string>",
"name": "<string>",
"last_login": "<string>",
"given_name": "<string>",
"family_name": "<string>",
"blocked": true,
"identities": [
{
"provider": "<string>",
"connection": "<string>",
"user_id": "<string>",
"isSocial": true,
"access_token": "<string>",
"refresh_token": "<string>"
}
]
},
"entityType": "environment",
"entityId": "<string>"
}
],
"nextPageKey": "<string>",
"searchedUntil": "<string>"
}Fetch Audit Logs
curl --request GET \
--url https://api.env0.com/audit/events \
--header 'Authorization: Basic <encoded-value>'import requests
url = "https://api.env0.com/audit/events"
headers = {"Authorization": "Basic <encoded-value>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Basic <encoded-value>'}};
fetch('https://api.env0.com/audit/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.env0.com/audit/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.env0.com/audit/events"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Basic <encoded-value>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.env0.com/audit/events")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.env0.com/audit/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"events": [
{
"actorId": "<string>",
"actionName": "<string>",
"timestamp": "2023-11-07T05:31:56Z",
"id": "<string>",
"organizationId": "<string>",
"actor": {
"email": "<string>",
"user_id": "<string>",
"username": "<string>",
"created_at": "<string>",
"updated_at": "<string>",
"app_metadata": {
"organizations": [
{
"id": "<string>",
"role": "<string>",
"name": "<string>"
}
],
"isApiKey": true,
"isAutogeneratedTerraformDeployer": true,
"apiKeyType": "oidc",
"createdBy": "<string>",
"organizationId": "<string>",
"isSystemUser": true,
"readOnly": true
},
"picture": "<string>",
"name": "<string>",
"last_login": "<string>",
"given_name": "<string>",
"family_name": "<string>",
"blocked": true,
"identities": [
{
"provider": "<string>",
"connection": "<string>",
"user_id": "<string>",
"isSocial": true,
"access_token": "<string>",
"refresh_token": "<string>"
}
]
},
"projectId": "<string>",
"ipAddress": "<string>",
"payload": {},
"source": "<string>",
"onBehalfOf": "<string>",
"attributedTo": "<string>",
"attributedToUser": {
"email": "<string>",
"user_id": "<string>",
"username": "<string>",
"created_at": "<string>",
"updated_at": "<string>",
"app_metadata": {
"organizations": [
{
"id": "<string>",
"role": "<string>",
"name": "<string>"
}
],
"isApiKey": true,
"isAutogeneratedTerraformDeployer": true,
"apiKeyType": "oidc",
"createdBy": "<string>",
"organizationId": "<string>",
"isSystemUser": true,
"readOnly": true
},
"picture": "<string>",
"name": "<string>",
"last_login": "<string>",
"given_name": "<string>",
"family_name": "<string>",
"blocked": true,
"identities": [
{
"provider": "<string>",
"connection": "<string>",
"user_id": "<string>",
"isSocial": true,
"access_token": "<string>",
"refresh_token": "<string>"
}
]
},
"entityType": "environment",
"entityId": "<string>"
}
],
"nextPageKey": "<string>",
"searchedUntil": "<string>"
}Authorizations
env zero API authentication is done via API keys. An API Key can either be created by an organization administrator, in which case it will not be connected to any specific user, or via Personal API Keys to authenticate as a user.
Creating an API Key with a Specific Role
- Once you've created your organization, you can set up and manage API Keys.
- Navigate to the Organization Settings page and click the API Keys tab.
- Click Add API Key and enter a name for your key in the Name field. This name is for reference purposes only and isn't used directly in authentication.
❗️Save Your API Key ID and secret The secret will not be available after you close this window.
Creating a Personal API Key
- Click on your avatar (located on the top right of the screen)
- Click on Personal Settings
- Select the API Keys tab
- Click Add API Key, and enter a name for your key in the Name field. This name is for reference purposes and isn't used directly in authentication.
❗️Save your API Key ID & secret The secret will not be available after you close this window.
Using an API Key to Authenticate
Authentication of the env zero API is done using the Basic Authentication method. Each request made should include the API Key ID as the username, and the API Key secret as the password. For example, when using curl, we can include these parameters via flag --user {API Key ID}:{API Key Secret}.
API Key Permissions
When creating an API key through the organization settings, you will need to choose if you’d like to grant it Organization Admin or User permissions. In case of the latter, you can assign fine-grained permissions per project. Personal API Keys can be created through the user’s profile page and will have the same permissions as the user has.
Rate Limits
env zero API allows up to 1K requests per 60 seconds, requests are aggregated by IP, HTTP Method and URI. If you exceed this limit, you will receive a 429 status code.
Query Parameters
Number of audit logs per page. The maximum is 1000, the default is 50
An audit log's id from which the page will start
Return only audit logs at or after this ISO-8601 date
Return only audit logs at or before this ISO-8601 date
Return only audit logs attributed to this user or API key
Return only audit logs attributed to one of these users or API keys, separated by commas
Return only audit logs not attributed to any of these users or API keys, separated by commas
Return only audit logs of this project
Return only audit logs of one of these projects, separated by commas
Return only audit logs not of any of these projects, separated by commas
Return only audit logs of this environment, project, template or deployment
Return only audit logs of these entity types, separated by commas: environment, deployment, project, template
Return only audit logs from these sources, separated by commas: ui, cli, api, system, not-recorded
Return only audit logs with one of these action names, separated by commas
Return only audit logs with none of these action names, separated by commas
Sort by time. 'desc' (newest first) is the default; 'asc' gives oldest first
Was this page helpful?