Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Deployment API

The API reference lists every endpoint, the token kinds it accepts, and its request body.

Credentials

Deployment calls take a pk_ automation token. An ak_ agent API key cannot control deployments.

Token kindDeployment use
observerRead deployments, status, snapshots, build logs, and the active deployment.
operatorBuild, activate, promote, roll back, start or stop runtimes, and change deploy settings.
adminSetup that also creates agents, connects GitHub, or manages secrets.

Prefer an agent-bound operator token for routine releases. See Automation Tokens for creation rules.

The examples use these environment variables:

export AMODAL_API_BASE=https://api.amodalai.com
export AMODAL_AGENT_ID="YOUR_AGENT_ID"
# Set AMODAL_PLATFORM_TOKEN from your secret manager.

Build

A deployment builds the agent's selected source. For a connected GitHub or GitLab repository, push to the branch you want to deploy. For Amodal-hosted source, save a source version first.

Start a build with POST /api/deployments/redeploy:

curl --fail-with-body "$AMODAL_API_BASE/api/deployments/redeploy" \
  -H "Authorization: Bearer $AMODAL_PLATFORM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"agentId":"'"$AMODAL_AGENT_ID"'","branch":"main","environment":"preview"}'

branch defaults to the source's default branch. Send commitSha to build that commit of branch instead of its head. environment defaults to production. For a connected repository with commitSha set, it defaults to the environment a push of branch builds. The response returns deployId and buildId. Poll GET /api/deployments/{deployId} for deployment status and GET /api/builds/{buildId}/status for build progress. Read build logs at GET /api/builds/{buildId}/logs.

Send "reuseBuild": true to share a build of the same commit: when the environment's newest build is that commit and has not failed, or a push is building it, the response returns that deployment with reused: true and starts no other build. Without reuseBuild, every call starts a build.

A completed build and an active deployment are separate states. Check runtime readiness and isActive before you continue. A build for any environment other than production activates when it completes. A production build activates only when automatic production promotion is on; otherwise it stays inactive until you activate it.

Each deployment's autoActivate field records whether the platform activates it once its build completes; it is null for deployments that predate the field.

Deploy Settings

GET and PUT /api/agents/{agent_id}/deploy-settings read and change the settings that the Deploys page shows:

FieldDefaultBehavior
productionBranchDefault branchA push to this branch builds the production environment. A push to another branch builds preview-<branch>.
autoDeployfalseWhen false, a push records source only and builds nothing.
autoPromoteProductionfalseWhen true, a completed production build activates automatically. When ci.evals.runOn covers production, it goes live only when the eval gate allows it.
rootDirRepository rootFolder that holds amodal.json. null or blank means the repository root. Requires a connected repository.

ci.deploy in amodal.json further limits which pushes build. See CI Rules.

When autoPromoteProduction is true and the build's amodal.json sets ci.evals.runOn to production or all, a completed production build with eval cases stays inactive while an eval comparison runs it against production. It goes live when the comparison freezes and the eval gate allows it. A push the gate refuses stays inactive until someone activates it, like a build without autoPromoteProduction. See Evals.

A push builds nothing when the environment's newest build is already the pushed commit and has not failed, or when another push or a reuseBuild redeploy is building it.

A push to a preview branch cancels the builds of that branch's older commits that are still running. Deleting a preview branch cancels all of its running builds. A cancelled deployment has status cancelled and gets no runtime. Its build log records the reason. Builds of the production environment always run to completion.

Test And Activate

Test the deploy URL before changing production. Mint a short-lived runtime token with POST /api/agents/{agent_id}/tokens and use it as the bearer token for /chat/stream. A pk_ token cannot authorize runtime chat. See Authentication.

POST /api/deployments/{deployId}/activate activates a deploy in its own environment and deactivates the previous one there. It does not copy a preview deploy into production. Studio's Make production calls this endpoint. The eval gate applies to a production deploy that has never been active. A deploy that was active before is never gated.

Promote Between Environments

POST /api/deployments/promote copies the active deployment of one environment into a separate deployment in another environment and activates it:

curl --fail-with-body "$AMODAL_API_BASE/api/deployments/promote" \
  -H "Authorization: Bearer $AMODAL_PLATFORM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"agentId":"'"$AMODAL_AGENT_ID"'","fromEnvironment":"preview","toEnvironment":"production"}'

