Skip to main content
POST /api/v1/cloud/environments/{environment_id}/work/{work_id}/stop Stops a work item. The request body is optional; an empty body or {} sends the default force=false request, also called a graceful stop. For starting or active items, force=false moves the item to stopping. The worker should drain the in-flight work, then call this endpoint again to confirm completion and move the item to stopped. force=true moves any live item directly to stopped.

Path parameters

ParameterTypeDescription
environment_idstringEnvironment ID with the env_ prefix
work_idstringWork item ID with the work_ prefix

Headers

HeaderRequiredDescription
AuthorizationYesBearer $QODER_PAT
Content-TypeNoapplication/json when a body is sent

Request body

FieldTypeRequiredDefaultDescription
forcebooleanNofalseIf true, force the item to stopped without graceful drain

Example request: force=false

curl -X POST "https://api.qoder.com/api/v1/cloud/environments/env_019e64e01a137caf953ac2ac7b42ec5c/work/work_019f3be4fd2475d9a784bf2c739e1194/stop" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{}'

Example request: force=true

curl -X POST "https://api.qoder.com/api/v1/cloud/environments/env_019e64e01a137caf953ac2ac7b42ec5c/work/work_019f3be4fd2475d9a784bf2c739e1194/stop" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{"force": true}'

Example response

HTTP 200 OK
{
  "id": "work_019f3be4fd2475d9a784bf2c739e1194",
  "type": "work",
  "environment_id": "env_019e64e01a137caf953ac2ac7b42ec5c",
  "data": {
    "type": "session",
    "id": "sess_019f3be3fa66750bb9a1fbcde85b5fe1"
  },
  "state": "stopping",
  "created_at": "2026-07-01T08:15:01Z",
  "acknowledged_at": "2026-07-01T08:15:04Z",
  "started_at": "2026-07-01T08:15:06Z",
  "latest_heartbeat_at": "2026-07-01T08:16:06.120394Z",
  "stop_requested_at": "2026-07-01T08:16:30Z",
  "stopped_at": null,
  "metadata": {}
}

Response fields

Returns the updated Work item object.

Errors

HTTPTypeTrigger
400invalid_request_errorRequest body is not valid JSON
400invalid_request_errorThe Environment is not self_hosted
401authentication_errorPAT invalid or expired
403permission_errorNot authorized for this operation
404not_found_errorEnvironment or work item not found
See Errors for the full error envelope.

State transitions

force=false means an empty body, {}, or {"force": false}. force=true means {"force": true}.
forceCurrent stateResult
falsequeuedstopped
falsestarting or activestopping
falsestoppingstopped
falsestoppedReturns the existing stopped item
trueAny live statestopped

Cloud environment setup

Choose the container, network, and dependencies your agent runs in.