## GET /api/v2/audit-log

**List account audit events**

Return recent audit events for the authenticated account. The response keeps the raw endpoint/method fields for forensics, but also includes API-composed `summary`, `category`, `action`, `resourceLabel`, and `changes` fields so clients do not have to interpret route names or request bodies. By default this endpoint also merges dedicated DNS history events from `dns_audit_events`, which provide concrete before/after DNS record and nameserver changes. Use `hideGet=true` when the user wants changes rather than read-only page loads.

### Related Endpoints

- `GET /api/v2/me`: Get current account profile
- `PATCH /api/v2/me`: Update current account profile
- `GET /api/v2/cancellations`: List service cancellations

### Headers

- `Accept`: application/json
- `Authorization`: Bearer YOUR_API_KEY
- Required API scope: `audit:read`

### Parameters

- `limit` (query, integer) [min: 1, max: 100]: Page size from 1 to 100.
- `cursor` (query, string): Cursor returned by the previous page.
- `startAt` (query, string): Inclusive ISO-8601 lower bound. Defaults to the last 12 hours.
- `endAt` (query, string): Inclusive ISO-8601 upper bound.
- `hideGet` (query, boolean): Hide read-only GET events.
- `includeStats` (query, boolean): Include account-level audit counters for the selected window.
- `includeDnsEvents` (query, boolean): Include dedicated DNS history events with before/after DNS values. Defaults to true.

### Request Example

```bash
curl -X GET "https://cloud.hostup.se/api/v2/audit-log" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json"
```

### Response Schema

- `data` (array<object>, required)
- `data[].id` (string, required)
- `data[].occurredAt` (string, required)
- `data[].method` (string, required)
- `data[].endpoint` (string, required)
- `data[].path` (string, required)
- `data[].ipAddress` (string,null, optional)
- `data[].userAgent` (string,null, optional)
- `data[].statusCode` (integer,null, optional)
- `data[].success` (boolean, required)
- `data[].durationMs` (integer,null, optional)
- `data[].errorMessage` (string,null, optional)
- `data[].authMethod` (string,null, optional)
- `data[].resourcesAccessed` (array<string>, required)
- `data[].severity` (string, required)
- `data[].tags` (array<string>, required)
- `data[].eventSource` (string, required)
  Allowed values: request_audit, dns_history
- `data[].actorType` (string,null, optional)
  Allowed values: customer, staff, system, api, smartcopy, 
- `data[].actorId` (string,null, optional)
- `data[].requestId` (string,null, optional)
- `data[].category` (string, required)
  Allowed values: dns, domain, security, billing, api, account
- `data[].action` (string, required)
- `data[].summary` (string, required)
- `data[].resourceLabel` (string,null, optional)
- `data[].changes` (array<object>, required)
- `data[].changes[].label` (string, required)
- `data[].changes[].before` (string,null, required)
- `data[].changes[].after` (string,null, required)
- `total` (integer, required)
- `hasMore` (boolean, required)
- `nextCursor` (string,null, required)
- `stats` (object, optional)

### Responses

#### 200 - Paginated audit events.
```json
{
  "data": [
    {
      "id": "b95de54b-2d8d-45f1-96b9-2d2e5a3c02fb",
      "occurredAt": "2026-05-19T09:55:00.000Z",
      "method": "PUT",
      "endpoint": "/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m4",
      "path": "/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/records/drr_01hxa3b4c5d6e7f8g9h0j1k2m4",
      "ipAddress": "203.0.113.25",
      "userAgent": "Mozilla/5.0",
      "statusCode": 200,
      "success": true,
      "durationMs": 214,
      "errorMessage": null,
      "authMethod": "session",
      "resourcesAccessed": [
        "v2_dns_zone:zone_01hxa3b4c5d6e7f8g9h0j1k2m3:record_update"
      ],
      "severity": "info",
      "tags": [
        "v2_dns_record_update"
      ],
      "eventSource": "request_audit",
      "actorType": null,
      "actorId": null,
      "requestId": null,
      "category": "dns",
      "action": "dns_record_update",
      "summary": "Changed DNS record A @ -> 203.0.113.10.",
      "resourceLabel": "drr_01hxa3b4c5d6e7f8g9h0j1k2m4",
      "changes": [
        {
          "label": "Example Label",
          "before": null,
          "after": "203.0.113.10"
        }
      ]
    }
  ],
  "total": 1,
  "hasMore": false,
  "nextCursor": null
}
```

#### 400 - Invalid request. The response body is an RFC 7807 Problem Details document.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "The request body failed validation.",
  "code": "invalid_request",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z",
  "errors": [
    {
      "pointer": "/items/0/domainName",
      "detail": "`domainName` is required.",
      "code": "invalid_request"
    }
  ]
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - Forbidden. The caller lacks a required scope or does not own the resource.
```json
{
  "type": "https://developer.hostup.se/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "The caller lacks a required scope or does not own the resource.",
  "code": "forbidden",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 404 - Not found. The resource does not exist or is not owned by the caller.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Too many requests. Retry after the limit resets.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```
