Skip to Content

Update Project Plan

Changes the project to a new plan.

Required permissions

Changing the plan requires project.plan.update on project:<project-id>. owner has full access; assistant, member, and organization API Keys need this grant. If the plan change involves billing data, also use project.billing.read when automation needs to read costs.

PATCH /v1/project/:id/plan

Rate limit: 5 requests per minute (counted per source IP).

Path Parameters

ParameterTypeDescription
idstringProject ID

Headers

HeaderRequiredDescription
x-api-key or AuthorizationYesOrganization API Key or user token
x-organization-idWith a user tokenActive project organization. Not needed with an organization API key
Content-Type: application/jsonYesRequired because the request has a JSON body

Body

FieldTypeRequiredDescription
planstringYesPlan identifier

Available Plans

PlanDescription
staticStatic plan
basicBasic plan
premiumPremium plan
premium_plusPremium plus plan
businessBusiness plan
deep_learning_basicBasic Deep Learning (with GPU)
deep_learning_premiumPremium Deep Learning (with GPU)
db-starter, db-basic, db-premium, db-enterpriseDatabase and Key-Value plans
cache-starter, cache-basic, cache-premium, cache-enterpriseCache plans
queue-starter, queue-basic, queue-premium, queue-enterpriseQueue plans (Valkey and RabbitMQ)
job-starter, job-basic, job-premiumScheduled Job plans

The legacy free plans (free, db-free, cache-free, and queue-free), available only to organizations that already received the free plans, are not accepted as a destination on this route. A free (HTTP) or db-free (PostgreSQL) project can change to a paid plan of its family in any billing mode: the project becomes hourly, compute and storage billing start at the change and the free period is never billed. Paid projects do not go back to a free plan. The new plan must belong to the family of the project type: HTTP plans for applications, db-* for PostgreSQL, MariaDB, and Key-Value, cache-* for Cache, queue-* for Queue, analytics-* for Analytics, and job-* for Scheduled Jobs. Analytics projects accept analytics-* plans (analytics-sandbox, analytics-starter, analytics-production, analytics-enterprise), both upgrading and downgrading; the plan defines the instances (1 on Sandbox and Starter, 3 on Production and Enterprise). For Key-Value, Cache, and Queue (Valkey or RabbitMQ), the change requires a running project with hourly billing and is only accepted between paid plans with the same number of instances and the same billed storage; otherwise the API responds 409. As a result, Cache changes among cache-starter, cache-basic, cache-premium, and cache-enterprise; Key-Value changes among db-basic, db-premium, and db-enterprise; and Queue changes among queue-basic, queue-premium, and queue-enterprise, because db-starter and queue-starter have one instance and the other plans have three. On Key-Value and Queue, the storage must meet the new plan's minimum; on Key-Value and Queue with Valkey, moving to a smaller plan also requires the stored data to fit the new plan's memory. The effects of the change on each service are in Valkey and Queues with RabbitMQ. Scheduled Jobs change among the job-* plans of the Job catalog, and the new plan applies from the next run; see Change the plan of a Job.

Plan change rules

  • Plan changes are only accepted for projects with hourly billing, or per-minute billing on Scheduled Jobs; monthly and yearly contracts keep the plan for the contracted period.
  • You can leave the free and db-free plans for a paid plan, but not go back to them. Free Key-Value, Cache, and Queue services do not change plans.
  • The project must be running (running) or stopped (stopped), with no other operation in progress. Key-Value, Cache, and Queue only change plans while running.
  • A stopped project stays stopped after the change: it keeps 0 instances, with no compute charge, and comes back with the new plan on resume.
  • If the organization has pending payments, moving to a larger plan or leaving a free plan returns 402; moving to a smaller plan remains available.

Example

{
  "plan": "premium"
}

Response

{
  "status": "success",
  "message": "updated with success"
}

On Analytics projects, the 200 response above means the change is done. If the change continues in the background, the response is 202:

{
  "status": "accepted",
  "code": "PLAN_CHANGE_IN_PROGRESS",
  "message": "The plan change has started and should finish in a few minutes."
}

Follow it with GET /v1/project/:id (Project information). When downgrading to a one-instance plan, Zenifra confirms the remaining instance has all the data before removing the others. Billing changes when the change completes.

Errors

