Deployments
ulex deployment simulation: the ten-state lifecycle, strategies, step logs, resources and issued credentials, progress tracking, and cancel and rollback.
Required scopes: read:deployments, write:deployments. Starting a prod deployment additionally requires ulex:admin and confirm: true.
ulex does not run your code. POST /deployments models the full lifecycle — states, steps, logs, resource creation, credential issuance, and rollback — deterministically and instantly, so an agent can build and demonstrate a delivery pipeline without a CI runner, a container registry, or AWS credentials. Read What ulex is not before you describe it to anyone as deployment infrastructure.
#Control plane environment
curl -sS "$BASE/environments" -H "Authorization: Bearer $ULEX_API_KEY"{
"object": "list",
"data": [
{ "id": "env_01M3PSWAQ8KTKST4M41YP8HAVK", "object": "environment", "slug": "production", "name": "Production", "domain": "ulexid.com", "region": "us-east-2" }
],
"first_id": "env_01M3PSWAQ8KTKST4M41YP8HAVK",
"last_id": "env_01M3PSWAQ8KTKST4M41YP8HAVK",
"has_more": false,
"next_cursor": null
}curl -sS "$BASE/environments/prod/health" -H "Authorization: Bearer $ULEX_API_KEY"{
"environment": "prod",
"status": "healthy",
"version": "2025.9.1",
"region": "us-east-2",
"uptime_seconds": 841233,
"checks": [
{ "name": "api", "status": "pass", "latency_ms": 11 },
{ "name": "dynamodb", "status": "pass", "latency_ms": 3 },
{ "name": "kms", "status": "pass", "latency_ms": 7 },
{ "name": "queue", "status": "pass", "latency_ms": 2 },
{ "name": "directory_sync", "status": "pass", "latency_ms": 41 }
]
}status ∈ healthy | degraded | unavailable. degraded means at least one non-critical check is failing and the control plane still serves requests. unavailable means you should not call anything.
#Start a deployment
curl -sS -X POST "$BASE/deployments" \
-H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: 3c9d1f77-0b2e-4a58-9d61-5e7a2c40b913" \
-d '{
"application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
"environment": "prod",
"confirm": true,
"commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
"branch": "main",
"commit_message": "Add SAML SP wiring",
"strategy": "simulated"
}'#The production interlock
A prod deployment needs ulex:admin and an explicit confirm: true. Without it:
{
"error": {
"type": "invalid_request_error",
"code": "validation_failed",
"message": "A prod deployment requires confirm: true.",
"param": "confirm",
"request_id": "req_01M3PSW9R0175NAW62NYR403R8",
"retryable": false,
"hint": "Re-send with \"confirm\": true. This interlock exists so a mistargeted call cannot promote an application into production."
}
}{
"application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
"environment": "prod",
"commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
"branch": "main",
"strategy": "simulated",
"confirm": true
}The confirm: true interlock exists so that a copy-pasted payload or retry loop cannot promote an application without a deliberate confirmation flag. And it is retryable: false by design, not by accident: no retry of the same request can succeed, because the request has to change.
{
"id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
"object": "deployment",
"application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
"environment": "prod",
"state": "queued",
"domain": "acme-support.ulexid.com",
"strategy": "simulated",
"commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
"branch": "main",
"commit_message": "Add SAML SP wiring",
"resources": [],
"issued": {},
"steps": [],
"error": null,
"progress_percent": 0,
"requested_by": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
"created_at": "2026-09-29T14:48:20.000Z",
"started_at": null,
"finished_at": null,
"duration_ms": null
}environment is required on POST /deployments and matches the hosted control plane ("prod").
strategy | What it means |
|---|---|
simulated (default) | the full modelled lifecycle. Nothing leaves the control plane |
agent_direct | the caller runs the steps and reports progress with PATCH; ulex only tracks state and issues credentials |
cloudformation | a CloudFormation template is rendered and described, but not deployed |
synthesize | an OpenSAM/CloudFormation template plus a local invoke image are produced |
commit_sha must be 7–40 lowercase hex characters, or null.
Pricing is usage-based; there is no plan-based concurrent deployment limit. The deployment simulator still enforces its own technical request and execution bounds.
#Lifecycle
Ten states with a strict transition table. A transition that is not in the table is 409 invalid_state_transition.
┌──────────► cancelled
│
queued ─► provisioning ─► configuring ─► building ─► deploying ─► verifying ─► succeeded
│ │ │ │ │ │ │
└────────────┴──────────────┴─────────────┴────────────┴────────────┘ │
▼
failed ─► queued rolled_back
│
▼
queued| From | To |
|---|---|
queued | provisioning, cancelled, failed |
provisioning | configuring, failed, cancelled |
configuring | building, failed, cancelled |
building | deploying, failed, cancelled |
deploying | verifying, failed, cancelled, rolled_back |
verifying | succeeded, failed, rolled_back, cancelled |
succeeded | rolled_back |
failed | queued (retry) |
cancelled | — terminal |
rolled_back | queued (redeploy) |
failed → queued is a retry: the same deployment id is reused, attempt is not tracked separately, and a fresh steps[] array replaces the old one. If you want a new attempt in the record, start a new deployment.
#Poll
curl -sS "$BASE/deployments/dep_01M3PSVP70YQ9Y1YD8QMC42JXF" -H "Authorization: Bearer $ULEX_API_KEY"{
"id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
"object": "deployment",
"application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
"environment": "prod",
"state": "succeeded",
"domain": "acme-support.ulexid.com",
"strategy": "simulated",
"commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
"branch": "main",
"resources": [
{ "type": "application", "id": "app_01M3PSV7J8TBSPHG95CYSEX32B", "url": "https://acme-support.ulexid.com" },
{ "type": "oidc_client", "id": "client_01M3PSV7J8TBSPHG95CYSEX32B", "url": null },
{ "type": "saml_sp", "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A", "url": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/metadata" },
{ "type": "scim_endpoint", "id": "dir_01M3PSVBF8038RK2MW2N263Q2B", "url": "https://ulexid.com/api/v1/scim/v2" }
],
"issued": {
"client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
"client_secret": "cs_Tn4Wv8Kp2LmQ6Rb9Yc3Xd7Fs1Hg0Ja5E",
"api_key": "ulex_sk_live_7Qm2KpLx9Tb4Ns8RfWy3Zc1Hjf6Ee0Au",
"saml_entity_id": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B",
"saml_acs_url": "https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso",
"saml_idp_metadata_url": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/metadata",
"oidc_issuer": "https://ulexid.com",
"scim_base_url": "https://ulexid.com/api/v1/scim/v2",
"scim_bearer_token": "scim_7Bq4Nxf2Vk9Lc3MdT6hR8wS1yP5aG0eJ",
"authorization_endpoint": "https://ulexid.com/api/v1/oauth2/authorize",
"token_endpoint": "https://ulexid.com/api/v1/oauth2/token",
"admin_email": "dana@acme.example",
"admin_password": null
},
"steps": [
{ "name": "provision-application", "state": "succeeded", "started_at": "2026-09-29T14:48:20.412Z", "finished_at": "2026-09-29T14:48:20.918Z", "duration_ms": 506, "message": "Registered OIDC client app_01M3PSV7J8TBSPHG95CYSEX32B", "logs": ["client_id=client_01M3PSV7J8TBSPHG95CYSEX32B", "require_pkce=true", "redirect_uris=1"] },
{ "name": "configure-saml-sp", "state": "succeeded", "started_at": "2026-09-29T14:48:20.918Z", "finished_at": "2026-09-29T14:48:21.104Z", "duration_ms": 186, "message": "SP metadata published", "logs": ["entity_id=https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B", "acs_url=https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso"] },
{ "name": "configure-scim", "state": "succeeded", "started_at": "2026-09-29T14:48:21.104Z", "finished_at": "2026-09-29T14:48:21.330Z", "duration_ms": 226, "message": "SCIM endpoint published for dir_01M3PSVBF8038RK2MW2N263Q2B", "logs": ["base_url=https://ulexid.com/api/v1/scim/v2", "inbound_scim_enabled=true"] },
{ "name": "build", "state": "succeeded", "started_at": "2026-09-29T14:48:21.330Z", "finished_at": "2026-09-29T14:48:21.402Z", "duration_ms": 72, "message": "Bundle built from 9f3c1a7", "logs": ["artifact=acme-support:9f3c1a7", "size=412KiB"] },
{ "name": "deploy", "state": "succeeded", "started_at": "2026-09-29T14:48:21.402Z", "finished_at": "2026-09-29T14:48:21.688Z", "duration_ms": 286, "message": "Released to acme-support.ulexid.com", "logs": ["revision=14", "previous_revision=13"] },
{ "name": "verify", "state": "succeeded", "started_at": "2026-09-29T14:48:21.688Z", "finished_at": "2026-09-29T14:48:21.920Z", "duration_ms": 232, "message": "Health check passed", "logs": ["GET / 200 in 41ms", "GET /.well-known/openid-configuration 200 in 12ms", "token_endpoint reachable"] }
],
"error": null,
"progress_percent": 100,
"created_at": "2026-09-29T14:48:20.000Z",
"started_at": "2026-09-29T14:48:20.412Z",
"finished_at": "2026-09-29T14:48:21.920Z",
"duration_ms": 1508
}issued is populated on a successful deployment and is the one place credentials come back as a set. It is returned in full on the terminal GET and then retained; treat it as secret and store it in the same call.
progress_percent is 0–100 and is a coarse hint. Poll on state, not on progress_percent. Two steps can be at the same percentage.
Typical wall clock: about 1.5 seconds for simulated, 200–400 ms per step.
#Logs
curl -sS "$BASE/deployments/dep_01M3PSVP70YQ9Y1YD8QMC42JXF/logs?step=verify&tail=50" -H "Authorization: Bearer $ULEX_API_KEY"{
"object": "deployment_logs",
"deployment_id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
"steps": [
{ "name": "verify", "state": "succeeded", "duration_ms": 232, "message": "Health check passed" }
],
"lines": [
{ "ts": "2026-09-29T14:48:21.688Z", "level": "info", "step": "verify", "message": "GET / 200 in 41ms" },
{ "ts": "2026-09-29T14:48:21.701Z", "level": "info", "step": "verify", "message": "GET /.well-known/openid-configuration 200 in 12ms" },
{ "ts": "2026-09-29T14:48:21.720Z", "level": "info", "step": "verify", "message": "token_endpoint reachable" },
{ "ts": "2026-09-29T14:48:21.920Z", "level": "info", "step": "verify", "message": "deployment succeeded" }
]
}Levels: debug, info, warn, error. Every line is scrubbed before storage — no client secrets, no tokens, no raw environment values. tail defaults to 200, max 2,000. Omit step to get all steps.
#Cancel and rollback
curl -sS -X POST "$BASE/deployments/dep_01M3PSVP70YQ9Y1YD8QMC42JXF/cancel" -H "Authorization: Bearer $ULEX_API_KEY"{ "id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF", "object": "deployment", "state": "cancelled", "progress_percent": 60, "finished_at": "2026-09-29T14:48:21.500Z" }Cancelling a succeeded, cancelled, or rolled_back deployment is 409 invalid_state_transition. Cancelling is terminal — the only way forward is a new deployment.
curl -sS -X POST "$BASE/deployments/dep_01M3PSVP70YQ9Y1YD8QMC42JXF/rollback" \
-H "Authorization: Bearer $ULEX_API_KEY" -H "Content-Type: application/json" \
-d '{"to_deployment_id":"dep_01M3PSW4VRJVGQ82XD4EZ3T6SD"}'{
"id": "dep_01M3PSW4VRJVGQ82XD4EZ3T6SD",
"object": "deployment",
"state": "rolled_back",
"domain": "acme-support.ulexid.com",
"progress_percent": 100,
"rolled_back_from": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
"finished_at": "2026-09-29T14:52:04.000Z"
}Rollback creates a new deployment in rolled_back state; it does not mutate the original. to_deployment_id defaults to the last succeeded deployment for the same application and environment. The rolled-back deployment's issued block is empty — you do not get credentials back from a rollback, because they belonged to the revision you left.
#List
curl -sS -G "$BASE/deployments" -H "Authorization: Bearer $ULEX_API_KEY" \
--data-urlencode 'application_id=app_01M3PSV7J8TBSPHG95CYSEX32B' \
--data-urlencode 'environment=prod' \
--data-urlencode 'limit=20' \
--data-urlencode 'order=desc'{
"object": "list",
"data": [
{ "id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF", "object": "deployment", "state": "succeeded", "commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b", "progress_percent": 100, "created_at": "2026-09-29T14:48:20.000Z" },
{ "id": "dep_01M3PSW4VRJVGQ82XD4EZ3T6SD", "object": "deployment", "state": "rolled_back", "commit_sha": "3f8b2c1d9e7a5b3f1d9c7a5e3b1f9d7c5a3e1b9f7d5c3a1e9b7d5f3c1a9e7b5d3", "progress_percent": 100, "created_at": "2026-09-28T18:02:11.000Z" }
],
"first_id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
"last_id": "dep_01M3PSW4VRJVGQ82XD4EZ3T6SD",
"has_more": false,
"next_cursor": null
}Filters: application_id, environment, state, branch, commit_sha, plus the standard pagination parameters. List responses omit steps and issued for bandwidth; read the individual deployment for those.
#The agent loop
export async function deployAndWait(
applicationId: string,
environment: string = "prod",
opts: { commit_sha?: string; branch?: string; timeoutMs?: number } = {},
): Promise<Deployment> {
const { deployment } = await tools.ulex_deploy({
application_id: applicationId,
environment,
confirm_production: true,
commit_sha: opts.commit_sha ?? null,
branch: opts.branch ?? "main",
idempotency_key: `deploy-${applicationId}-${environment}-${opts.commit_sha ?? "head"}`,
});
const deadline = Date.now() + (opts.timeoutMs ?? 120_000);
const terminal = new Set(["succeeded", "failed", "cancelled", "rolled_back"]);
for (;;) {
if (Date.now() > deadline) {
await tools.ulex_cancel_deployment({ deployment_id: deployment.id });
throw new Error(`deployment ${deployment.id} timed out and was cancelled`);
}
// 250ms backoff is well inside the simulator's ~1.5s lifecycle and does not
// burn the MCP budget: 4 polls per deployment.
await new Promise((r) => setTimeout(r, 250));
const current = await tools.ulex_get_deployment({ deployment_id: deployment.id });
if (!terminal.has(current.state)) continue;
if (current.state !== "succeeded") {
const logs = await tools.ulex_get_deployment_logs({
deployment_id: deployment.id,
step: current.steps.find((s) => s.state === "failed")?.name,
tail: 50,
});
throw new Error(
`deployment ${current.id} ${current.state}: ${current.error?.code ?? "unknown"} — ${current.error?.message ?? ""}\n` +
logs.lines.map((l) => ` [${l.level}] ${l.message}`).join("\n"),
);
}
return current;
}
}#Errors
code | Status | Cause |
|---|---|---|
validation_failed | 400 | bad environment, malformed commit_sha, unknown strategy |
not_found | 404 | no such application |
deployment_not_found | 404 | no such deployment |
invalid_state_transition | 409 | cancel after terminal, or rollback a failed deployment that has nothing to roll back to |
deployment_failed | 500 | a step failed; read deployment.error.code |
insufficient_scope | 403 | missing write:deployments, or ulex:admin for prod |
#MCP equivalents
ulex_deploy, ulex_get_deployment, ulex_list_deployments, ulex_cancel_deployment, ulex_rollback_deployment, ulex_get_deployment_logs, ulex_list_environments, ulex_get_environment_health.
Deeper: Operations: deployments, Runbooks.