Logo ZenifraZenifra

Environment Variables

Learn how to manage your project's environment variables via API.

Get Environment Variables

Returns the environment variables configured in the project.

GET /project/:id/envs

Path Parameters

ParameterTypeDescription
idstringProject ID (ObjectId)

Response

{
  "status": "success",
  "data": {
    "envs": [
      {
        "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.

PATCH /project/:id/envs

Path Parameters

ParameterTypeDescription
idstringProject ID (ObjectId)

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": "Environment variables updated"
}

Examples

Get Environment Variables

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

Update Environment Variables

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

Python

import requests

API_KEY = "your-api-key"
PROJECT_ID = "507f1f77bcf86cd799439011"

headers = {"x-api-key": API_KEY}

# 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