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

# Extract

> Upload a PDF and extract structured data in one command.

`okra extract` uploads, processes, and extracts structured data from a PDF in one step. The source can be a **local file path**, a **URL**, or the **document ID** of a PDF you already uploaded.

```bash theme={null}
# From a local file
okra extract ./report.pdf

# From a URL
okra extract https://example.com/report.pdf

# From an existing document
okra extract doc-abc123
```

## Structured extraction with a schema

Pass a JSON Schema to get structured JSON back. The schema can be a file path or inline JSON.

```bash theme={null}
okra extract ./invoice.pdf \
  --schema ./invoice.schema.json \
  --prompt "Extract vendor, total, currency, and due date"
```

When stdout is not a TTY (or with `--json`), the result comes back in the standard envelope:

```json theme={null}
{
  "ok": true,
  "command": "extract",
  "result": { "data": {} },
  "cost": { "usd": null },
  "citations": [],
  "next_actions": []
}
```

## Per-field citations (`--cite`)

Add `--cite` to attach **per-field source citations** — the page and bounding box each extracted value came from. Grounding is opt-in: without `--cite` you get values only.

```bash theme={null}
okra extract ./invoice.pdf --schema ./invoice.schema.json --cite
```

Citations are returned in the Anthropic-shaped `citations` array (`type: page_location`, with the source page, bbox, and the schema field each value maps to), alongside the extracted `data`.

## Fire-and-forget (`--no-wait`)

By default `okra extract` waits for processing to finish. Use `--no-wait` to queue the work and return immediately; follow up with `okra jobs wait`.

```bash theme={null}
okra extract ./report.pdf --no-wait
okra jobs wait <docId>
```

## Flags

| Flag               | Description                                                              |
| ------------------ | ------------------------------------------------------------------------ |
| `--schema <file>`  | JSON Schema file or inline JSON for structured extraction                |
| `--prompt <query>` | Extraction prompt (default: "Extract all data according to the schema")  |
| `--cite`           | Return per-field source citations (page + bbox) for each extracted value |
| `--no-wait`        | Fire-and-forget — queue the job and don't wait for processing            |

Global flags (`--json`, `--quiet`, `--output`) apply as well — see the [CLI Reference](/cli/reference).

<Tip>
  To browse a document's text, tables, and structure after extraction, use the grounded [`context`](/cli/reference) commands (`okra context structure`, `okra context tables`, `okra context get`) or read raw markdown with `okra read <docId>`.
</Tip>
