Get Environment Variables

Returns the environment variables configured in the project.

Required permissions

Reading requires project.env.read on project:<project-id>. Updating requires project.env.update on the same project. owner has full access; assistant, member, and organization API Keys need the specific scope. Values may be sensitive and must not be logged.

GET /v1/project/:id/envs

Rate limit: 50 requests per minute (counted per source IP).

Path Parameters

ParameterTypeDescription
idstringProject ID

Headers

HeaderRequiredDescription
x-api-key or AuthorizationYesOrganization API Key or user token
x-organization-idWith a user tokenActive project organization. Not needed with an organization API key
Content-Type: application/jsonConditionalRequired only for PATCH calls

Response

Environment variable values can include sensitive data. Treat this response as sensitive because values returned by the API may be available in plain text to any credential with the project.env.read permission.

{
  "status": "success",
  "message": "get envs with success",
  "data": [
    {
      "name": "DATABASE_URL",
      "value": "postgres://user:pass@host:5432/db"
    },
    {
      "name": "NODE_ENV",
      "value": "production"
    }
  ]
}

Update Environment Variables

Updates the environment variables of the project.

The list you send replaces all current variables: variables left out are removed. To change a single variable, read the list with GET, adjust the item, and send the full list. The change restarts the application instances and adds an entry to the deployment history.

PATCH /v1/project/:id/envs

Rate limit: 20 requests per minute (counted per source IP).

Path Parameters

ParameterTypeDescription
idstringProject ID

Body

FieldTypeRequiredDescription
envsarrayYesArray of objects with name and value (maximum 50 variables, each name up to 120 characters, each value up to 32760 characters)

Example

{
  "envs": [
    {
      "name": "DATABASE_URL",
      "value": "postgres://user:pass@host:5432/db"
    },
    {
      "name": "API_KEY",
      "value": "new-api-key"
    }
  ]
}

Response

{
  "status": "success",
  "message": "updated with success"
}

Errors

StatusWhen it happens
400Invalid body (for example, above the limits on this page)
404Project not found
409The project is not running (project is not running)

Examples

Get Environment Variables

curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/envs" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id"

Update Environment Variables

curl -X PATCH "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/envs" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id" \
  -H "Content-Type: application/json" \
  -d '{"envs": [{"name": "NODE_ENV", "value": "production"}]}'

Python

import requests

API_KEY = "your-api-key"
ORGANIZATION_ID = "your-organization-id"
PROJECT_ID = "507f1f77bcf86cd799439011"

headers = {"x-api-key": API_KEY, "x-organization-id": ORGANIZATION_ID}

# Get environment variables
envs = requests.get(
    f"https://api.zenifra.com/v1/project/{PROJECT_ID}/envs",
    headers=headers
).json()
print(envs)

# Update environment variables
requests.patch(
    f"https://api.zenifra.com/v1/project/{PROJECT_ID}/envs",
    headers=headers,
    json={
        "envs": [
            {"name": "NODE_ENV", "value": "production"},
            {"name": "DATABASE_URL", "value": "postgres://user:pass@host:5432/db"}
        ]
    }
)

Limits

  • Maximum of 50 environment variables per project
  • Each name can have up to 120 characters
  • Each value can have up to 32760 characters

Last updated on

On this page