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

# Export Audit Log as CSV

Exports the audit log as a CSV file, with the same filters as [List Audit Log Entries](https://docs.timbrix.mx/api-reference/audit-logs/list.md) (`cursor` and `limit` do not apply). Dates are written in America/Mexico\_City time, and actions use their plain-Spanish label (for example `Timbró CFDI`) instead of the internal code.

Exporting the log is itself recorded in the log (`audit_log.exported`).

> **Limit**: up to **50,000 rows** per export. If the filters match more, the endpoint returns `422` with code `AUDIT_EXPORT_TOO_LARGE` and no file; narrow the date range or add filters and try again.

## Authentication

Accepts **either**:

* An API key (`X-API-Key: sk_...`) with the `read:audit-logs` scope.
* A Supabase Bearer session (`Authorization: Bearer <token>`) with the `X-Organization-Id: <org-id>` header — the user must be an owner or admin of that organization.

## Example Request

```bash theme={null}
curl "https://api.timbrix.mx/audit-logs/export.csv?from=2026-10-01&to=2026-10-31" \
  -H "X-API-Key: sk_..." \
  -o bitacora-octubre.csv
```

```typescript theme={null}
import { writeFile } from "node:fs/promises"

const csv = await client.auditLogs.exportCsv(
  "550e8400-e29b-41d4-a716-446655440000",
  { from: "2026-10-01", to: "2026-10-31" }
)
await writeFile("bitacora-octubre.csv", csv, "utf8")
```

With the CLI:

```bash theme={null}
timbrix audit-logs export --org <org-id> --from 2026-10-01 --to 2026-10-31 --out bitacora-octubre.csv
```

## Common Errors

### 400 Bad Request

Invalid date or filter value.

### 403 Forbidden

Not an owner or admin, or the API key lacks the `read:audit-logs` scope.

### 422 Unprocessable Entity

`AUDIT_EXPORT_TOO_LARGE`: more than 50,000 entries match.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.