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
| Header | Required | Description |
|---|---|---|
x-api-key | Yes | Project API Key |
x-organization-id | Yes | Active project organization |
Content-Type: application/json | Yes | Required for PATCH |
Update Autoscaling
PATCH /project/:id/autoscalingBody
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | Yes | true enables or updates; false disables |
min_instances | number | When enabling | Reserved minimum instances |
max_instances | number | When enabling | Maximum instances allowed during spikes |
target_cpu_utilization_percent | number | No | Target CPU. Default: 70 |
target_memory_utilization_percent | number | No | Target 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/eventsReturns 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
| Field | Type | Required | Description |
|---|---|---|---|
direction | string | No | Filters by scale_up or scale_down |
from | ISO date | No | Start of the period |
to | ISO date | No | End of the period |
page | number | No | Page. Default: 1 |
limit | number | No | Items 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
| Situation | Result |
|---|---|
| Project is not HTTP | Rejected |
| Project is stopped | Rejected |
| Plan does not allow autoscaling | Rejected |
| Manually changing instances while autoscaling is enabled | Rejected with 409 |
Common Errors
| Code | When it happens |
|---|---|
PROJECT_MUST_BE_RUNNING | The project must be running before autoscaling can be changed |
AUTOSCALING_UPDATE_IN_PROGRESS | Another autoscaling update is already running for the project |
AUTOSCALING_TOGGLE_COOLDOWN_ACTIVE | Autoscaling was enabled or disabled recently |
AUTOSCALING_NOT_AVAILABLE_FOR_PLAN | The current plan does not allow autoscaling |
AUTOSCALING_REQUIRES_SHARED_STORAGE | The project needs shared storage to use autoscaling |
Next Steps
- Check Instances to list current instances.
- Check Metrics and Logs to validate behavior during spikes.