Skip to main content
Deployments

Create a deployment

Create a new Deployment that runs an Agent on a cron schedule or manually.

POST /api/v1/cloud/deployments Creates a new Deployment. A Deployment binds an Agent to a cron schedule (or manual-only trigger), an Environment, and an initial set of events delivered at each run. The newly created deployment is in the active status and will begin firing according to its schedule immediately.

Headers

HeaderRequiredDescription
AuthorizationYesBearer $QODER_ACCESS_TOKEN
Content-TypeYesapplication/json

Request body

FieldTypeRequiredDescription
namestringYesDeployment name (max 256 characters)
descriptionstringNoHuman-readable description
agentstring or objectYesAgent reference. Either a plain string "agent_xxx" (uses latest version) or an object {"id": "agent_xxx", "type": "agent", "version": 2} to pin a specific version. Object form must include type: "agent".
environment_idstringYesEnvironment ID (env_ prefix)
scheduleobjectNoCron schedule configuration. If omitted, the deployment is manual-only (schedule will be null in response). See Schedule object below.
initial_eventsarrayYesArray of events (1–50) delivered to the Agent on each run. Each event must have a type field. Allowed types: user.message, user.define_outcome.
resourcesarrayNoResources attached to each session (e.g., github_repository, file, memory_store). Default [].
vault_idsarrayNoList of Vault IDs to inject credentials. Default []. Max 50.
metadataobjectNoCustom string key-value metadata (max 16 keys, key ≤64 chars, value ≤512 chars). Values must be strings.
environment_variablesstringNoDeployment-level environment variables to inject into sessions created by this deployment, formatted as KEY=VALUE pairs separated by ; or newlines. Not supported on self-hosted environments.

Schedule object

FieldTypeRequiredDescription
typestringYesMust be "cron"
expressionstringYesStandard 5-field cron expression (e.g., "0 9 * * *")
timezonestringYesIANA timezone (e.g., "Asia/Shanghai")

Environment variables

environment_variables uses the same validation as Session creation: variable names must match [A-Za-z_][A-Za-z0-9_]*, reserved names/prefixes are rejected, duplicate keys are rejected, and the total payload is limited. The response returns a normalized string sorted by key and joined with newlines.

Example request

curl -X POST "https://api.qoder.com/api/v1/cloud/deployments" \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "api-doc-verification-deployment",
    "description": "Deployment created for API documentation verification",
    "agent": "agent_019eb4d4a06d747c865d5800b9c57ae2",
    "environment_id": "env_019e64e01a137caf953ac2ac7b42ec5c",
    "schedule": {
      "type": "cron",
      "expression": "0 9 * * *",
      "timezone": "Asia/Shanghai"
    },
    "initial_events": [
      {
        "type": "user.message",
        "content": [
          {
            "type": "text",
            "text": "Generate today'\''s status report"
          }
        ]
      }
    ],
    "resources": [],
    "vault_ids": [],
    "metadata": {
      "team": "platform"
    },
    "environment_variables": "FEATURE_FLAG=on;LOG_LEVEL=info"
  }'

Example response

HTTP 200 OK
{
  "agent": {
    "id": "agent_019eb4d4a06d747c865d5800b9c57ae2",
    "type": "agent",
    "version": 1
  },
  "archived_at": null,
  "created_at": "2026-06-14T08:53:32Z",
  "description": "Deployment created for API documentation verification",
  "environment_id": "env_019e64e01a137caf953ac2ac7b42ec5c",
  "environment_variables": "FEATURE_FLAG=on\nLOG_LEVEL=info",
  "id": "dep_019ec556114c78f8b60ee34fcb98bf59",
  "initial_events": [
    {
      "content": [
        {
          "type": "text",
          "text": "Generate today's status report"
        }
      ],
      "type": "user.message"
    }
  ],
  "metadata": {
    "team": "platform"
  },
  "name": "api-doc-verification-deployment",
  "paused_reason": null,
  "resources": [],
  "schedule": {
    "expression": "0 9 * * *",
    "timezone": "Asia/Shanghai",
    "type": "cron",
    "upcoming_runs_at": [
      "2026-06-15T01:00:00Z",
      "2026-06-16T01:00:00Z",
      "2026-06-17T01:00:00Z",
      "2026-06-18T01:00:00Z",
      "2026-06-19T01:00:00Z"
    ]
  },
  "status": "active",
  "type": "deployment",
  "updated_at": "2026-06-14T08:53:32Z",
  "vault_ids": []
}

Response fields

FieldTypeDescription
idstringDeployment unique identifier (dep_ prefix)
typestringAlways "deployment"
namestringDeployment name
descriptionstring or nullDescription
agentobjectAgent reference: {id, type, version}
environment_idstringAssociated Environment ID
scheduleobject or nullSchedule config with upcoming_runs_at (null for manual-only)
schedule.expressionstringCron expression
schedule.timezonestringIANA timezone
schedule.typestringAlways "cron"
schedule.upcoming_runs_atarrayNext 5 scheduled fire times (UTC, ISO 8601)
schedule.last_run_atstringLast execution time (appears after first run)
initial_eventsarrayEvents delivered on each run
resourcesarrayAttached resources
vault_idsarrayAssociated Vault IDs
metadataobjectCustom string key-value metadata
environment_variablesstringNormalized KEY=VALUE lines injected into sessions created by this deployment
statusstring"active" or "paused"
paused_reasonobject or nullStructured pause reason (e.g., {"type":"manual"})
archived_atstring or nullArchive timestamp (ISO 8601) or null
created_atstringCreation time (ISO 8601)
updated_atstringLast update time (ISO 8601)

CMA alignment

This endpoint aligns with the Anthropic CMA POST /v1/deployments spec. Key differences:
  • The agent field accepts both string and object forms (CMA requires object only).
  • environment_variables is a Qoder extension on deployments. It is stored on the deployment template and copied into sessions created by deployment runs.
  • Response includes upcoming_runs_at in the schedule object (up to 5 future fire times).

Errors

HTTPTypeTrigger
400invalid_request_errorMissing required field, object-form agent without type: "agent", invalid cron expression, invalid metadata or environment variables, unknown event type, or referenced Agent/Environment is archived
401authentication_errorPAT or SAT invalid or expired
404not_found_errorAgent or Environment does not exist
See Errors for the full error envelope.
Create a deployment - Qoder