# Audit Logs

The Audit Logs API provides access to operational audit records for AI operations. Every chat and embedding request is logged with details about the request, response, tokens used, and outcome.

## Endpoints

| Method | Endpoint                                                                                                                     | Description                     |
| ------ | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
| GET    | [`/umbraco/ai/management/api/v1/audit-logs`](/ai-in-umbraco/management-api/audit-logs/list.md)                               | List audit logs with filtering  |
| GET    | [`/umbraco/ai/management/api/v1/audit-logs/{id}`](/ai-in-umbraco/management-api/audit-logs/get.md)                           | Get a specific audit log entry  |
| GET    | [`/umbraco/ai/management/api/v1/audit-logs?entityId={entityId}`](/ai-in-umbraco/management-api/audit-logs/entity-history.md) | Get audit history for an entity |
| DELETE | [`/umbraco/ai/management/api/v1/audit-logs/{id}`](/ai-in-umbraco/management-api/audit-logs/delete.md)                        | Delete a specific audit log     |
| POST   | [`/umbraco/ai/management/api/v1/audit-logs/cleanup`](/ai-in-umbraco/management-api/audit-logs/cleanup.md)                    | Clean up old audit logs         |

## Base URL

```
/umbraco/ai/management/api/v1
```

## Audit Log Object

{% code title="Audit Log" %}

```json
{
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "startTime": "2024-01-25T09:15:00Z",
    "endTime": "2024-01-25T09:15:02Z",
    "duration": "00:00:02.345",
    "status": "Succeeded",
    "errorCategory": null,
    "errorMessage": null,
    "userId": "user-guid",
    "userName": "admin@example.com",
    "entityId": "content-guid",
    "entityType": "document",
    "capability": "Chat",
    "profileId": "profile-guid",
    "profileAlias": "content-assistant",
    "profileVersion": 5,
    "providerId": "openai",
    "modelId": "gpt-4o",
    "featureType": "prompt",
    "featureId": "prompt-guid",
    "featureVersion": 2,
    "inputTokens": 150,
    "outputTokens": 420,
    "totalTokens": 570,
    "detailLevel": "Standard",
    "parentAuditLogId": null
}
```

{% endcode %}

## Status Values

| Status           | Description                      |
| ---------------- | -------------------------------- |
| `Running`        | Operation is in progress         |
| `Succeeded`      | Operation completed successfully |
| `Failed`         | Operation failed with an error   |
| `Cancelled`      | Operation was cancelled          |
| `PartialSuccess` | Operation partially completed    |

## Error Categories

| Category         | Description                  |
| ---------------- | ---------------------------- |
| `Authentication` | API key or credential issues |
| `RateLimit`      | Provider rate limit exceeded |
| `Timeout`        | Request timed out            |
| `InvalidRequest` | Malformed request            |
| `ModelError`     | Model processing error       |
| `NetworkError`   | Connection issues            |
| `Unknown`        | Unclassified error           |

## Detail Levels

Audit logs can be stored with different levels of detail:

| Level      | Includes                          |
| ---------- | --------------------------------- |
| `Minimal`  | Timing, status, tokens only       |
| `Standard` | Above + profile, model, user info |
| `Full`     | Above + prompt/response snapshots |

{% hint style="info" %}
Detail level is configured in application settings. Higher detail levels use more storage.
{% endhint %}

## Related

* [Audit Logs Backoffice](/ai-in-umbraco/backoffice/audit-logs.md)
* [Usage Analytics](/ai-in-umbraco/management-api/analytics.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.umbraco.com/ai-in-umbraco/management-api/audit-logs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
