Project Instances

Use these endpoints to discover active instances and change the number of project replicas. They are useful for scaling automations, cost-saving routines, and internal operations dashboards.

Headers

HeaderRequiredDescription
x-api-keyYesProject API Key
x-organization-idYesActive project organization
Content-Type: application/jsonYesRequired only for PATCH

List Instances

Returns the current project instance identifiers.

GET /project/:id/instances

Path Parameters

ParameterTypeDescription
idstringProject ID (ObjectId)

Response

{
  "status": "success",
  "message": "get instances with success",
  "data": [
    { "instance": "abc" },
    { "instance": "def" }
  ]
}

Use the instance value in metrics and logs calls when you want to inspect a specific container.

Change Instance Count

Changes the number of project replicas.

PATCH /project/:id/instances

Body

FieldTypeRequiredDescription
instancesnumberYesNew instance count. Must be a positive integer.

Example

{
  "instances": 3
}

Response

{
  "status": "success",
  "message": "project instances changed with success"
}

Operational Rules

SituationResult
instances equals the current valueReturns 200 with no meaningful change
instances equals 0Rejected. Use Lifecycle to stop the project
Project is stoppedRejected. Use /resume before scaling
Monthly or yearly planMay be rejected; dynamic scaling is intended for hourly billing
db-free planDoes not allow dynamic instance changes
MariaDBRequires exactly 3 instances

Examples

curl

curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/instances" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id"
curl -X PATCH "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/instances" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id" \
  -H "Content-Type: application/json" \
  -d '{"instances": 3}'

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}

instances = requests.get(
    f"https://api.zenifra.com/v1/project/{PROJECT_ID}/instances",
    headers=headers
).json()

scale = requests.patch(
    f"https://api.zenifra.com/v1/project/{PROJECT_ID}/instances",
    headers=headers,
    json={"instances": 3}
).json()

Common Errors

CodeLikely reasonHow to fix
400instances is missing, invalid, or 0Send a positive integer and use /stop to stop the project
404Project not foundCheck Project ID, API Key, and organization
409Current state or plan does not allow dynamic scalingCheck that the project is running and billed hourly
500Operational failure while applying scalingRetry or contact support

Next Steps

  • Check Metrics and Logs to validate the new instance.
  • Use Lifecycle to stop or resume a project.
  • Review Storage before increasing instances with persistent volumes.