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

# Export Jobs Guide

> Create, monitor, and download asynchronous export jobs

## Overview

Exports are asynchronous and use raw job snapshots rather than the standard envelope.
Use exports when a search result set is too large for interactive pagination or when another system needs a durable CSV, JSONL, text, HTML, or JSON file. The `type` field selects the export family (`docs`, `victims`, or `breach`), while `service` tells OathNet which search service should produce the rows.

The export workflow has the same mental model as other long-running jobs:

* create a job from a search family, output format, fields, limit, and `query_config`
* poll until the job is complete, failed, or expired
* download the generated file while it is still available
* use list history to avoid creating duplicate exports

<Note>
  Successful create responses return HTTP `202` with a raw job snapshot.
</Note>

## Create And Poll

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://oathnet.org/api/service/v2/exports" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "service": "breach",
      "type": "breach",
      "format": "jsonl",
      "limit": 10000,
      "fields": ["email", "password", "dbname"],
      "query_config": {
        "filter": {
          "field": "email_domain",
          "operator": "eq",
          "value": "example.com"
        }
      }
    }'
  ```

  ```python Python theme={null}
  import requests
  import time

  create_response = requests.post(
      "https://oathnet.org/api/service/v2/exports",
      headers={
          "x-api-key": "YOUR_API_KEY",
          "Content-Type": "application/json",
      },
      json={
          "service": "breach",
          "type": "breach",
          "format": "jsonl",
          "limit": 10000,
          "fields": ["email", "password", "dbname"],
          "query_config": {
              "filter": {
                  "field": "email_domain",
                  "operator": "eq",
                  "value": "example.com",
              }
          },
      },
  )

  job = create_response.json()
  job_id = job["job_id"]

  while True:
      snapshot = requests.get(
          f"https://oathnet.org/api/service/v2/exports/{job_id}",
          headers={"x-api-key": "YOUR_API_KEY"},
      ).json()

      if snapshot["status"] == "completed":
          break

      time.sleep(snapshot.get("next_poll_after_ms", 2000) / 1000)

  download = requests.get(
      f"https://oathnet.org/api/service/v2/exports/{job_id}/download",
      headers={"x-api-key": "YOUR_API_KEY"},
  )

  with open(snapshot["result"]["file_name"], "wb") as handle:
      handle.write(download.content)
  ```
</CodeGroup>

```json Create Response Example theme={null}
{
  "job_id": "exp_job_1704067200_abc123",
  "status": "queued",
  "created_at": "2024-01-01T10:00:00Z",
  "next_poll_after_ms": 1000,
  "request": {
    "type": "breach",
    "service": "breach",
    "format": "jsonl",
    "limit": 10000
  }
}
```

```json Completed Response Example theme={null}
{
  "job_id": "exp_job_1704067200_abc123",
  "status": "completed",
  "created_at": "2024-01-01T10:00:00Z",
  "completed_at": "2024-01-01T10:01:30Z",
  "progress": {
    "records_done": 10000,
    "records_total": 10000,
    "bytes_done": 1024000,
    "percent": 100.0,
    "updated_at": "2024-01-01T10:01:30Z"
  },
  "result": {
    "ready_at": "2024-01-01T10:01:30Z",
    "expires_at": "2024-01-01T22:01:30Z",
    "file_name": "export_breach_2024-01-01.jsonl",
    "file_size": 1024000,
    "format": "jsonl",
    "records": 10000
  }
}
```

## Notes

* Use `service` values `stealer`, `victims`, or `breach` for current requests.
* Use `query_config` when the export should reuse the same structured filter grammar as search, bulk search, or scanners.
* `list` and `status` responses are raw snapshots, not envelopes.
* `download` returns a file stream. Save bytes directly.

<CardGroup cols={2}>
  <Card title="Structured Filters" icon="filter" href="/guides/structured-filters">
    Reuse the same `query_config` grammar across search, scanners, and exports
  </Card>

  <Card title="Bulk Search" icon="list" href="/guides/bulk-search">
    Run one search shape across many terms before exporting
  </Card>

  <Card title="Pagination" icon="list" href="/guides/pagination">
    Use interactive pagination before switching to async exports
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/overview">
    Use OpenAPI for exact job schema, formats, statuses, and download behavior
  </Card>
</CardGroup>
