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

# Exporting Data

> Access audit logs, export logs, and download exported logs from the Portkey app or the API.

This page covers three tasks. Each has an app flow and an API flow.

1. [Access audit logs](#1-access-audit-logs): see who changed what in your organisation
2. [Export logs](#2-export-logs): create an export job for your request logs
3. [Download exported logs](#3-download-exported-logs): get the finished file

> [!NOTE]
>
> Have a list of IDs, such as from a data pack? See [Look up by request ID](#look-up-by-request-id) for audit log entries and [Export specific logs by ID](#export-specific-logs-by-id) for logs.

## 1. Access audit logs

Audit logs record administrative changes: who made a change, to which resource, and when.

### Access in the app

Go to **Admin Settings > Audit Logs**. Audit logs are collected automatically across all workspaces. See [Audit Logs](https://docs.portkey.ai/docs/product/enterprise-offering/audit-logs.md) for what each entry contains.

### Filters

Narrow the results with any of these filters:

| Filter | Description |
| - | - |
| **Time range** | Period to search |
| **Method** | HTTP method: `POST`, `PUT`, or `DELETE` |
| **Request ID** | A specific request |
| **Resource type** | Type of resource affected, such as workspaces, API keys, integrations, configs, guardrails, or prompts |
| **Action** | Create, update, delete, publish, export, rotate, manage, or duplicate |
| **Response status** | HTTP status code |
| **Workspace** | A specific workspace |
| **User** | The user or API key that made the change |
| **Client IP** | Originating IP address |
| **Country** | Originating country |

In the app, use the filters on the Audit Logs page.

### Access with the API

Call [`GET /audit-logs`](https://docs.portkey.ai/docs/api-reference/admin-api/control-plane/audit-logs/list-audit-logs). `start_time`, `end_time`, and `organisation_id` are required. `start_time` and `end_time` are ISO 8601 timestamps.

```bash theme={"system"}
curl "https://api.portkey.ai/v1/audit-logs?start_time=2026-11-01T00:00:00Z&end_time=2026-11-18T23:59:59Z&organisation_id=YOUR_ORGANISATION_ID" \
  -H "x-portkey-api-key: YOUR_PORTKEY_API_KEY"
```

Add any of these query parameters to filter the results:

| Parameter | Filters by |
| - | - |
| `method` | `POST`, `PUT`, or `DELETE` |
| `uri` | URI path |
| `request_id` | Request ID |
| `user_id` | User ID |
| `user_type` | `user` or `api_key` |
| `workspace_id` | Workspace |
| `response_status_code` | HTTP status code |
| `resource_type` | Resource type |
| `action` | Action |
| `client_ip` | Client IP address |
| `country` | Country |

Results are paginated. Use `current_page` and `page_size` (maximum 100) to page through them.

### Look up by request ID

To fetch specific audit log entries from a list of request IDs, use `POST /v1/audit-logs/bulk` instead of paging through a time range. Use an organisation admin API key.

In the app, filter by **Request ID** and paste the ID.

With the API, send the request IDs in batches:

```bash theme={"system"}
curl -X POST "https://api.portkey.ai/v1/audit-logs/bulk" \
  -H "x-portkey-api-key: YOUR_ADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_ids": ["REQUEST_ID_1", "REQUEST_ID_2"],
    "last_page": true
  }'
```

* Send 500 to 2,500 request IDs per call.
* If the final batch has fewer than 500 IDs, set `last_page` to `true`.
* The response contains the matching audit log entries and a `total`.
* IDs with no entry are left out. You only see entries for your own organisation. Duplicate IDs are ignored.

Audit logs are not looked up through log exports. Use this endpoint.

## 2. Export logs

Exports run as jobs. Each job writes your request logs for a time range, or for a list of log IDs, to a JSONL file, up to 50,000 logs per job.

### Export in the app

**1. Open Exports**

Go to **Exports** on the main sidebar and click **Request Data**.

**2. Configure the export**

Set the **Time Range**, the **Logs Limits** (maximum number of logs or a custom offset), and the **Requested Fields** to include.

**3. Request and start the export**

Click **Request Export**. The job appears in the exports list with the status **Draft**. Click **Start** to run it.

### Export with the API

Create the export job, then start it. The job runs asynchronously.

**1. Create the export**

[`POST /v1/logs/exports`](https://docs.portkey.ai/docs/api-reference/admin-api/data-plane/logs/log-exports-beta/create-a-log-export) with a time range and the fields to export. The response contains the export `id`.

```bash theme={"system"}
curl -X POST "https://api.portkey.ai/v1/logs/exports" \
  -H "x-portkey-api-key: YOUR_PORTKEY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filters": {
      "created_at": {
        "gte": "2026-11-01T00:00:00Z",
        "lte": "2026-11-18T23:59:59Z"
      }
    },
    "requested_data": ["id", "created_at", "ai_model", "total_units", "cost", "response_status_code"]
  }'
```

**2. Start the export**

[`POST /v1/logs/exports/{export_id}/start`](https://docs.portkey.ai/docs/api-reference/admin-api/data-plane/logs/log-exports-beta/start-a-log-export)

```bash theme={"system"}
curl -X POST "https://api.portkey.ai/v1/logs/exports/EXPORT_ID/start" \
  -H "x-portkey-api-key: YOUR_PORTKEY_API_KEY"
```

For the full list of fields, restrictions on exportable fields, and a complete script, see [Logs Export](https://docs.portkey.ai/docs/product/observability/logs-export.md).

### Open a single log in the app

To open one log by its ID, use this URL pattern:

```
https://app.portkey.ai/organisation/ORGANISATION_ID/logs?logId=LOG_ID
```

### Export specific logs by ID

To get the full request and response for a list of log IDs, create an export with `filters.ids`. Use an organisation admin API key.

```bash theme={"system"}
curl -X POST "https://api.portkey.ai/v1/logs/exports" \
  -H "x-portkey-api-key: YOUR_ADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Logs by ID",
    "requested_data": ["id", "created_at", "request", "response"],
    "filters": { "ids": ["LOG_ID_1", "LOG_ID_2"] }
  }'
```

Then [start the export](#export-with-the-api) and [download it](#download-with-the-api) as for any other export.

* Include 1 to 50,000 IDs per export. For a longer list, create more than one export.
* Use `ids` only. Don't combine it with a date range or other filters.
* You can't change the IDs on an export after creating it. Create a new export.
* Export by ID returns logs even if they are older than your plan's log retention period.
* If your organisation blocks fields such as `request` or `response` from exports, creating the export is rejected. Check what is allowed with `GET /v1/logs/exports/field-restrictions`.
* Export by ID is for logs only.

#### Enterprise and self-hosted organisations

Enterprise logs are stored only in your own log store. If the IDs you have belong to logs stored on Portkey SaaS, add the query param `saas-logs-only=true` when creating the export:

```bash theme={"system"}
curl -X POST "https://api.portkey.ai/v1/logs/exports?saas-logs-only=true" \
  -H "x-portkey-api-key: YOUR_ADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "SaaS logs by ID",
    "requested_data": ["id", "created_at", "request", "response"],
    "filters": { "ids": ["LOG_ID_1", "LOG_ID_2"] }
  }'
```

## 3. Download exported logs

### Download in the app

**1. Wait for the export to finish**

Open **Exports** on the main sidebar. The status changes to **Success** when the job is done. If it shows **Failure**, click **Start Again** to retry.

**2. Download the file**

Click **Download** next to the completed export. The file is in JSONL format, one log entry per line.

### Download with the API

**1. Check the export status**

[`GET /v1/logs/exports/{export_id}`](https://docs.portkey.ai/docs/api-reference/admin-api/data-plane/logs/log-exports-beta/retrieve-a-log-export). Check about every 30 seconds until `status` is `success`.

```bash theme={"system"}
curl "https://api.portkey.ai/v1/logs/exports/EXPORT_ID" \
  -H "x-portkey-api-key: YOUR_PORTKEY_API_KEY"
```

**2. Get the download URL**

[`GET /v1/logs/exports/{export_id}/download`](https://docs.portkey.ai/docs/api-reference/admin-api/data-plane/logs/log-exports-beta/download-a-log-export) returns a signed URL. Use an organisation admin API key.

```bash theme={"system"}
curl "https://api.portkey.ai/v1/logs/exports/EXPORT_ID/download" \
  -H "x-portkey-api-key: YOUR_PORTKEY_API_KEY"
```

**3. Download the file**

The signed URL expires quickly, so download the file right away. If the link has expired, request a new one.

```bash theme={"system"}
curl -o logs_export.jsonl "SIGNED_DOWNLOAD_URL"
```

## Other data

* **Hook results:** results stored with your logs are included in log exports. For hook results that aren't in logs, email [datasupport@portkey.ai](mailto:datasupport@portkey.ai).
* **Fine-tuning runs:** list jobs with [`GET /v1/fine_tuning/jobs`](https://docs.portkey.ai/docs/api-reference/inference-api/fine-tuning/list-fine-tuning-jobs) and open one with [`GET /v1/fine_tuning/jobs/{job_id}`](https://docs.portkey.ai/docs/api-reference/inference-api/fine-tuning/retrieve-fine-tuning-job).

## Troubleshooting

| What you see | Likely cause | What to do |
| - | - | - |
| Fewer logs in the export than IDs in your list | Some IDs don't exist or belong to another organisation | Check the IDs against your list |
| `400` on `POST /v1/audit-logs/bulk` | Under 500 IDs without `last_page`, over 2,500 IDs, an empty list, or an invalid ID | Fix the batch and retry |
| `400` when creating an export | `ids` combined with other filters, an empty list, or a blocked field | Use `ids` only and check `GET /v1/logs/exports/field-restrictions` |
| `401` or `403` | The key isn't an organisation admin key, or (for export by ID) the organisation has an enterprise or self-hosted deployment | Use an organisation admin API key |
| The download link doesn't work | The signed link expired | Request a new link and download right away |

## Related

> [card] [Audit Logs](https://docs.portkey.ai/docs/product/enterprise-offering/audit-logs.md)

> [card] [Logs Export](https://docs.portkey.ai/docs/product/observability/logs-export.md)


## Related topics

- [Logs Export](https://docs.portkey.ai/docs/product/observability/logs-export.md)
- [Audit Logs](https://docs.portkey.ai/docs/product/enterprise-offering/audit-logs.md)
- [OpenTelemetry(OTel) Export](https://docs.portkey.ai/docs/product/enterprise-offering/otel/otel.md)
- [Analytics Export](https://docs.portkey.ai/docs/product/enterprise-offering/otel/analytics.md)
- [Data Service](https://docs.portkey.ai/docs/changelog/data-service.md)


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