StatusCodeWhen it happens
400—Invalid body (for example, plan missing, free, db-free, or not in the accepted list)
402ORGANIZATION_BILLING_BLOCKEDThe organization has pending payments and the new plan increases spending or the project leaves a free plan
404—Project not found (including preview environments and deleted projects) or plan does not exist
409PROJECT_PLAN_ALREADY_SELECTEDThe project already uses the requested plan (message: "The project already uses this plan.")
409PLAN_TYPE_MISMATCHThe plan does not belong to the family of the project type (message: "The selected plan is not available for this project type.")
409PROJECT_STATE_CONFLICTThe project is neither running nor stopped (for example, still being created or failed)
409PROJECT_OPERATION_IN_PROGRESSThe project is being resumed or deleted, or another operation is in progress
409—The paid project has a monthly or yearly contract (cant change plan with contract)
409INSUFFICIENT_PLAN_CAPACITYThere is no capacity available on the new plan
409CLICKHOUSE_NON_REPLICATED_DATAOn Analytics: "Some tables use an engine without replication and hold data. Move that data to replicated tables before changing to a plan with one instance." Move the data to tables with the default engine
409CLICKHOUSE_REPLICAS_NOT_IN_SYNCOn Analytics: "The instances are still synchronizing data. Try the plan change again in a few minutes." Try again in a few minutes
409FREE_PLAN_CHANGE_UNAVAILABLEOn Key-Value, Cache, and Queue with Valkey: the project is on a free plan (message: "Changes to or from a free plan are not available.")
409PROJECT_PLAN_CHANGE_UNAVAILABLEOn Key-Value, Cache, and Queue: the project is not running or does not use hourly billing; on Valkey, also during a credential rotation
409PLAN_CHANGE_REQUIRES_INSTANCE_MIGRATIONOn Key-Value and Queue: the new plan has a different number of instances (for example, from queue-starter to queue-basic)
409STORAGE_BELOW_PLAN_MINIMUMOn Key-Value and Queue: the storage is below the new plan's minimum. Grow the storage (Storage) before changing
409PLAN_CHANGE_REQUIRES_STORAGE_SETTLEMENTOn Key-Value and Queue: the change would alter the billed storage
409PLAN_CHANGE_MEMORY_ABOVE_TARGETOn Key-Value and Queue with Valkey, when moving to a smaller plan: the stored data does not fit the new plan's memory. Remove data or choose a larger plan
409PLAN_CHANGE_MEMORY_UNAVAILABLEOn Key-Value and Queue with Valkey, when moving to a smaller plan: the service's memory usage could not be confirmed. Try again in a few minutes
409PROJECT_PLAN_STATE_UNAVAILABLEOn Key-Value, Cache, and Queue: the service is not ready for the change
422PROJECT_OPERATION_NOT_SUPPORTEDThe project type does not accept plan changes
503PLAN_CAPACITY_TEMPORARILY_UNAVAILABLEPlan capacity is temporarily unavailable; try again shortly

The bodies of PROJECT_STATE_CONFLICT, PROJECT_OPERATION_IN_PROGRESS, and ORGANIZATION_BILLING_BLOCKED are in Conflicts and billing block.


Automatic contract renewal

Turns automatic renewal on or off for a project with a monthly or annual contract.

PATCH /v1/project/:id/renew-automatic-contract

Only the organization owner can change automatic renewal. assistant, member, and organization API Keys receive 403, even with project.plan.update. Rate limit: 5 requests per minute (counted per source IP).

Body

FieldTypeRequiredDescription
renew_automatic_contractbooleanYestrue to renew automatically at the end of the contract; false to not renew
{
  "renew_automatic_contract": false
}

Response

{
  "status": "success",
  "message": "renew automatic contract updated with success"
}

Errors

StatusWhen it happens
400Invalid body, or the project uses hourly or per-minute billing, which has no contract renewal
403The credential is not the organization owner (owner role required)
404Project not found

Cancel renewal

DELETE /v1/project/:id/subscription

Turns off automatic renewal of a monthly or yearly contract: the project stays active until the end of the contracted period and the contract is not renewed. It is also restricted to the organization owner. Rate limit: 5 requests per minute (counted per source IP).

{
  "status": "success",
  "message": "canceled the subscription of project with success"
}
StatusWhen it happens
403The credential is not the organization owner
404Project not found
409The project uses hourly or per-minute billing, which has no contract (cant cancell subscription of payment mode hourly)

Examples

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

Python

import requests

API_KEY = "your-api-key"
ORGANIZATION_ID = "your-organization-id"
PROJECT_ID = "507f1f77bcf86cd799439011"

response = requests.patch(
    f"https://api.zenifra.com/v1/project/{PROJECT_ID}/plan",
    headers={"x-api-key": API_KEY, "x-organization-id": ORGANIZATION_ID},
    json={"plan": "premium"}
)
print(response.json())

Notes

  • Plan change may take a few minutes to be applied
  • Plan changes are only accepted for projects with hourly billing, or per-minute billing on Scheduled Jobs; billing uses the new plan price from the change onward (on Scheduled Jobs, from the next run)
  • When you move to a plan without auto-scaling or health check, those features are turned off automatically
  • GPU plans (deep_learning_basic, deep_learning_premium) have their own prices; see GET /v1/project/plans

Last updated on

On this page