HTTP Autoscaling

Use this endpoint to configure autoscaling for paid HTTP applications. The project keeps a reserved minimum instance count and can increase instances automatically during traffic spikes.

Headers

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

Update Autoscaling

PATCH /project/:id/autoscaling

Body

FieldTypeRequiredDescription
enabledbooleanYestrue enables or updates; false disables
min_instancesnumberWhen enablingReserved minimum instances
max_instancesnumberWhen enablingMaximum instances allowed during spikes
target_cpu_utilization_percentnumberNoTarget CPU. Default: 70
target_memory_utilization_percentnumberNoTarget memory. Default: 80

max_instances must be greater than or equal to min_instances.

Enable or Update

{
  "enabled": true,
  "min_instances": 2,
  "max_instances": 8,
  "target_cpu_utilization_percent": 70,
  "target_memory_utilization_percent": 80
}

Disable

{
  "enabled": false
}

Response

{
  "status": "success",
  "message": "project autoscaling updated with success",
  "data": {
    "autoscaling": {
      "enabled": true,
      "min_instances": 2,
      "max_instances": 8,
      "target_cpu_utilization_percent": 70,
      "target_memory_utilization_percent": 80
    }
  }
}

Event History

GET /project/:id/autoscaling/events

Returns the paginated history of scale up and scale down events recorded by Zenifra. Use this endpoint for audit trails, support, and traffic spike analysis.

Query

FieldTypeRequiredDescription
directionstringNoFilters by scale_up or scale_down
fromISO dateNoStart of the period
toISO dateNoEnd of the period
pagenumberNoPage. Default: 1
limitnumberNoItems per page. Default: 50, maximum: 100

Response

{
  "status": "success",
  "message": "get project autoscaling events with success",
  "data": {
    "events": [
      {
        "id": "6a24f7...",
        "direction": "scale_up",
        "previous_instances": 2,
        "new_instances": 5,
        "desired_instances": 5,
        "min_instances": 2,
        "max_instances": 8,
        "trigger_metric": "cpu",
        "current_cpu_utilization_percent": 91,
        "target_cpu_utilization_percent": 70,
        "current_memory_utilization_percent": 62,
        "target_memory_utilization_percent": 80,
        "reason": "increased_capacity",
        "message": "Automatic scaling increased the project instance count.",
        "occurred_at": "2026-06-05T21:40:00.000Z"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 50,
      "total": 1,
      "total_pages": 1
    }
  }
}

The history is retained for 13 months.

Billing

For hourly projects, billing uses observed instances during the billing period.

For monthly or yearly projects, the reserved minimum is part of the main contract. Instances above the minimum are billed as elastic instance-hours using the plan hourly price.

Rules

SituationResult
Project is not HTTPRejected
Project is stoppedRejected
Plan does not allow autoscalingRejected
Manually changing instances while autoscaling is enabledRejected with 409

Common Errors

CodeWhen it happens
PROJECT_MUST_BE_RUNNINGThe project must be running before autoscaling can be changed
AUTOSCALING_UPDATE_IN_PROGRESSAnother autoscaling update is already running for the project
AUTOSCALING_TOGGLE_COOLDOWN_ACTIVEAutoscaling was enabled or disabled recently
AUTOSCALING_NOT_AVAILABLE_FOR_PLANThe current plan does not allow autoscaling
AUTOSCALING_REQUIRES_SHARED_STORAGEThe project needs shared storage to use autoscaling

Next Steps