> ## 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 Activity Logs

> Retrieve the activity log history for a task, including comments, approvals, and other actions

## Endpoint

```
GET /v2/tasks/{task_id}/activity-logs
```

## Authentication

This endpoint requires an OAuth access token. Send it as a bearer token:

```bash theme={null}
Authorization: Bearer your_access_token
```

**Required scope:** `tasks:read`

## Path Parameters

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

## Query Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `limit` | integer | 50 | Maximum number of logs to return (1–200) |
| `offset` | integer | 0 | Pagination offset |
| `only_user_comments` | boolean | false | When `true`, only return user comment entries |

## Request Example

```bash cURL theme={null}
curl -X GET "https://platform.chamelio.ai/v2/tasks/12345/activity-logs?limit=20&offset=0&only_user_comments=true" \
  -H "Authorization: Bearer your_access_token"
```

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

task_id = 12345

url = f"https://platform.chamelio.ai/v2/tasks/{task_id}/activity-logs"
headers = {
    "Authorization": "Bearer your_access_token"
}
params = {
    "limit": 20,
    "offset": 0,
    "only_user_comments": True
}

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

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

const params = new URLSearchParams({
  limit: 20,
  offset: 0,
  only_user_comments: true
});

const response = await fetch(
  `https://platform.chamelio.ai/v2/tasks/${taskId}/activity-logs?${params}`,
  {
    headers: {
      'Authorization': 'Bearer your_access_token'
    }
  }
);

const data = await response.json();
console.log(data);
```

## Response

### Success Response

**Status Code:** `200 OK`

```json theme={null}
{
  "activity_logs": [
    {
      "activity_log_id": 98765,
      "action_type": "general.comment",
      "message": "The contract has been reviewed and looks good.",
      "user_id": 42,
      "user_email": "reviewer@example.com",
      "created_at": "2025-03-15T14:30:00Z",
      "reply_to": null,
      "mention_emails": ["manager@example.com"],
      "attachment_ids": [501, 502]
    },
    {
      "activity_log_id": 98770,
      "action_type": "approval.user_approved",
      "message": "Task approved by manager@example.com",
      "user_id": 57,
      "user_email": "manager@example.com",
      "created_at": "2025-03-15T15:00:00Z",
      "reply_to": null,
      "mention_emails": [],
      "attachment_ids": []
    }
  ],
  "total_count": 2
}
```

### Response Fields

| Field | Type | Description |
| - | - | - |
| `activity_logs` | array | List of activity log entries |
| `total_count` | integer | Total number of matching logs (for pagination) |

### Activity Log Entry Fields

| Field | Type | Description |
| - | - | - |
| `activity_log_id` | integer | Unique ID of the activity log entry |
| `action_type` | string | Type of action (e.g., `"general.comment"`, `"approval.user_approved"`) |
| `message` | string | Description of the action or comment text |
| `user_id` | integer \| null | ID of the user who performed the action |
| `user_email` | string \| null | Email of the user who performed the action |
| `created_at` | string | ISO 8601 timestamp of when the action occurred |
| `reply_to` | integer \| null | Activity log ID of the parent comment (if this is a reply) |
| `mention_emails` | array\[string] | Emails mentioned in this entry |
| `attachment_ids` | array\[integer] | IDs of attachments associated with this entry |

## Error Responses

### 400 Bad Request

Returned when the access token has no user behind it.
`client_credentials` tokens act as the admin who created the application, so this applies only to
tokens issued before application creators were recorded.

```json theme={null}
{
  "detail": "client_credentials tokens are not associated with a user"
}
```

### 401 Unauthorized

Returned when the access token is missing, unknown, revoked, or expired, or when an `X-API-Key` was
sent instead of a bearer token. See [OAuth error responses](https://docs.chamelio.ai/api-reference/oauth-apps.md#error-responses).

```json theme={null}
{
  "detail": "Invalid access token"
}
```

### 403 Forbidden

Returned when the token lacks the required scope:

```json theme={null}
{
  "detail": "Insufficient scope; this endpoint requires: tasks:read"
}
```

Or when the user may not access this task:

```json theme={null}
{
  "detail": "You do not have access to this resource"
}
```

### 404 Not Found

Returned when the task does not exist.

```json theme={null}
{
  "detail": "Not found"
}
```

### 422 Validation Error

Returned when query parameters are invalid (e.g., `limit` outside the 1–200 range).

```json theme={null}
{
  "detail": [
    {
      "loc": ["query", "limit"],
      "msg": "ensure this value is less than or equal to 200",
      "type": "value_error.number.not_le"
    }
  ]
}
```

### 429 Too Many Requests

Returned when your organization exceeds its per-minute request limit.

```json theme={null}
{
  "detail": "Rate limit exceeded"
}
```

### 500 Internal Server Error

Returned when the request fails due to a server error.

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

## Notes

> [!NOTE]
>
> Use the `activity_log_id` from these results as the `reply_to` value when
> [adding a comment](https://docs.chamelio.ai/api-reference/endpoint/v2/tasks/add-comment.md) to create threaded conversations.

> [!TIP]
>
> Set `only_user_comments` to `true` to filter out system-generated entries and see only comments posted
> by users.

> [!TIP]
>
> Use `limit` and `offset` together to paginate through large activity histories. The `total_count` field
> tells you how many entries exist in total.

## Use Cases

This endpoint is useful for:

* **Audit trails** - Review the full history of actions taken on a task
* **Comment syncing** - Pull task comments into external systems like Slack or a CRM
* **Threaded replies** - Fetch existing comments to display conversation threads and reply to specific entries
* **Activity dashboards** - Build custom views showing task progress and team interactions
