Bundles
POST
/v1/orgs/{org_id}/projects/{project_id}/envs/{source_env}/promotePromote Bundle
Promote the active bundle from source env to the next stage (dev→staging, staging→prod).
CI tokenscope: bundle:publishoperation_id: bundles.promote
Authentication
Create via POST /v1/orgs/{org_id}/tokens/ci. Project-scoped, allows bundle lifecycle.
SDK install
pip install znyx-sdknpm install @znyx/sdkPath parameters
| Name | Type | Required | Description |
|---|---|---|---|
| org_id#path | string | required | — |
| project_id#path | string | required | — |
| source_env#path | string | required | — |
Header parameters
| Name | Type | Required | Description |
|---|---|---|---|
| X-API-Key#header | string | null | optional | — |
| authorization#header | string | null | optional | — |
Request bodyrequired
| Field | Type | Required | Description |
|---|---|---|---|
| promoted_by | string | optional | — |
Responses
| Status | Description |
|---|---|
| 200 | Successful Response |
| 422 | Validation Error |
Response schema
idrequiredstring
versionrequiredinteger
policy_hashrequiredstring
is_activerequiredboolean
published_byrequiredstring | null
published_atrequiredstring
Errors & what triggers them
| Code | Trigger | Fix |
|---|---|---|
| 400 | source_env has no valid promotion target (e.g. source=prod). | — |
| 404 | No active bundle in the source environment to promote. | — |
Notes & examples
Promotion order
Promotion moves the currently active bundle forward one stage:
dev→stagingstaging→prod
There is no prod → ? — the path ends there. If you want to push a specific dev version straight to prod, use activate with an explicit version instead.
Guardrails
- The target environment must already exist. Create it with
POST /v1/orgs/{org}/projects/{p}/environmentsif not. - The target env's tier-gate quota is checked (e.g. free plan gets limited bundle versions per env).
- If there's no active bundle in the source env, you get a 404 — nothing to promote.
Webhook
Emits bundle.promoted with from_environment, to_environment, and policy_hash. Wire this to Slack / PagerDuty for prod awareness.
Request
curl -X POST 'https://api.znyx.ai/v1/orgs/00000000-0000-0000-0000-000000000000/projects/00000000-0000-0000-0000-000000000000/envs/<source_env>/promote' \
-H 'Authorization: Bearer $ZNYX_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"promoted_by": "ui"
}'Response
application/json
Successful Response
{
"id": "string",
"version": 0,
"policy_hash": "string",
"is_active": false,
"published_by": null,
"published_at": "string"
}Schema: object