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}/approve

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

Request Body

The request body must be a JSON object with the following fields:

Required Fields

FieldTypeDescription
approvedbooleanWhether the task is approved (true) or rejected (false)

Optional Fields

FieldTypeDescription
commentstringOptional comment explaining the approval or rejection decision
variablesarrayAdditional variable values collected during the approval step
user_emailstringEmail of the user submitting the approval (defaults to API key owner)

Request Example

curl -X POST "https://platform.chamelio.ai/tasks/12345/approve" \
  -H "X-API-Key: ca_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "approved": true,
    "comment": "Contract terms look acceptable. Approved for signing.",
    "variables": [
      {
        "variable_id": "approval_notes",
        "type": "text",
        "value": "Verify insurance requirements before final signature"
      }
    ],
    "user_email": "manager@example.com"
  }'

Response

Success Response

Status Code: 200 OK
{
  "task_id": 12345,
  "status": "in_progress",
  "approved": true,
  "message": "Approval submitted successfully"
}

Response Fields

FieldTypeDescription
task_idintegerID of the task
statusstringUpdated task status (typically "in_progress" as workflow continues to next step)
approvedbooleanWhether the task was approved or rejected
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 is not at an approval step or has already been approved/rejected.
{
  "detail": "Task is not awaiting approval"
}

422 Validation Error

Returned when the request body is invalid or variables don’t match the expected schema.
{
  "detail": [
    {
      "loc": ["body", "approved"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

500 Internal Server Error

Returned when submission fails due to a server error.
{
  "detail": "Failed to submit approval"
}

Notes

When a task is approved, the workflow continues to the next step. When rejected, the workflow typically ends or follows a rejection path defined in the workflow.
Use the comment field to document the reasoning behind approval or rejection decisions for audit and compliance purposes.
Ensure the task is at an approval step before calling this endpoint. Check the current_step_type from the Get Task endpoint.

Use Cases

This endpoint is useful for:
  • Automated approvals - Integrate approval workflows with external systems
  • Custom approval UIs - Build custom interfaces for task approval
  • Conditional approvals - Approve tasks based on external business logic
  • Bulk approvals - Process multiple approval requests programmatically