toEnvironment defaults to production. Confirm that the source environment's active deployment is the one you tested. If its runtime bundle is missing or cannot be copied, promotion fails without changing the destination. Promotion activates the destination regardless of autoPromoteProduction.

Promotion into production is subject to the eval gate, checked against the source deployment's latest comparison.

Eval Comparison

An eval comparison runs a deployment's evals next to the agent's live production deployment and sorts each case into a bucket. See Evals for what a comparison runs, the buckets, and the verdict.

Start one with POST /api/deployments/{deployId}/eval-comparison. The request has no body.

curl --fail-with-body -X POST "$AMODAL_API_BASE/api/deployments/$DEPLOY_ID/eval-comparison" \
  -H "Authorization: Bearer $AMODAL_PLATFORM_TOKEN"

The endpoint takes an operator or admin token. A Studio user needs permission to change deployments, which collaborator roles do not grant. The response is the queued comparison. When a comparison for the deployment is already queued or running, the response is that comparison and no other starts. A comparison started with a token records triggeredBy: "api"; one started from Studio records manual.

StatusCodeCause
404NOT_FOUNDThe deployment does not exist.
409NO_AGENTThe deployment belongs to no agent.
409DEPLOYMENT_NOT_READYThe deployment's build has not completed.
409PRODUCTION_DEPLOYMENTThe deployment is the live production deployment, the baseline of every comparison.
502AUTOMATION_WORKER_ERRORThe comparison could not be queued. It is recorded with status failed.
503AUTOMATION_WORKER_NOT_CONFIGUREDThe platform has no automation runner to queue the comparison. It is recorded as failed.

Read the deployment's latest comparison with GET /api/deployments/{deployId}/eval-comparison. It takes an observer, operator, or admin token, and any Studio user who can read the agent. The response is { "comparison": ... }, with null before the deployment's first comparison. It fails with 404 NOT_FOUND when the deployment does not exist.

curl --fail-with-body "$AMODAL_API_BASE/api/deployments/$DEPLOY_ID/eval-comparison" \
  -H "Authorization: Bearer $AMODAL_PLATFORM_TOKEN"

Both endpoints return the comparison in the same shape:

FieldMeaning
idComparison ID.
agentIdThe agent both deployments belong to.
candidateDeployIdThe deployment under test.
baselineDeployIdThe production deployment it ran against; null when the agent had none.
candidateEnvironmentThe candidate's environment. Outside production, it ran with that environment's connections and secrets.
statusqueued, running, complete, failed, or cancelled when a newer held push replaced it.
verdictclear, regressed, or incomplete; null until status is complete.
activateOnCleartrue while the candidate is a held production push that goes live when this comparison freezes and the eval gate allows it.
casesOne entry per case; null until status is complete.
triggeredBymanual, api, or deploy for a comparison a completed build started.
createdByThe user who started it, or null.
createdAtWhen it was queued.
completedAtWhen it completed or failed; null before.

Each entry in cases has these fields:

FieldMeaning
caseNameThe case ID.
bucketincomplete, new, removed, edited, regressed, inconclusive, fixed, still_failing, or unchanged.
baseline, candidateThe first pass on each side: verdict, attempts, and passedAttempts. null for a side without the case.
baselineConfirm, candidateConfirmThe reruns on each side, in the same shape; null when the case did not rerun.
baselineCaseId, candidateCaseIdThe IDs of each side's first-pass result row.
baselineRow, candidateRowEach side's full first-pass result: verdict, attempts, durationMs, costMicros, and a detail with the response, assertions, tool calls, and any error. null for unchanged cases.

Eval Gate

Making a production deployment live for the first time checks its latest eval comparison. That covers activation of a production deployment that has never been active, promotion into production, and rollback to a production deployment that has never been active. Promotion checks the source deployment's comparison. The gate applies to deployments from every source. A deployment that goes live in another environment, and a deployment that was active before, are not checked.

The gate follows ci.evals.gate in the deployment's own amodal.json. It applies only when ci.evals.runOn covers production and the deployment has cases. A deployment whose bundle cannot be read is not checked. See Evals.

