Get Environment Variables

Returns the environment variables configured in the project.

GET /project/:id/envs

Path Parameters

ParameterTypeDescription
idstringProject ID (ObjectId)

Headers

HeaderRequiredDescription
x-api-keyYesProject API Key
x-organization-idYesActive project organization
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 callers with a valid project API key.

{
  "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.

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": "updated with success"
}

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