# Concepts

> Documents, schemas, extractions, results, field statuses and evidence.

## Objects

| Object | Id | What it is |
|---|---|---|
| Document | `doc_…` | An uploaded file, parsed into pages, sheets or sections. |
| Schema | `sch_…` | A saved JSON Schema with immutable versions. See [Schema authoring](/docs/schemas.md). |
| Template | `invoice`, `receipt`, … | A built-in schema. |
| Extraction | `job_…` | One run of a schema over a document. Asynchronous. |
| Webhook endpoint | `we_…` | A URL that receives signed events. |
| API key | `key_…` | Authenticates a program in one mode: `pf_live_…` or `pf_test_…`. |

Everything belongs to your account. Documents, extractions and webhook endpoints also
belong to one mode (test or live); schemas are shared by both. Documents and their
extractions are deleted 30 days after upload, or sooner on request (see
[Retention](/docs/limits.md#retention)).

## Extraction lifecycle

```text
pending → running → completed
                  → completed_with_unresolved   (review_required: true)
                  → failed
        → cancelled
```

While running, `stage` and `progress` show where the job is. `usage` and
`charge_usd` show the model usage and the amount charged once it finishes; test jobs
are always free.

## Results

`GET /v1/extractions/{job_id}/result`:

```json
{
  "object": "extraction_result",
  "job_id": "job_ff48e2ee7a2e",
  "mode": "live",
  "status": "completed_with_unresolved",
  "review_required": true,
  "data": {
    "invoice_number": "INV-1042",
    "total": 1280.5,
    "items": [{ "description": "Consulting", "amount": 1280.5 }]
  },
  "fields": {
    "/invoice_number": {
      "status": "verified",
      "verification": "SUPPORTED",
      "value": "INV-1042",
      "raw_value": "INV-1042",
      "sources": [
        {
          "unit_id": "page_000001",
          "locator": { "page_number": 1 },
          "quote": "Invoice no. INV-1042",
          "bounding_box": null
        }
      ]
    },
    "/due_date": {
      "status": "unresolved",
      "value": null,
      "unresolved_reason": "Two different due dates are printed.",
      "sources": []
    }
  },
  "unresolved_fields": ["/due_date"],
  "schema_valid": true,
  "schema_errors": [],
  "usage": { "llm_calls": 6, "estimated_cost_usd": 0.0041 }
}
```

- **`data`** follows your schema. Fields without a value are `null`. A field that
  needs review keeps its best candidate value in `data` (the same as
  `fields[pointer].value`), so check `unresolved_fields` before you trust a value.
- **`fields`** has one entry per extracted value, keyed by
  [JSON Pointer](https://www.rfc-editor.org/rfc/rfc6901): `/total`,
  `/items/0/amount`.
- **`unresolved_fields`** lists every field with status `unresolved`: the pointers that
  need a person.
- **`review_required`** is true when the job finished as `completed_with_unresolved`:
  some fields are unresolved, or `data` does not pass your schema.
- **`schema_valid`** and `schema_errors` tell you whether `data` passes your schema
  (for example, a `required` field that could not be found).

Add `?include=attempts,checks` to see every extraction attempt and verification check
behind each field, which helps when tuning a schema.

## Field statuses

| `status` | Console label | Meaning |
|---|---|---|
| `verified` | Verified | The value was confirmed against its source. A nullable field confirmed absent is `verified` with value `null`. |
| `unresolved` | Needs review | The value could not be confirmed, candidates disagreed, or a required field was not found; see `unresolved_reason`. `value` holds the best candidate or `null`. |
| `unverified` | Needs review | The value was extracted without a verification step. Live and test results normally do not contain it. |

Use verified values directly and send `unresolved` fields to review. If you ever see
`unverified`, treat it like `unresolved`.

## Evidence

Each entry in `sources` shows where a value came from:

| Field | Meaning |
|---|---|
| `unit_id` | The page, sheet range or section that was read. |
| `locator` | Where in the document: `page_number` for PDFs and images; `sheet_name` and `cell` or `cell_range` for spreadsheets. |
| `quote` | The text the value was read from. |
| `raw_value` | The value as printed, before normalization (for example `$1,280.50`). |
| `bounding_box` | The region on the page, when known. |
| `text_span` | Character offsets in the unit's text, when known. |

`value` is the normalized value that goes into `data`; `normalization_method` says how
it was converted from `raw_value`.

## Metadata

Extractions accept `metadata`: up to 20 string keys (40 characters) and values (500
characters). Use it for your own ids. It is returned with the job, in lists
(`GET /v1/extractions`) and in webhooks. In test mode, `metadata.test_outcome` picks a
[simulated outcome](/docs/test-mode.md).

## Lists and pagination

List endpoints (`/v1/extractions`, `/v1/documents`, `/v1/schemas`, `/v1/webhooks`)
return:

```json
{ "object": "list", "data": [], "has_more": true, "next_cursor": "eyJ…" }
```

Pass `limit` (up to 100) and `cursor=<next_cursor>` for the next page. Extractions
can be filtered by `status`, `schema_id`, `schema_version`, `template_id`,
`document_id`, `created_after` and `created_before`.