StateResult
gate is offAllowed
gate is failures, the comparison completed, and a case fails or errors on the deploymentRefused
The comparison is queued or runningRefused
No comparison, or the latest has status failedRefused, with startComparison: true
The latest comparison was cancelled by a newer pushRefused, with startComparison: true
The verdict is regressed or incompleteRefused
The verdict is clearAllowed

A refusal returns 422 EVAL_GATE_BLOCKED and leaves the active deployment serving. The response carries details:

{
  "error": {
    "code": "EVAL_GATE_BLOCKED",
    "message": "Evals regressed against production. Fix the evals, or override with force and a reason."
  },
  "details": { "deployId": "dep_abc123", "comparisonId": "6f1c2b9e-...", "cases": ["greets"], "startComparison": false }
}
FieldMeaning
deployIdThe deployment whose comparison decided: the activated deployment, or the source of a promotion.
comparisonIdIts latest comparison, or null when it has none.
casesThe blocking case names: the regressed and incomplete cases, or with gate: "failures", the cases that fail or error on the deployment.
startComparisontrue when only a new comparison can decide. Start one with POST /api/deployments/{deployId}/eval-comparison.

The amodal/evals commit status reports the comparison to the repository. The gate does not read it. See Evals.

A held auto-promoted production push goes live when its comparison freezes and this gate allows it. A push the gate refuses stays inactive until someone makes it live. See Evals.

To override the gate, send "force": true with a non-empty "reason". A request with force and no reason fails with 400 VALIDATION_ERROR. In Studio, a refused Make production lists the blocking cases with a link to the deployment's comparison, offers Run evals vs production when startComparison is true, and offers Make production anyway, which asks for the reason. A refused amodal promote prints the blocking cases and the deployment's page in Studio. With the CLI, pass amodal promote --force --reason "<why>" or amodal rollback --force --reason "<why>".

curl --fail-with-body "$AMODAL_API_BASE/api/deployments/$DEPLOY_ID/activate" \
  -H "Authorization: Bearer $AMODAL_PLATFORM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"force":true,"reason":"Hotfix for an outage; eval failure is a known flaky case"}'

The activate endpoint records a deployment_promoted audit entry, the promote endpoint records snapshot_promoted, and the rollback endpoint records snapshot_rolled_back. When force overrides a refusal, the request also records eval_gate_overridden with the actor, the reason, the gate's refusal message, the comparison ID, and the blocking case names.

Roll Back

Pass the deployment ID to activate in the target environment:

curl --fail-with-body "$AMODAL_API_BASE/api/deployments/rollback" \
  -H "Authorization: Bearer $AMODAL_PLATFORM_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"agentId":"'"$AMODAL_AGENT_ID"'","deployId":"'"$KNOWN_GOOD_DEPLOY_ID"'","environment":"production"}'

Without deployId, rollback selects the most recently activated inactive deployment that completed and was live before. If none qualifies, rollback fails without changing the active deployment. Use an explicit ID for a verified release. Rollback to a deploy that was live before is not gated. An explicit production deployId that was never active is checked by the eval gate like activation and accepts force with reason.

Runtime URLs

URLBehavior
https://agent-slug.amodalapp.comPersistent agent URL for the active production deployment.
https://deploy-id--agent-slug.amodalapp.comURL pinned to one deployment.

Activation, promotion, and rollback in production change where the persistent URL points. Each one switches only after the target runtime passes its health check, which can take up to two minutes for a cold runtime. A runtime that does not become healthy in that time fails the request with 503 RUNTIME_NOT_READY and leaves the active deployment serving. A deploy URL stays pinned to its deployment while that deployment and its runtime are retained.

Publish MCP and A2A endpoints

Deploy owner-authored tool and agent expose declarations, or a native OpenAPI connection's expose.mcp map, in the same source bundle as the implementation. The deployment serves /mcp and, for eligible tools and agents, /a2a; there is no separate protocol server to provision. Set hosted identity/protection and signed caller grants separately from the source definitions.

Production caller grants follow promotion; preview deployments require their own grants. Replacing a contract can invalidate existing receipts. Before upgrading, decide whether to drain starts, retain old contracts, or allow observation of prior deployments. See Preview, drain, and upgrade for the access-management API, exact-contract requirements, and anonymous limitations.