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

# Invoice Audit Trail API

> Retrieve audit trail information for a specific invoice by its identifier

## Authentication

All requests require an API key in the request headers.

**Headers:**

```
Authorization: Api-Key YOUR_API_KEY
```

## Request

**Content-Type:** `application/json`

### Path Parameters

| Parameter | Type   | Required | Description                                      |
| --------- | ------ | -------- | ------------------------------------------------ |
| `id`      | string | Yes      | The unique identifier of the invoice to retrieve |

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://api.pazy.io/v1.0/invoice/invoice_identifier/audit-trail \
    -H "Authorization: Api-Key YOUR_API_KEY"
  ```

  ```javascript JavaScript (Fetch API) theme={null}
  const response = await fetch(
    "https://api.pazy.io/v1.0/invoice/invoice_identifier/audit-trail",
    {
      method: "GET",
      headers: {
        Authorization: "Api-Key YOUR_API_KEY",
      },
    },
  );

  const result = await response.json();
  ```

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

  url = "https://api.pazy.io/v1.0/invoice/invoice_identifier/audit-trail"
  headers = {
      "Authorization": "Api-Key YOUR_API_KEY"
  }

  response = requests.get(url, headers=headers)
  result = response.json()
  ```
</CodeGroup>

## Success Response

**HTTP Status:** `200 OK`

**Response Fields:**

| Field                                  | Type    | Description                                                                                                                                                                                                            |
| -------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ok`                                   | boolean | Indicates whether the request was successful                                                                                                                                                                           |
| `data`                                 | object  | Contains the invoice audit trail response data                                                                                                                                                                         |
| `data.auditTrail`                      | array   | List of audit trail associated with the invoice                                                                                                                                                                        |
| `data.auditTrail[].dateCreated`        | string  | The date when the audit trail entry was created (ISO 8601 format)                                                                                                                                                      |
| `data.auditTrail[].actionType`         | string  | The type of the audit. It is one of five values: `TRANSITION`, `REPAIR`, `DRAFTED`, `SYNCED`, `EDIT`, `PAYMENT`, `ATTACHMENT`, `OVERRIDES`, `MIGRATED`, `REFUND`, `ACKNOWLEDGEMENT`, `PAYMENT_SYNCED`, `FLAG_RESOLVED` |
| `data.auditTrail[].user`               | object  | Information about the user who made the comment                                                                                                                                                                        |
| `data.auditTrail[].user.id`            | string  | Unique identifier for the user                                                                                                                                                                                         |
| `data.auditTrail[].user.name`          | string  | Name of the user                                                                                                                                                                                                       |
| `data.auditTrail[].details`            | object  | Details about the audit trail entry                                                                                                                                                                                    |
| `data.auditTrail[].details.change`     | object  | Give the state of old and new state                                                                                                                                                                                    |
| `data.auditTrail[].details.change.old` | object  | Give the old state                                                                                                                                                                                                     |
| `data.auditTrail[].details.change.new` | object  | Give the new state                                                                                                                                                                                                     |
| `data.auditTrail[].details.actionBy`   | string  | Give who performed the action: `USER`, `PLATFORM`                                                                                                                                                                      |
| `data.context`                         | object  | Additional context for the audit trail                                                                                                                                                                                 |
| `data.context.count`                   | number  | The total number of audit trail                                                                                                                                                                                        |

### Response Example

```json theme={null}
{
  "ok": true,
  "data": {
    "auditTrail": [
      {
        "dateCreated": "2026-03-17T06:18:54.434Z",
        "actionType": "TRANSITION",
        "user": {
          "id": "<userId>",
          "name": "John Doe"
        },
        "details": {
          "change": {
            "new": "PENDING",
            "old": "DRAFTED"
          },
          "actionBy": "USER"
        }
      }
    ],
    "context": {
      "count": 1
    }
  }
}
```

## Error Responses

### Missing Invoice ID

**HTTP Status:** `400 Bad Request`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "MISSING_REQUIRED_FIELD",
    "message": "Invoice ID is required"
  }
}
```

### Invoice Not Found

**HTTP Status:** `404 Not Found`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "INVOICE_NOT_FOUND",
    "message": "Invoice not found"
  }
}
```

### Access Denied

**HTTP Status:** `403 Forbidden`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "ACCESS_DENIED",
    "message": "Access denied: You can only view your own invoices or invoices where you are the vendor owner"
  }
}
```

### Authentication Errors

**HTTP Status:** `401 Unauthorized`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "MISSING_CREDENTIALS",
    "message": "Missing Credentials"
  }
}
```

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "Invalid API Key"
  }
}
```

### Permission Errors

**HTTP Status:** `403 Forbidden`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "INSUFFICIENT_PERMISSIONS",
    "message": "Permission check failed - PERMISSION_CHECK_FAILED"
  }
}
```

## Best Practices

### Access Control

* Only invoices you created or where you are the vendor owner are accessible (unless you have admin or auditor role)
* Use the invoice `id` returned from the invoice creation endpoint to retrieve audit trail
