> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Task Versions

> View the change history of a task

# Task Versions

Retrieve the version history (audit trail) of a task. Each version represents a change made to the task, showing who changed what and when.

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Path Parameters

<ParamField path="task_id" type="string" required>
  UUID of the task
</ParamField>

### Query Parameters

<ParamField query="page" type="integer" default="1">
  Page number
</ParamField>

<ParamField query="size" type="integer" default="50">
  Items per page
</ParamField>

## Response

Returns a paginated response with version entries.

<ResponseField name="items" type="array[object]">
  Version entries

  <ResponseField name="transaction_id" type="string">
    Transaction UUID
  </ResponseField>

  <ResponseField name="operation_type" type="integer">
    Operation: `0` (insert), `1` (update), `2` (delete)
  </ResponseField>

  <ResponseField name="issued_at" type="string">
    When the change occurred (ISO 8601)
  </ResponseField>

  <ResponseField name="user_first_name" type="string">
    First name of the user who made the change
  </ResponseField>

  <ResponseField name="user_last_name" type="string">
    Last name of the user who made the change
  </ResponseField>

  <ResponseField name="version_changes" type="array[object]">
    Fields that changed, each with `key`, `value`, `previous_value`
  </ResponseField>
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of versions
</ResponseField>

<ResponseField name="page" type="integer">
  Current page
</ResponseField>

<ResponseField name="size" type="integer">
  Page size
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl "https://api.dcycle.io/v1/tasks/${TASK_ID}/versions" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  response = requests.get(
      f"https://api.dcycle.io/v1/tasks/{os.getenv('TASK_ID')}/versions",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
  )

  data = response.json()
  for version in data["items"]:
      user = f"{version['user_first_name']} {version['user_last_name']}"
      changes = ", ".join(c["key"] for c in version["version_changes"])
      print(f"{version['issued_at']}: {user} changed {changes}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const { data } = await axios.get(
    `https://api.dcycle.io/v1/tasks/${process.env.TASK_ID}/versions`,
    {
      headers: {
        'x-api-key': process.env.DCYCLE_API_KEY,
        'x-organization-id': process.env.DCYCLE_ORG_ID,
      },
    }
  );

  data.items.forEach(v => {
    const changes = v.version_changes.map(c => c.key).join(', ');
    console.log(`${v.issued_at}: ${v.user_first_name} changed ${changes}`);
  });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "items": [
    {
      "transaction_id": "txn-uuid",
      "operation_type": 1,
      "issued_at": "2025-06-15T14:30:00Z",
      "user_first_name": "Ana",
      "user_last_name": "García",
      "version_changes": [
        {
          "key": "stage",
          "value": "completed",
          "previous_value": "in_progress"
        }
      ]
    }
  ],
  "total": 3,
  "page": 1,
  "size": 50
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 404 Not Found

**Cause:** The task does not exist or belongs to another organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Not Found"}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Get Task" icon="eye" href="/api-reference/projects/get-task">
    View current task state
  </Card>

  <Card title="Update Task" icon="pen" href="/api-reference/projects/update-task">
    Modify task fields
  </Card>
</CardGroup>
