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

# Export Expired Jobs

> Start a task to export all expired jobs since a date as a JSONL file

Export the full expired-jobs feed since a given date as a downloadable JSONL file. This endpoint creates an async task and returns immediately; poll [Get Task Status](/docs/api-reference/tasks/get-task-status) for the download URL.

<Info>
  **This is the intended path for large historical pulls.** The [Expired Jobs feed](/docs/api-reference/jobs/expired-jobs) is subject to deep-pagination limits (only roughly the most recent 350–450k records of a window are reachable page-by-page). The export walks the entire result set server-side with no page-depth limit — a one-week window of \~1M records exports completely.
</Info>

<Warning>
  This endpoint requires an API key for **all** requests. See [Authentication](/docs/authentication).
</Warning>

## Endpoint

```bash theme={null}
POST /v2/jobs/expired-jobs/export
```

## Authentication

<ParamField header="x-api-key" type="string" required>
  Your Hirebase API key
</ParamField>

## Request Body

<ParamField body="since" type="string" required>
  Starting date/datetime to export expired jobs from. Accepts ISO 8601 date (`"2026-08-15"`) or full datetime (`"2026-08-15T14:00:00Z"`). Naive datetimes are treated as UTC. Invalid values return `400` with a descriptive message; a missing `since` returns `422`.
</ParamField>

<ParamField body="notify" type="boolean" default="false">
  Set to `true` to receive an email at your account address when the export completes, containing the download link.
</ParamField>

<Note>
  There is no `format` field — expired-jobs exports are always **JSONL** (one JSON object per line).
</Note>

## Metering

Expired-jobs exports are **free**: they cost 0 units of your Jobs API allowance (`m_jobs_api_calls`), regardless of how many records they export. Expired data is not billed; only live job data is.

## Response

Returns a task object (`type: "export_expired_jobs"`, initial `state: "queued"`). Poll [`GET /v2/tasks/{task_id}`](/docs/api-reference/tasks/get-task-status); when `state` is `"finished"`, `result` contains:

<ResponseField name="result" type="object">
  <Expandable>
    <ResponseField name="download_url" type="string">
      URL to download the JSONL file
    </ResponseField>

    <ResponseField name="file_size" type="integer">
      File size in bytes
    </ResponseField>

    <ResponseField name="record_count" type="integer">
      Number of expired-job records exported
    </ResponseField>

    <ResponseField name="expiry_time" type="string">
      ISO timestamp when the download URL expires (30 days after completion)
    </ResponseField>
  </Expandable>
</ResponseField>

## Exported Record Fields

Each JSONL line contains exactly:

* `_id` — unique job identifier; use it as `job_id` in [`GET /v2/jobs/{job_id}`](/docs/api-reference/jobs/get-by-id)
* `company_slug`
* `job_slug`
* `date_expired` (`YYYY-MM-DD`)

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST 'https://api.hirebase.org/v2/jobs/expired-jobs/export' \
    -H 'x-api-key: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{"since": "2026-08-15T00:00:00Z", "notify": true}'
  ```

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

  headers = {"x-api-key": "YOUR_API_KEY"}
  task = requests.post(
      "https://api.hirebase.org/v2/jobs/expired-jobs/export",
      headers=headers,
      json={"since": "2026-08-15T00:00:00Z", "notify": True},
  ).json()

  while True:
      t = requests.get(f"https://api.hirebase.org/v2/tasks/{task['id']}", headers=headers).json()
      if t["state"] in ("finished", "failed"):
          break
      time.sleep(5)

  if t["state"] == "finished":
      jsonl = requests.get(t["result"]["download_url"]).text
      records = [line for line in jsonl.splitlines() if line]
      print(len(records), "expired jobs")
  ```
</CodeGroup>

<ResponseExample>
  ```json Task Response theme={null}
  {
    "id": "10411d18-aa49-4253-bcad-b0f604f092be",
    "type": "export_expired_jobs",
    "state": "queued",
    "progress": 0.0,
    "input": { "since": "2026-08-15T00:00:00Z", "format": "jsonl" },
    "result": null,
    "error": null
  }
  ```

  ```json Exported JSONL (one line per record) theme={null}
  {"_id": "6a7a7813250256b98912a4b2", "company_slug": "at-home", "job_slug": "zone-lead-ft-2a147c98", "date_expired": "2026-08-25"}
  ```
</ResponseExample>
