Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.chamelio.ai/llms.txt

Use this file to discover all available pages before exploring further.

Endpoint

POST /tasks/{task_id}/cancel

Authentication

This endpoint requires authentication via API key. Include your API key in the X-API-Key header:
X-API-Key: ca_your_api_key_here

Path Parameters

ParameterTypeRequiredDescription
task_idintegerYesUnique identifier for the task to cancel

Request Example

curl -X POST "https://platform.chamelio.ai/tasks/12345/cancel" \
  -H "X-API-Key: ca_your_api_key_here"

Response

Success Response

Status Code: 200 OK
{
  "task_id": 12345,
  "status": "cancelled",
  "message": "Task cancelled successfully"
}

Response Fields

FieldTypeDescription
task_idintegerID of the cancelled task
statusstringUpdated task status (should be "cancelled")
messagestringSuccess confirmation message

Error Responses

401 Unauthorized

Returned when authentication fails. See the authentication errors section for details.
{
  "detail": "Invalid API key"
}

404 Not Found

Returned when the task doesn’t exist or you don’t have access to it.
{
  "detail": "Task not found"
}

409 Conflict

Returned when the task cannot be cancelled (e.g., already completed or already cancelled).
{
  "detail": "Task cannot be cancelled in its current state"
}

500 Internal Server Error

Returned when cancellation fails due to a server error.
{
  "detail": "Failed to cancel task"
}

Notes

Cancelling a task is irreversible. The workflow will stop at its current step and cannot be resumed.
Only tasks with status pending or in_progress can be cancelled. Completed, failed, or already cancelled tasks cannot be cancelled.

Use Cases

This endpoint is useful for:
  • User-initiated cancellation - Allow users to stop workflows they no longer need
  • Error handling - Cancel workflows that are stuck or encountering issues
  • Workflow management - Clean up unnecessary or duplicate workflow instances
  • Resource optimization - Stop workflows that are no longer relevant to free up resources