> ## 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.

# Get Task

> Retrieve the current status and details of a workflow task

## Endpoint

```
GET /tasks/{task_id}
```

## Authentication

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

```bash theme={null}
X-API-Key: ca_your_api_key_here
```

## Path Parameters

| Parameter | Type    | Required | Description                    |
| --------- | ------- | -------- | ------------------------------ |
| `task_id` | integer | Yes      | Unique identifier for the task |

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://platform.chamelio.ai/tasks/12345" \
    -H "X-API-Key: ca_your_api_key_here"
  ```

  ```python Python theme={null}
  import requests

  task_id = 12345

  url = f"https://platform.chamelio.ai/tasks/{task_id}"
  headers = {
      "X-API-Key": "ca_your_api_key_here"
  }

  response = requests.get(url, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const taskId = 12345;

  const response = await fetch(
    `https://platform.chamelio.ai/tasks/${taskId}`,
    {
      method: 'GET',
      headers: {
        'X-API-Key': 'ca_your_api_key_here'
      }
    }
  );

  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>

## Response

### Success Response

**Status Code:** `200 OK`

```json theme={null}
{
  "task": {
    "task_id": 12345,
    "task_url": "https://app.chamelio.ai/workflows/tasks/12345",
    "task_title": "Vendor Contract Review - Acme Corporation",
    "workflow_id": "vendor_contract_review",
    "workflow_name": "Vendor Contract Review",
    "workflow_version": 1,
    "workflow_state_id": "ws_abc123",
    "status": "in_progress",
    "current_step_id": "review_step",
    "current_step_name": "AI Review",
    "current_step_type": "review",
    "created_at": "2025-01-20T10:30:00Z",
    "updated_at": "2025-01-20T10:35:00Z",
    "completed_at": null,
    "owner_email": "john.doe@example.com",
    "assignee_email": "legal@example.com",
    "collaborator_emails": ["contracts@example.com"],
    "step_runs": [
      {
        "step_run_id": "sr_001",
        "step_id": "intake_step",
        "step_name": "Document Intake",
        "step_type": "intake",
        "status": "completed",
        "variables": [
          {
            "variable_type": "text",
            "value": "Acme Corporation",
            "step_id": "intake_step",
            "variable_id": "vendor_name"
          }
        ]
      }
    ],
    "variables": [
      {
        "variable_type": "text",
        "value": "Acme Corporation",
        "step_id": "intake_step",
        "variable_id": "vendor_name"
      },
      {
        "variable_type": "number",
        "value": 150000,
        "step_id": "intake_step",
        "variable_id": "contract_value"
      },
      {
        "variable_type": "email",
        "value": "legal@example.com",
        "step_id": "intake_step",
        "variable_id": "reviewer_email"
      }
    ]
  }
}
```

### Response Fields

| Field  | Type   | Description                                        |
| ------ | ------ | -------------------------------------------------- |
| `task` | object | Complete task state including status and variables |

### Task Object Fields

| Field                 | Type             | Description                                                                                              |
| --------------------- | ---------------- | -------------------------------------------------------------------------------------------------------- |
| `task_id`             | integer          | Unique identifier for the task                                                                           |
| `task_url`            | string or null   | Direct URL to the task in the Chamelio web application                                                   |
| `task_title`          | string or null   | Human-readable title of the task                                                                         |
| `workflow_id`         | string           | Identifier of the workflow this task is running                                                          |
| `workflow_name`       | string or null   | Human-readable workflow name                                                                             |
| `workflow_version`    | integer          | Workflow version number                                                                                  |
| `workflow_state_id`   | string           | Identifier for the specific workflow state                                                               |
| `status`              | string           | Current task status: `created`, `in_progress`, `pending`, `completed`, `cancelled`, `failed`, `archived` |
| `current_step_id`     | string or null   | ID of the step currently being executed (null if completed)                                              |
| `current_step_name`   | string or null   | Name of the current step (null if completed)                                                             |
| `current_step_type`   | string or null   | Type of the current step (e.g., `"approval"`, `"review"`, `"intake"`, `"signature"`)                     |
| `created_at`          | string           | ISO 8601 timestamp when the task was created                                                             |
| `updated_at`          | string           | ISO 8601 timestamp of the last task update                                                               |
| `completed_at`        | string or null   | ISO 8601 timestamp when the task completed (null if not yet completed)                                   |
| `owner_email`         | string or null   | Email of the user who owns the task                                                                      |
| `assignee_email`      | string or null   | Email of the user currently assigned to the task                                                         |
| `collaborator_emails` | array of strings | Emails of users collaborating on the task                                                                |
| `step_runs`           | array            | History of step executions with their collected variables                                                |
| `variables`           | array            | All variables aggregated across all step runs                                                            |

### Step Run Object Fields

| Field         | Type   | Description                                                                                            |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------ |
| `step_run_id` | string | Unique identifier for this step run                                                                    |
| `step_id`     | string | Identifier for the step definition                                                                     |
| `step_name`   | string | Human-readable step name                                                                               |
| `step_type`   | string | Type of workflow component (e.g., `"intake"`, `"approval"`, `"signature"`, `"review"`)                 |
| `status`      | string | Step run status: `initiated`, `pending`, `in_progress`, `completed`, `failed`, `rejected`, `cancelled` |
| `variables`   | array  | Variables collected during this step run                                                               |

### Variable Object Fields

Used in both `step_runs[].variables` and the top-level `variables` array.

| Field           | Type   | Description                                                                                                                                                                                              |
| --------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `variable_type` | string | Type of the variable: `text`, `number`, `boolean`, `date`, `email`, `file`, `select`, `multi_select`, `user_entity`, `business`, `dynamic_list`, `dynamic_table`, `number_with_currency`, `conversation` |
| `value`         | any    | Current value of the variable (string, number, boolean, array, or null)                                                                                                                                  |
| `step_id`       | string | ID of the step that collected this variable                                                                                                                                                              |
| `variable_id`   | string | Unique identifier for the variable                                                                                                                                                                       |

## Error Responses

### 401 Unauthorized

Returned when authentication fails. See the [authentication errors](/api-reference/introduction#authentication-errors) section for details.

```json theme={null}
{
  "detail": "Invalid API key"
}
```

### 404 Not Found

Returned when the task doesn't exist or you don't have access to it.

```json theme={null}
{
  "detail": "Task not found"
}
```

### 500 Internal Server Error

Returned when the request fails due to a server error.

```json theme={null}
{
  "detail": "Failed to get task"
}
```

## Notes

<Info>
  Poll this endpoint periodically to monitor task progress. The `status` field can be one of: `created`, `in_progress`, `pending`, `completed`, `cancelled`, `failed`, or `archived`.
</Info>

<Tip>
  Use `current_step_id` and `current_step_type` to understand which step the workflow is currently executing. If `current_step_type` is `"approval"`, you can use the [Get Approval Details](/api-reference/endpoint/tasks/approval-details) endpoint for more information about the approval step.
</Tip>

## Use Cases

This endpoint is useful for:

* **Status monitoring** - Track workflow progress and completion
* **Variable retrieval** - Get values collected during workflow execution
* **Step history** - Review which steps have run and what data each collected
* **Debugging** - Understand where a workflow is stuck or failed
* **User notifications** - Display current workflow status in your application
