{
  "openapi": "3.1.0",
  "info": {
    "title": "Exhibit API",
    "version": "1.0.0",
    "description": "Exhibit answers your PDF's questions in **seconds**, showing where each answer came from.\n\n## Quickstart\n\nMake an API key: sign in at `/account`, then open Developers, then Keys. Then ask the sample document a question:\n\n```bash\ncurl -sO https://askexhibit.com/sample.pdf\ncurl https://askexhibit.com/v1/extract \\\n  -H \"Authorization: Bearer $EXHIBIT_API_KEY\" \\\n  -F pdf=@sample.pdf \\\n  -F 'questions=[\"How many days did training the big model take?\"]'\n```\n\nEvery answer comes back with where it was read:\n\n```json\n{\n  \"run\": \"5f0c9e…\",\n  \"answers\": [\n    {\n      \"question\": \"How many days did training the big model take?\",\n      \"found\": true,\n      \"answer\": \"3.5 days\",\n      \"page\": 6,\n      \"evidence\": \"The big models were trained for 300,000 steps (3.5 days).\",\n      \"evidence_url\": \"https://askexhibit.com/v1/runs/5f0c9e…/fields/0.jpg\"\n    }\n  ]\n}\n```\n\nMost code needs three fields of an answer: `found`, whether the document answers it; `answer`, as written (or `value`, for a typed question, below); and `evidence_url`, where it was read.\n\nOpen `evidence_url` to see that sentence where it is printed, on page 7 (`page` counts from 0). It needs no key, and lasts as long as its run is kept.\n\n![`evidence_url` for \"3.5 days\": the strip of page 7 the answer was read from, full width, so its heading is in view.](/docs-img/band.jpg)\n\n## TypeScript\n\n```bash\nnpm install @askexhibit/sdk\n```\n\n```ts\nimport { ExhibitClient, result } from \"@askexhibit/sdk\";\nimport { openAsBlob } from \"node:fs\";\n\nconst exhibit = new ExhibitClient({ token: process.env.EXHIBIT_API_KEY });\n\nconst { answers } = await result(exhibit.extract({\n  pdf: await openAsBlob(\"lease.pdf\"),\n  questions: [\n    \"Who is the landlord?\",\n    { text: \"What is the annual rent?\", type: \"money\" },\n  ],\n}));\n```\n\nA typed question's answer also has a `value` in that shape: for a `money` question, for example `{ \"amount\": 1200, \"currency\": \"GBP\" }`. To have each answer as it lands, iterate `await exhibit.extract(…)` instead of passing it to `result()`.\n\n## Questions\n\nA question is a string, or an object:\n\n- `text`: the question.\n- `type`: what the value is. `auto` (the default) leaves the answer as written. `number`, `count`, `quantity`, `duration`, `date`, `time`, `range`, `money`, `boolean`, `choice`, `multi`, `list`, `record`, `identifier`, `entity`, `presence` and `region` also give a `value`: numbers, whole numbers of things (never a percentage), numbers with their unit, lengths of time, ISO dates, times of day and date ranges, amounts with their currency, true or false, one or several of the `options`, a list of items, an identifier as printed, a name. See `AnswerType`.\n- `options`: the choices, for `choice` and `multi`; a `record`'s fields.\n- `fidelity: \"verbatim\"`: copy the answer off the page, never reason it.\n- `id`: your own key for the answer, on every question or none. It comes back as `field_id`.\n\nIf a question can't be answered from the document, `found` is `false`. Nothing is made up to fill the gap.\n\n## Evidence\n\nEach found answer has three links:\n\n- `evidence_url`: the strip of the page the answer is on.\n- `locator_url`: the whole page, with that strip outlined.\n- `region_url`: where it is, as coordinates from 0 to 1000.\n\nAdd `?highlight=true` to any of them to mark the answer itself with a box. Evidence is located the first time it is opened, then kept.\n\n![With `?highlight=true`: the answer boxed on its page. Here, the paper's title.](/docs-img/highlight.jpg)\n\n![`locator_url`: the whole page, the strip outlined, for where in a long document the answer is.](/docs-img/locator.jpg)\n\n## Forms\n\nAsking the same questions of many documents? Save them once as a form, with your own id for each field, and send `form=lease-review` instead of the questions. A form's versions never change, and each run records the version it used. `POST /v1/forms/import` drafts a form from a form PDF; `POST /v1/forms/suggest` drafts questions from an example document.\n\n## Streaming\n\nBy default the reply comes once the run ends. With `Accept: text/event-stream` each answer arrives as it is read, as server-sent events: `meta`, `answer`, `value`, `evidence` (the same answer found on other pages, after the answers), then `result` (or `error`). The SDK streams this way. Send `trace=true` to see the steps it took, and their timings, as well.\n\n## Without holding a connection\n\nSend `wait=false` and the reply is a 202 at once, naming the run: `{\"run\": \"5f0c9e…\", \"status\": \"running\"}`. Ask `GET /v1/runs/{run}` for it: `\"status\": \"running\"` while it is still going (wait the seconds `Retry-After` says), then `\"status\": \"done\"` with the answers, or `\"status\": \"failed\"` with the `error` and `code` a waiting request would have had. For queues, serverless functions, and documents that take a while.\n\nA request sent twice by a retry (a timeout on your side, say) need not run twice: send an `Idempotency-Key` header, a UUID of yours, and the same request with the same key within a day answers with the first request's run, read and billed once.\n\n## Without uploading\n\nA document online need not pass through you: send `pdf_url`, an https link Exhibit fetches it from (a storage bucket's signed URL, for one). With nothing to upload, the body can be JSON:\n\n```bash\ncurl https://askexhibit.com/v1/extract \\\n  -H \"Authorization: Bearer $EXHIBIT_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"pdf_url\": \"https://askexhibit.com/sample.pdf\", \"questions\": [\"How many days did training the big model take?\"]}'\n```\n\n## Errors, limits and billing\n\n- An error is `{\"error\": \"…\", \"code\": \"…\"}`. Show the `error` to people; branch on the `code` in your code. See `Error` for the codes.\n- A document is at most 64 MB and 1,000 pages. A request asks at most 192 questions.\n- A 503 (`unavailable`) is Exhibit not reached at all: nothing was read or billed. Send it again, after its `Retry-After` when it has one. A 502 (`read_failed`) is a run that began and failed.\n- A 429 has `Retry-After`: the seconds until asking again will be let through (for `concurrency_limit`, a short wait for one of your documents being read to finish).\n- Some limits go by the address a request comes from, since there is no key to count against: evidence links, 60 in any 10 s; and requests with a key that is not one we know, 10 in any 10 s, past which that address's keyed requests are refused for the rest of the 10 s (429, `rate_limited`).\n- Each plan's limits, for the whole account a month and per key a minute:\n- Free: 200 pages and 1,000 questions a month; 12 documents read (extract, import, suggest) and 120 requests a minute per key; 1 read at a time per key, 2 per account.\n- Pay as you go: $0.01 a page and $0.002 a question; 100,000 pages and 1,000,000 questions a month; 30 documents read (extract, import, suggest) and 120 requests a minute per key; 4 read at a time per key, 16 per account. A spend limit of your own is set under Developers, then Usage.\n- Lists (`GET /v1/forms`, a form's runs) come a page at a time: pass a page's `next` as `after` for the one after it, until `next` is null.\n- You pay for what was read: the result's `billable` says how many pages and questions. The same questions asked again of the same document come back at once and cost nothing (`cached_from` names the earlier run, when it was your account's). Send `cache=false` to run it afresh.\n\n## Where it runs\n\nExhibit runs in US East (Ashburn, Virginia). Called from a server near it, such as one in AWS `us-east-1`, a round trip takes a few milliseconds; from Europe about a tenth of a second, from Asia about a quarter. A run's `timing` is Exhibit's own time, from your request arriving to its result, without your connection.\n\nA document your account sent before, or one of its forms holds, need not be uploaded again: send its SHA-256 as `pdf_sha256` instead of the file, and only on a 404 `pdf_not_kept` send the file itself. The SDK and the CLI do this for you.\n\n## Your documents\n\nExhibit reads documents with AI models run by third-party providers, so the documents you upload and the questions you ask are sent to them for processing. Their own data-retention terms apply, and Exhibit does not control them. Do not upload what you may not share with third parties.\n\nExhibit also keeps what you send: the PDF, each run's answers and evidence stay until you delete the form or the account. A delete leaves Exhibit's server within minutes and its nightly backups within 15 days."
  },
  "servers": [
    {
      "url": "https://askexhibit.com"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Extract",
      "description": "Answer questions from a PDF."
    },
    {
      "name": "Evidence",
      "description": "See where an answer came from. No key needed."
    },
    {
      "name": "Forms",
      "description": "Named, versioned sets of questions."
    },
    {
      "name": "Runs",
      "description": "Frozen runs, and their answers."
    },
    {
      "name": "Service",
      "description": "Health, and the sample document."
    }
  ],
  "paths": {
    "/v1/extract": {
      "post": {
        "operationId": "extract",
        "tags": [
          "Extract"
        ],
        "summary": "Answer questions from a PDF",
        "description": "Reads the document and answers every question. By default one JSON body when the run ends; with `Accept: text/event-stream`, each answer as it settles; with `wait=false`, a 202 at once naming the run, whose answers `GET /v1/runs/{run}` gives when it ends. Send `questions` or `form`, never both, and the document as one of `pdf` (a file part of multipart/form-data), `pdf_sha256` or `pdf_url`. Without a file to upload, the body may be JSON instead.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "The document. At most 64 MB and 1,000 pages. Send it, or `pdf_sha256` for one this account sent before, or `pdf_url` for one online."
                  },
                  "pdf_sha256": {
                    "type": "string",
                    "pattern": "^[0-9a-fA-F]{64}$",
                    "description": "In place of `pdf`: the SHA-256 of a document this account sent before, or one of its forms holds (the sample is everyone's), as 64 hex digits, so it is not uploaded again. A 404 `pdf_not_kept` when Exhibit no longer has it: send the file as `pdf`."
                  },
                  "pdf_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "In place of `pdf`: an https link Exhibit fetches the document from, such as a storage bucket's signed URL. It must open without signing in, from a public address."
                  },
                  "filename": {
                    "type": "string",
                    "description": "With `pdf_sha256` or `pdf_url`: the name the run records for the document. An upload's own filename is used otherwise."
                  },
                  "questions": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Question"
                    },
                    "minItems": 1,
                    "maxItems": 192,
                    "description": "The questions: strings, question objects, or both. At most 192. Sent as one part holding the JSON array.",
                    "examples": [
                      [
                        "What BLEU score does the big model reach on English-to-German?",
                        "How many days did training take?"
                      ]
                    ]
                  },
                  "form": {
                    "type": "string",
                    "description": "A saved form, `id` or `id@version`. A bare id runs the latest version, and the resolved `id@version` is what is recorded, for example `lease-review@3`."
                  },
                  "cache": {
                    "type": "boolean",
                    "default": true,
                    "description": "`false` runs the questions afresh even if they were asked of this document before (see \"Errors, limits and billing\")."
                  },
                  "trace": {
                    "type": "boolean",
                    "default": false,
                    "description": "`true` adds the steps the run took and how long each took: the `trace` events, and the result's `trace`."
                  },
                  "wait": {
                    "type": "boolean",
                    "default": true,
                    "description": "`false` answers at once with a 202 naming the run (`status: running`), rather than when it ends: for a queue, a serverless function, or anything that should not hold a connection open. Read the answers from `GET /v1/runs/{run}`. Over plain HTTP: the SDK's `extract` streams, and waits."
                  }
                }
              },
              "encoding": {
                "questions": {
                  "contentType": "application/json"
                }
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "pdf_sha256": {
                    "type": "string",
                    "pattern": "^[0-9a-fA-F]{64}$",
                    "description": "In place of `pdf`: the SHA-256 of a document this account sent before, or one of its forms holds (the sample is everyone's), as 64 hex digits, so it is not uploaded again. A 404 `pdf_not_kept` when Exhibit no longer has it: send the file as `pdf`."
                  },
                  "pdf_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "In place of `pdf`: an https link Exhibit fetches the document from, such as a storage bucket's signed URL. It must open without signing in, from a public address."
                  },
                  "filename": {
                    "type": "string",
                    "description": "With `pdf_sha256` or `pdf_url`: the name the run records for the document. An upload's own filename is used otherwise."
                  },
                  "questions": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Question"
                    },
                    "minItems": 1,
                    "maxItems": 192,
                    "description": "The questions: strings, question objects, or both. At most 192.",
                    "examples": [
                      [
                        "What BLEU score does the big model reach on English-to-German?",
                        "How many days did training take?"
                      ]
                    ]
                  },
                  "form": {
                    "type": "string",
                    "description": "A saved form, `id` or `id@version`. A bare id runs the latest version, and the resolved `id@version` is what is recorded, for example `lease-review@3`."
                  },
                  "cache": {
                    "type": "boolean",
                    "default": true,
                    "description": "`false` runs the questions afresh even if they were asked of this document before (see \"Errors, limits and billing\")."
                  },
                  "trace": {
                    "type": "boolean",
                    "default": false,
                    "description": "`true` adds the steps the run took and how long each took: the `trace` events, and the result's `trace`."
                  },
                  "wait": {
                    "type": "boolean",
                    "default": true,
                    "description": "`false` answers at once with a 202 naming the run (`status: running`), rather than when it ends: for a queue, a serverless function, or anything that should not hold a connection open. Read the answers from `GET /v1/runs/{run}`. Over plain HTTP: the SDK's `extract` streams, and waits."
                  }
                },
                "description": "The same request, for a document that need not be uploaded: named by `pdf_sha256` or `pdf_url`. A key not listed here is a 400."
              }
            }
          }
        },
        "x-fern-streaming": {
          "format": "sse"
        },
        "responses": {
          "200": {
            "description": "The run: as server-sent events with `Accept: text/event-stream`, else its `result` as one JSON body.",
            "headers": {
              "x-exhibit-run": {
                "description": "The run's id, as `run` in the result: its answers' evidence URLs hang off it.",
                "schema": {
                  "type": "string"
                }
              },
              "Server-Timing": {
                "description": "Where the request waited before this reply began, step by step, in milliseconds (for example `identify;dur=120, pdf;dur=300, ingest;dur=140`). `ingest` is also counted in `timing.total_ms`. For reading only: the steps and their names may change.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "text/event-stream": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractEvent"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractResult"
                }
              }
            }
          },
          "202": {
            "description": "With `wait=false`: the run started. Its answers come from `GET /v1/runs/{run}` when it ends.",
            "headers": {
              "x-exhibit-run": {
                "description": "The run.",
                "schema": {
                  "type": "string"
                }
              },
              "Location": {
                "description": "`/v1/runs/{run}`.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds until asking about it is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunRunning"
                }
              }
            }
          },
          "400": {
            "description": "Not a PDF, password-protected, no pages or more than 30, a question the contract refuses, more than one document, a part or key it does not take, or a `pdf_url` that could not be fetched.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`pdf_sha256` names a document Exhibit does not have (`pdf_not_kept`), or `form` one that does not exist (`unknown_form`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "An `Idempotency-Key` sent before with a different request (`idempotency_key_reused`), or one another request is claiming at this moment (`conflict`: send it again in a second).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "A PDF larger than 64 MB (`pdf_too_large`), or a JSON body over 4 MB (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over a rate, concurrency or monthly limit.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Without the stream: the run failed after it began (`read_failed`). With it, the same comes as an `error` event.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Exhibit cannot read documents just now (`unavailable`): try again later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Your own id for this request, a UUID for one. Sent again with the same request within a day (a retry after a timeout), the reply is the first request's, with `Idempotent-Replayed: true`: its `result` once it has ended (a 202 as `GET /v1/runs/{run}` gives it while it is still going), or, asked with `Accept: text/event-stream`, as the stream told it (its answers, then its `result`; the SDK waits out a 202 for it), and nothing is read or billed twice. A run that failed holds its key no longer: sent again, it runs again. The same key with a different request is a 409 (`idempotency_key_reused`)."
          }
        ]
      }
    },
    "/v1/forms": {
      "get": {
        "operationId": "listForms",
        "tags": [
          "Forms"
        ],
        "summary": "List forms",
        "description": "Every form, latest version only, by id. A page at a time: follow `next`.",
        "responses": {
          "200": {
            "description": "The forms.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "forms",
                    "next"
                  ],
                  "properties": {
                    "forms": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Form"
                      }
                    },
                    "samples": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      },
                      "description": "Each form's sample, by form id: its document's id, as `getFormSample` gives it in `ETag` (there in quotes, as `If-None-Match` takes it). A form with no sample has no entry here. A client that kept that sample need not ask for it again."
                    },
                    "next": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Send as `after` for the next page; null on the last."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A `limit` out of bounds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "At most this many, from 1 to 500.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "$ref": "#/components/parameters/after"
          }
        ]
      },
      "post": {
        "operationId": "saveForm",
        "tags": [
          "Forms"
        ],
        "summary": "Save a form",
        "description": "Creates a form, or saves the next version of one with this name. Saving exactly what the latest version holds returns it and writes nothing, so a retried save is safe.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormSave"
              },
              "example": {
                "name": "Lease review",
                "fields": [
                  {
                    "id": "landlord",
                    "text": "Who is the landlord?"
                  },
                  {
                    "id": "rent",
                    "text": "What is the annual rent?",
                    "type": "money"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The version saved, or the latest when nothing changed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Form"
                }
              }
            }
          },
          "400": {
            "description": "A name, id or question the contract refuses.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "`based_on` is no longer the latest version, or it is 0 and a form by this name already exists. Nothing was written.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/forms/import": {
      "post": {
        "operationId": "importForm",
        "tags": [
          "Forms"
        ],
        "summary": "Draft a form from a form PDF",
        "description": "Reads a form, fillable or flat, and proposes its fields, with the printed option lists of its tick boxes. Never saves: review the draft, then save it.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "pdf"
                ],
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "The form."
                  },
                  "name": {
                    "type": "string",
                    "description": "The draft's name. Defaults to the file's."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Draft"
                }
              }
            }
          },
          "400": {
            "description": "Not a PDF, a part it does not take, or nothing to ask was found. Carries `pages_read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Larger than 64 MB (`pdf_too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over a rate, concurrency or monthly limit.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Reading the document failed (`read_failed`). Try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/forms/suggest": {
      "post": {
        "operationId": "suggestForm",
        "tags": [
          "Forms"
        ],
        "summary": "Draft questions from an example document",
        "description": "Reads an example document and proposes the questions a form over documents like it would ask. Never saves.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "pdf"
                ],
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary",
                    "description": "An example document."
                  },
                  "name": {
                    "type": "string",
                    "description": "The draft's name. Without it, the example's file name."
                  },
                  "count": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 30,
                    "default": 8,
                    "description": "At most this many questions, 1 to 30: a larger number is read as 30, a smaller as 1."
                  },
                  "hint": {
                    "type": "string",
                    "maxLength": 2000,
                    "description": "What the form is for."
                  },
                  "asked": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 2000
                    },
                    "maxItems": 192,
                    "description": "The questions the form already asks, one a part or a JSON array of them in one: none is proposed again, in these words or others."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Draft"
                }
              }
            }
          },
          "400": {
            "description": "Not a PDF, a `count` that is not a whole number or `hint`, a part it does not take, or nothing found. Carries `pages_read`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Larger than 64 MB (`pdf_too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over a rate, concurrency or monthly limit.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Reading the document failed (`read_failed`). Try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/forms/{form}": {
      "get": {
        "operationId": "getForm",
        "tags": [
          "Forms"
        ],
        "summary": "Get a form",
        "description": "The latest version, or the one named.",
        "responses": {
          "200": {
            "description": "The form.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Form"
                }
              }
            }
          },
          "400": {
            "description": "A version that is not a whole number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such form or version.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/formRef"
          }
        ]
      },
      "delete": {
        "operationId": "deleteForm",
        "tags": [
          "Forms"
        ],
        "summary": "Delete a form",
        "description": "Deletes the form whole: every version, its sample document, every run of it (and with them the evidence URLs they handed out), and the uploaded PDFs only those runs used. A PDF another run still names is kept. What was used and billed stays on the account's usage and invoice, no longer naming the run. A run of the form that is still going is a 409: delete the form when it ends. Name the form by its id alone: `id@version` is a 400.",
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted",
                    "runs",
                    "documents"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "string",
                      "description": "The id of the form deleted."
                    },
                    "runs": {
                      "type": "array",
                      "description": "The ids of the runs deleted with it. Their evidence URLs now answer 404.",
                      "items": {
                        "type": "string"
                      }
                    },
                    "documents": {
                      "type": "integer",
                      "description": "How many uploaded PDFs were deleted with them. A PDF a run was just using is removed within hours, not counted here."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A version was named.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such form (`unknown_form`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "A run of the form is still going.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/formId"
          }
        ]
      }
    },
    "/v1/forms/{form}/history": {
      "parameters": [
        {
          "$ref": "#/components/parameters/formId"
        }
      ],
      "get": {
        "operationId": "formHistory",
        "tags": [
          "Forms"
        ],
        "summary": "List a form's versions",
        "description": "Every version, oldest first.",
        "responses": {
          "200": {
            "description": "The versions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "versions"
                  ],
                  "properties": {
                    "versions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Form"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A version was named (`form@2`): history is every version of a form, so send its id alone.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such form.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/forms/{form}/runs": {
      "parameters": [
        {
          "$ref": "#/components/parameters/formId"
        }
      ],
      "get": {
        "operationId": "listRuns",
        "tags": [
          "Runs"
        ],
        "summary": "List a form's runs",
        "description": "The form's runs, every version, newest first: a summary each, not the answers. A page at a time: follow `next`.",
        "responses": {
          "200": {
            "description": "The runs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "runs",
                    "next"
                  ],
                  "properties": {
                    "runs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RunSummary"
                      }
                    },
                    "next": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Send as `after` for the next page; null on the last."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A `limit` out of bounds, or an `after` that is not a `next` this list gave.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such form (`unknown_form`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "At most this many, from 1 to 200.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "$ref": "#/components/parameters/after"
          }
        ]
      }
    },
    "/v1/forms/{form}/sample": {
      "parameters": [
        {
          "$ref": "#/components/parameters/formId"
        }
      ],
      "get": {
        "operationId": "getFormSample",
        "tags": [
          "Forms"
        ],
        "summary": "Get a form's sample document",
        "description": "The document the form was written against. Sent with an `ETag` and `Cache-Control: private, no-cache`: a client that keeps it sends `If-None-Match` and is answered 304 while it is unchanged.",
        "responses": {
          "200": {
            "description": "The PDF.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "ETag": {
                "description": "The document's own tag: unchanged while the document is.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "304": {
            "description": "Unchanged since the `If-None-Match` tag: the copy kept stands."
          },
          "400": {
            "description": "`id@version`: a sample belongs to the form, not to one version.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "The form has no sample.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putFormSample",
        "tags": [
          "Forms"
        ],
        "summary": "Keep a sample document with a form",
        "description": "Replaces any sample the form had. Every version shares it.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "pdf"
                ],
                "properties": {
                  "pdf": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kept.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "bytes"
                  ],
                  "properties": {
                    "bytes": {
                      "type": "integer",
                      "description": "The size kept."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not a PDF Exhibit can read (`pdf_unreadable`, `pdf_encrypted`, `pdf_no_pages`, `pdf_too_many_pages`), or no `pdf` part.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such form.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Larger than 64 MB (`pdf_too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/runs/{run}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/run"
        }
      ],
      "get": {
        "operationId": "getRun",
        "tags": [
          "Runs"
        ],
        "summary": "Get a run",
        "description": "Where a run stands, told by `status`: `running` (ask again after `Retry-After` seconds), `done` with every answer as it was given, or `failed` with the error an extract that waited would have had. For a run started with `wait=false`, this is how its answers arrive.",
        "responses": {
          "200": {
            "description": "The run: `running`, `done` with its answers, or `failed` with why.",
            "headers": {
              "Retry-After": {
                "description": "While `running`: seconds until asking again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Run"
                    },
                    {
                      "$ref": "#/components/schemas/RunRunning"
                    },
                    {
                      "$ref": "#/components/schemas/RunFailed"
                    }
                  ],
                  "discriminator": {
                    "propertyName": "status"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No run with this id in this account (`unknown_run`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/runs/{run}/fields/{field}.jpg": {
      "parameters": [
        {
          "$ref": "#/components/parameters/run"
        },
        {
          "$ref": "#/components/parameters/field"
        },
        {
          "$ref": "#/components/parameters/highlight"
        }
      ],
      "get": {
        "operationId": "getBand",
        "tags": [
          "Evidence"
        ],
        "summary": "The evidence band",
        "security": [],
        "description": "The strip of the page the answer sits in, full width, cut from a 2800 px render. Locates the answer on first access in the requested mode, then renders locally. Cached `private, immutable` for a year, by the browser that asked and never a shared cache: a run never changes, and a deleted one's crops do not outlive it on the way. A 404 `no_region` means the page could not be located for this answer; the answer itself still stands.",
        "responses": {
          "200": {
            "description": "The band.",
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "A bad `highlight`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`no_region` (the answer stands), an answer that was not found (`no_evidence`), an unknown run or field (`unknown_run`, `unknown_field`), a run still going (`run_in_progress`), a run that failed (`run_failed`), or a document no longer stored (`document_gone`: upload it again).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "With `run_in_progress`: the seconds until asking again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "429": {
            "description": "Too many evidence links from this address at once (`rate_limited`): they need no key, so they are paced by address.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Locating the answer failed (`read_failed`). Try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/runs/{run}/fields/{field}/locator.jpg": {
      "parameters": [
        {
          "$ref": "#/components/parameters/run"
        },
        {
          "$ref": "#/components/parameters/field"
        },
        {
          "$ref": "#/components/parameters/highlight"
        }
      ],
      "get": {
        "operationId": "getLocator",
        "tags": [
          "Evidence"
        ],
        "summary": "The page, with the answer outlined",
        "security": [],
        "description": "The whole page, 840 px wide, with the band outlined: where in the document the answer is. Locates the answer on first access in the requested mode, then renders locally. Cached `private, immutable` for a year, by the browser that asked and never a shared cache: a run never changes, and a deleted one's crops do not outlive it on the way. A 404 `no_region` means the page could not be located for this answer; the answer itself still stands.",
        "responses": {
          "200": {
            "description": "The page.",
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "A bad `highlight`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`no_region` (the answer stands), an answer that was not found (`no_evidence`), an unknown run or field (`unknown_run`, `unknown_field`), a run still going (`run_in_progress`), a run that failed (`run_failed`), or a document no longer stored (`document_gone`: upload it again).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "With `run_in_progress`: the seconds until asking again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "429": {
            "description": "Too many evidence links from this address at once (`rate_limited`): they need no key, so they are paced by address.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Locating the answer failed (`read_failed`). Try again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/runs/{run}/fields/{field}/region.json": {
      "parameters": [
        {
          "$ref": "#/components/parameters/run"
        },
        {
          "$ref": "#/components/parameters/field"
        },
        {
          "$ref": "#/components/parameters/highlight"
        }
      ],
      "get": {
        "operationId": "getRegion",
        "tags": [
          "Evidence"
        ],
        "summary": "Where the answer is, as coordinates",
        "security": [],
        "description": "The located region in normalized coordinates, and the trace of how it was found. For drawing your own overlay, redacting, or cropping at your own resolution. Locates the answer on first access in the requested mode. A 404 `no_region` means the page could not be located for this answer; the answer itself still stands.",
        "responses": {
          "200": {
            "description": "The region.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Region"
                }
              }
            }
          },
          "400": {
            "description": "A bad `highlight`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`no_region` (the answer stands), an answer that was not found (`no_evidence`), an unknown run or field (`unknown_run`, `unknown_field`), a run still going (`run_in_progress`), a run that failed (`run_failed`), or a document no longer stored (`document_gone`: upload it again). A failed attempt also carries its `trace`.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "trace": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/TraceEntry"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "With `run_in_progress`: the seconds until asking again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "429": {
            "description": "Too many evidence links from this address at once (`rate_limited`): they need no key, so they are paced by address.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Locating the answer failed (`read_failed`). Try again. Its body also carries the attempt's `trace`, as the 404's does.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/healthz": {
      "get": {
        "operationId": "health",
        "tags": [
          "Service"
        ],
        "summary": "Is it up",
        "description": "Answers without a key, for uptime checks.",
        "security": [],
        "responses": {
          "200": {
            "description": "Up.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sample.pdf": {
      "get": {
        "operationId": "samplePdf",
        "tags": [
          "Service"
        ],
        "summary": "The sample document",
        "security": [],
        "description": "\"Attention Is All You Need\", the document behind the `research-paper` form every account starts with.",
        "responses": {
          "200": {
            "description": "The PDF.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        }
      }
    },
    "/v1/runs/{run}/fields/{field}/review": {
      "parameters": [
        {
          "$ref": "#/components/parameters/run"
        },
        {
          "$ref": "#/components/parameters/field"
        }
      ],
      "post": {
        "operationId": "reviewAnswer",
        "tags": [
          "Runs"
        ],
        "summary": "Mark an answer right, or wrong with the right one",
        "description": "A person's mark on one answer of a run of a saved form. The form keeps it as a case of the field: the form's next documents are read with its latest lessons (where the answer is, its format, the look-alike that is not it), never with this document's values, and the field's track record counts it. Marking the same answer again replaces the first mark. A run of bare questions has no form to learn: a 400.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "verdict"
                ],
                "additionalProperties": false,
                "properties": {
                  "verdict": {
                    "type": "string",
                    "enum": [
                      "right",
                      "wrong"
                    ]
                  },
                  "answer": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "With `wrong` only, and then required: the right answer, or null when the document does not answer the question."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kept.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "field",
                    "record"
                  ],
                  "properties": {
                    "field": {
                      "type": "string",
                      "description": "The form's field id."
                    },
                    "record": {
                      "$ref": "#/components/schemas/Record"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A body of another shape, or a run of bare questions (no form to learn).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "An unknown run or field (`unknown_run`, `unknown_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/forms/{form}/record": {
      "parameters": [
        {
          "$ref": "#/components/parameters/formId"
        }
      ],
      "get": {
        "operationId": "formRecord",
        "tags": [
          "Forms"
        ],
        "summary": "Each field's track record",
        "description": "How many answers of each field people marked right and wrong, over every version of the form (a field keeps its id when the form is saved again).",
        "responses": {
          "200": {
            "description": "The records.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "form",
                    "fields"
                  ],
                  "properties": {
                    "form": {
                      "type": "string"
                    },
                    "fields": {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/Record"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or one that is unknown or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such form (`unknown_form`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Over the key's rate (`rate_limited`).",
            "headers": {
              "Retry-After": {
                "description": "Seconds until trying again is worth it.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key, `exh_…`."
      }
    },
    "parameters": {
      "formRef": {
        "name": "form",
        "in": "path",
        "required": true,
        "description": "A form id, or `id@version`.",
        "schema": {
          "type": "string"
        },
        "example": "lease-review@3"
      },
      "formId": {
        "name": "form",
        "in": "path",
        "required": true,
        "description": "A form id. `id@version` is a 400 here.",
        "schema": {
          "type": "string"
        },
        "example": "lease-review"
      },
      "field": {
        "name": "field",
        "in": "path",
        "required": true,
        "description": "The answer's `field_id` when it has one (a form's field, or a question sent with its own `id`), its index otherwise.",
        "schema": {
          "type": "string"
        }
      },
      "highlight": {
        "name": "highlight",
        "in": "query",
        "required": false,
        "description": "Draw the amber box on the answer, not only the band. `1` and `0` work too; anything else is a 400.",
        "schema": {
          "type": "boolean",
          "default": false
        }
      },
      "run": {
        "name": "run",
        "in": "path",
        "required": true,
        "description": "The run id from an extract.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9a-f]{32}$"
        }
      },
      "after": {
        "name": "after",
        "in": "query",
        "required": false,
        "description": "The `next` of the page before, for the page after it.",
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "What went wrong, in words, for people."
          },
          "code": {
            "type": "string",
            "description": "What went wrong, for code to branch on: stable where the words are not (see `Error`).",
            "examples": [
              "pdf_too_many_pages"
            ]
          },
          "pages_read": {
            "type": "integer",
            "description": "On a draft that found nothing: the pages still read, and metered."
          }
        },
        "description": "Every error. `code` is one per status (`bad_request`, `unauthorized`, `forbidden`, `not_found`, `method_not_allowed`, `conflict`, `too_large`, `rate_limited`, `read_failed`, `unavailable`, `internal`), or one of: `pdf_unreadable`, `pdf_encrypted`, `pdf_no_pages`, `pdf_too_many_pages`, `pdf_too_large`, `too_many_questions`, `unknown_form`, `unknown_run`, `unknown_field`, `run_in_progress` (an evidence link of a run still going: ask again shortly), `run_failed` (an evidence link of a run that failed: `GET /v1/runs/{run}` says why), `idempotency_key_reused`, `no_region` (the answer stands), `no_evidence`, `document_gone` (upload it again), `pdf_not_kept` (send the file itself), `monthly_limit` and `concurrency_limit`."
      },
      "AnswerType": {
        "type": "string",
        "enum": [
          "auto",
          "number",
          "count",
          "quantity",
          "duration",
          "date",
          "time",
          "range",
          "money",
          "boolean",
          "choice",
          "multi",
          "list",
          "record",
          "identifier",
          "entity",
          "presence",
          "region"
        ],
        "default": "auto",
        "description": "What the value is. `auto` (default) means no contract. `count` is a whole number of things: a share, a fraction or a sign is no count. `quantity` is a number with its unit (`{\"amount\": 3.5, \"unit\": \"days\"}`); a bare number is none. `duration` is a length of time with its unit, and in seconds when the unit fixes one (`{\"amount\": 3.5, \"unit\": \"days\", \"seconds\": 302400}`; a month's or a year's `seconds` is null). `time` is a time of day, `HH:MM` or `HH:MM:SS`, 24-hour. `range` is from one date to another (`{\"from\": \"2024-03-01\", \"to\": \"2024-06-30\"}`). `multi` is several of the `options`, as a list. `list` is the items the answer lists, as printed, when it marks them as a list (a JSON list, marked lines, or items set apart by semicolons). `identifier` is the answer exactly as read, copied off the page, never normalised. `entity` is a person, an organisation or an address, as named. `record` is rows of the fields its `options` name (a table's line items), each value as printed, when the answer gives them as rows. `presence` is whether the document holds an answer at all: `true`, or `false` (not present is an answer, not a failure). `region` is where on its page the answer is: its `region_url`."
      },
      "Fidelity": {
        "type": "string",
        "enum": [
          "auto",
          "verbatim"
        ],
        "default": "auto",
        "description": "`auto` (default) or `verbatim`: copy the answer off the page, never reason it."
      },
      "Classify": {
        "type": "string",
        "enum": [
          "skipped",
          "pending",
          "ok",
          "unsure",
          "failed"
        ],
        "description": "How the typed-value pass went. `skipped`: no type, or nothing found. `pending`: on an `answer` event, the value is still to come, in a `value` event. `ok`: a value came: on the `answer` event itself when the answer already is its value (a bare number, date or amount, or a number with only its currency sign, code or word, or its ordinal suffix), else in its `value` event. A yes/no or choice value always comes in its `value` event, read from the answer's page. `unsure`: a yes/no or choice value came, but its reading of the page is not sure: check it there before relying on it. `failed`: declined or errored; the answer stands."
      },
      "Check": {
        "type": "object",
        "required": [
          "verdict"
        ],
        "properties": {
          "verdict": {
            "type": "string",
            "enum": [
              "trusted",
              "doubted",
              "unchecked"
            ],
            "description": "Exhibit's own review of the answer. `trusted`: the review is confident enough for the answer's type. `doubted`: it is not; or a \"not found\" that the page scores doubt (open `searched.nearest`); or, on a run of a saved form, a person marked this question's last answer wrong. A doubted answer is served as it was first given: look at the evidence before relying on it. `unchecked`: no review was made (a \"not found\" the page scores agree with or did not score, or a review that could not be made)."
          },
          "confidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Exhibit's measured probability that this answer is right, from graded answers of the same kind; absent when not reviewed."
          }
        },
        "description": "Exhibit's own review of this answer as it went out. A doubted answer is never served as sure: it says so here."
      },
      "QuestionSpec": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Yours, on every question or none: answers carry it as `field_id`, and their evidence is addressed by it. Letters and digits in any script, `_`, `-` and `.`, not starting with `.`, at most 64."
          },
          "text": {
            "type": "string",
            "maxLength": 2000,
            "description": "The question. Not blank, at most 2000 characters."
          },
          "type": {
            "$ref": "#/components/schemas/AnswerType"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 500
            },
            "maxItems": 254,
            "description": "The choices, for `type: choice` only."
          },
          "fidelity": {
            "$ref": "#/components/schemas/Fidelity"
          }
        },
        "description": "A question with a contract. Any other key is a 400: a typo would otherwise be a constraint that silently is not one."
      },
      "Question": {
        "description": "A bare string, or a question with a contract.",
        "oneOf": [
          {
            "type": "string"
          },
          {
            "$ref": "#/components/schemas/QuestionSpec"
          }
        ]
      },
      "FormField": {
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionSpec"
          },
          {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "Yours: the join key into your UI. Checked as a question's `id` is."
              }
            }
          }
        ]
      },
      "Form": {
        "type": "object",
        "required": [
          "id",
          "name",
          "version",
          "fields"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The name's slug: its letters and digits in any script, lowercased and without accents, joined by dashes (`Qualité mensuelle` is `qualite-mensuelle`). A form saved when slugs were A to Z alone keeps the id it was given."
          },
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormField"
            },
            "maxItems": 192
          }
        }
      },
      "FormSave": {
        "type": "object",
        "required": [
          "name",
          "fields"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "description": "At most 100 characters (about 65 in a script of three bytes a letter, such as Chinese or Japanese), with a letter or a digit. Its slug is the id."
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormField"
            },
            "maxItems": 192,
            "description": "A draft's fields (import, suggest) save as they come back: their `page` and `alternatives` are review hints, and a save leaves them out."
          },
          "based_on": {
            "type": "integer",
            "minimum": 0,
            "description": "The latest version your edit started from, 0 for a new form. If another save came first, 409."
          }
        }
      },
      "DraftField": {
        "allOf": [
          {
            "$ref": "#/components/schemas/FormField"
          },
          {
            "type": "object",
            "required": [
              "page"
            ],
            "properties": {
              "page": {
                "type": "integer",
                "description": "The page it was read from, 0-based. A review hint, not part of a form."
              },
              "alternatives": {
                "type": "integer",
                "description": "Boxes counted on a tick-box group whose options could not be read. The field comes back `auto`: type the options in."
              }
            }
          }
        ]
      },
      "Draft": {
        "type": "object",
        "required": [
          "name",
          "fields"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DraftField"
            }
          },
          "pages_read": {
            "type": "integer",
            "description": "The pages read, which is what the call is metered by."
          }
        },
        "description": "Proposed, never saved."
      },
      "Money": {
        "type": "object",
        "required": [
          "amount",
          "currency"
        ],
        "properties": {
          "amount": {
            "type": "number"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 4217, or null when the page never said."
          }
        }
      },
      "Quantity": {
        "type": "object",
        "required": [
          "amount",
          "unit"
        ],
        "properties": {
          "amount": {
            "type": "number"
          },
          "unit": {
            "type": "string",
            "description": "The unit as printed, or `%`."
          }
        },
        "description": "A `quantity` question's value: a number with its unit."
      },
      "Duration": {
        "type": "object",
        "required": [
          "amount",
          "unit",
          "seconds"
        ],
        "properties": {
          "amount": {
            "type": "number"
          },
          "unit": {
            "type": "string"
          },
          "seconds": {
            "type": [
              "number",
              "null"
            ],
            "description": "Its length in seconds; null for months and years, whose length the unit does not fix."
          }
        },
        "description": "A `duration` question's value."
      },
      "DateRange": {
        "type": "object",
        "required": [
          "from",
          "to"
        ],
        "properties": {
          "from": {
            "type": "string",
            "format": "date"
          },
          "to": {
            "type": "string",
            "format": "date"
          }
        },
        "description": "A `range` question's value: from one date to another, the first not after the second."
      },
      "Region": {
        "type": "object",
        "required": [
          "page",
          "evidence",
          "mode",
          "band",
          "box",
          "answer",
          "trace"
        ],
        "properties": {
          "page": {
            "type": "integer",
            "description": "The page the evidence is on, 0-based, in the document as it was uploaded: the same page as the answer's `page`."
          },
          "evidence": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "band",
              "hl"
            ],
            "description": "`band`, or `hl` with highlight on."
          },
          "band": {
            "type": "object",
            "required": [
              "y1",
              "y2"
            ],
            "properties": {
              "y1": {
                "type": "integer"
              },
              "y2": {
                "type": "integer"
              }
            },
            "description": "Where the answer sits, 0 (top) to 1000 (bottom), before the band is padded."
          },
          "box": {
            "description": "Where the answer is, 0 to 1000 on each edge, in `hl` mode only.",
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "x1",
                  "y1",
                  "x2",
                  "y2"
                ],
                "properties": {
                  "x1": {
                    "type": "integer"
                  },
                  "y1": {
                    "type": "integer"
                  },
                  "x2": {
                    "type": "integer"
                  },
                  "y2": {
                    "type": "integer"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "answer": {
            "type": [
              "string",
              "null"
            ],
            "description": "The extract's answer, unchanged."
          },
          "trace": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TraceEntry"
            }
          }
        }
      },
      "Value": {
        "description": "`answer` in the declared shape: a number, a count (a whole number), a quantity with its unit, a duration, a time of day (a string), an ISO date or date range, a boolean, a choice, several choices or a list's items (a list of strings), an identifier or a name (a string), money, a record's rows, presence (a boolean) or a region. Null when the pass declined.",
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "$ref": "#/components/schemas/Money"
          },
          {
            "$ref": "#/components/schemas/Quantity"
          },
          {
            "$ref": "#/components/schemas/DateRange"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/schemas/Region"
          },
          {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "A `record`'s rows."
          },
          {
            "$ref": "#/components/schemas/Duration"
          },
          {
            "type": "null"
          }
        ]
      },
      "Answer": {
        "type": "object",
        "required": [
          "index",
          "question",
          "found",
          "answer",
          "page",
          "evidence",
          "quoted",
          "evidence_url",
          "locator_url",
          "region_url",
          "type",
          "classify",
          "check"
        ],
        "properties": {
          "found": {
            "type": "boolean",
            "description": "Whether the document answers it. False means the answer is not printed on these pages: a claim about the document, never about a pass that failed."
          },
          "value": {
            "$ref": "#/components/schemas/Value"
          },
          "answer": {
            "type": [
              "string",
              "null"
            ],
            "description": "Whatever answers the question: a value, a list, a summary of a table. Exactly what was read, never rewritten."
          },
          "evidence_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The evidence band: a whole URL, at the address the API was called on. Null when not found."
          },
          "index": {
            "type": "integer",
            "description": "Its place in the request, 0-based. Answers keep request order."
          },
          "field_id": {
            "type": "string",
            "description": "The question's id: a form field's, or the one given on the question."
          },
          "question": {
            "type": "string"
          },
          "page": {
            "type": [
              "integer",
              "null"
            ],
            "description": "0-based."
          },
          "pages": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Every page the answer drew on, 0-based, `page` first: a table over a page break, the values of a computation or a comparison. Absent when it drew on `page` alone."
          },
          "evidence": {
            "type": [
              "string",
              "null"
            ],
            "description": "A quote of the page (label and answer), or a description when the evidence is not text."
          },
          "quoted": {
            "type": "boolean",
            "description": "Whether `evidence` is the page's own words."
          },
          "also": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "page",
                "evidence"
              ],
              "properties": {
                "page": {
                  "type": "integer",
                  "description": "0-based."
                },
                "evidence": {
                  "type": "string",
                  "description": "The words on that page, as printed."
                }
              }
            },
            "description": "The proof's other pieces: every other place the answer rests on, beyond `evidence` on `page` (a sum's parts, the two sides of a comparison, a table over a page break). Absent when `evidence` alone is the proof."
          },
          "because": {
            "type": "string",
            "description": "One sentence that joins the evidence to the answer, with the numbers of a calculation (`62,500 - 58,100 = 4,400`). Absent when the answer is the evidence's own words."
          },
          "elsewhere": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "page",
                "evidence"
              ],
              "properties": {
                "page": {
                  "type": "integer",
                  "description": "0-based."
                },
                "evidence": {
                  "type": "string",
                  "description": "The words on that page, as printed."
                }
              }
            },
            "description": "The same answer, read on other pages too: each page and its words there. It backs the answer up; it is not part of its proof (that is `also`). It comes after the answer, in an `evidence` event, once every reading of the document is in, and is on the result and the run. Absent when no other page gave the same answer."
          },
          "locator_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The page, with the answer outlined: a whole URL, at the address the API was called on. Null when not found."
          },
          "region_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the answer is, as coordinates: a whole URL, at the address the API was called on. Null when not found."
          },
          "searched": {
            "$ref": "#/components/schemas/Searched"
          },
          "scale": {
            "type": "string",
            "description": "The page's own statement of the scale of its figures, as printed (`(In millions, except per-share amounts)`), when the answer is a bare figure of 1,000 or more that does not carry it. Such an answer is served as doubted: read it under this scale. Absent otherwise."
          },
          "type": {
            "$ref": "#/components/schemas/AnswerType"
          },
          "fidelity": {
            "$ref": "#/components/schemas/Fidelity"
          },
          "classify": {
            "$ref": "#/components/schemas/Classify"
          },
          "check": {
            "$ref": "#/components/schemas/Check"
          },
          "ms": {
            "type": "integer",
            "description": "Wall time attributable to this answer. 0 when not found or not recorded."
          }
        },
        "description": "One question's answer. Most code needs three fields: `found` (whether the document answers it), `value` (the answer in the type asked, for a typed question) or `answer` (as written), and `evidence_url` (where it was read, to show a person). The rest is for audit and display."
      },
      "Searched": {
        "type": "object",
        "required": [
          "pages",
          "nearest"
        ],
        "properties": {
          "pages": {
            "type": "integer",
            "description": "The pages looked at for this question: every page of the document was scored for it."
          },
          "nearest": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "page",
                "score"
              ],
              "properties": {
                "page": {
                  "type": "integer",
                  "description": "0-based."
                },
                "score": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1,
                  "description": "How likely Exhibit judged this page to hold the answer."
                }
              }
            },
            "description": "The pages likeliest to hold the answer, likeliest first, at most 3: open them to check the absence."
          }
        },
        "description": "Proof of absence, on a \"not found\" only: what was looked at. Absent on a found answer, and when the run kept no page scores."
      },
      "Timing": {
        "type": "object",
        "required": [
          "render_ms",
          "analyze_ms",
          "overlap_ms",
          "total_ms"
        ],
        "properties": {
          "render_ms": {
            "type": "integer"
          },
          "analyze_ms": {
            "type": "integer"
          },
          "overlap_ms": {
            "type": "integer",
            "description": "Render and analyze run together, so they add up to more than `total_ms` by this much."
          },
          "first_answer_ms": {
            "type": [
              "integer",
              "null"
            ],
            "description": "When the first answer went out."
          },
          "total_ms": {
            "type": "integer"
          }
        }
      },
      "Billable": {
        "type": "object",
        "required": [
          "pages",
          "questions"
        ],
        "properties": {
          "pages": {
            "type": "integer"
          },
          "questions": {
            "type": "integer"
          }
        },
        "description": "What the run is billed by."
      },
      "TraceEntry": {
        "type": "object",
        "required": [
          "stage",
          "detail",
          "start_ms",
          "ms",
          "ok"
        ],
        "properties": {
          "stage": {
            "type": "string",
            "enum": [
              "ingest",
              "cache",
              "render",
              "analyze",
              "merge",
              "classify",
              "ground",
              "text"
            ]
          },
          "detail": {
            "type": "string"
          },
          "start_ms": {
            "type": "integer",
            "description": "From the start of the request. Steps run at the same time overlap."
          },
          "ms": {
            "type": "integer"
          },
          "ok": {
            "type": "boolean"
          }
        },
        "description": "One step of a run and how long it took."
      },
      "ExtractResult": {
        "type": "object",
        "required": [
          "doc",
          "run",
          "pages",
          "answers",
          "timing"
        ],
        "properties": {
          "doc": {
            "type": "string",
            "description": "The document's id in your account: the same file, sent again by your account, has the same id. Not its sha256 (`pdf_sha256` names it by that). The sample document's id is the same in every account."
          },
          "run": {
            "type": "string",
            "description": "This run, frozen."
          },
          "form": {
            "type": "string",
            "description": "`id@version`, when the run named a form."
          },
          "pages": {
            "type": "integer"
          },
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Answer"
            }
          },
          "billable": {
            "$ref": "#/components/schemas/Billable"
          },
          "timing": {
            "$ref": "#/components/schemas/Timing"
          },
          "trace": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TraceEntry"
            },
            "description": "Only with `trace=true`: each step the run took, and how long."
          },
          "cached_from": {
            "type": "string",
            "description": "When the answers came from an earlier run of the same questions (see \"Errors, limits and billing\"): that run's run. Only a run of your account's: the sample document's answers are shared by every account, and another account's run is not named."
          }
        }
      },
      "ValueEvent": {
        "type": "object",
        "required": [
          "index",
          "value",
          "classify"
        ],
        "properties": {
          "index": {
            "type": "integer"
          },
          "value": {
            "$ref": "#/components/schemas/Value"
          },
          "classify": {
            "$ref": "#/components/schemas/Classify"
          }
        }
      },
      "EvidenceEvent": {
        "type": "object",
        "required": [
          "index",
          "elsewhere"
        ],
        "properties": {
          "index": {
            "type": "integer"
          },
          "elsewhere": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "page",
                "evidence"
              ],
              "properties": {
                "page": {
                  "type": "integer",
                  "description": "0-based."
                },
                "evidence": {
                  "type": "string",
                  "description": "The words on that page, as printed."
                }
              }
            },
            "description": "As on the answer (`Answer.elsewhere`)."
          }
        },
        "description": "An answer's `elsewhere`, once every reading is in. Only for an answer that has one."
      },
      "StreamError": {
        "type": "object",
        "required": [
          "status",
          "code",
          "error"
        ],
        "properties": {
          "status": {
            "type": "integer",
            "description": "The status this would have had."
          },
          "code": {
            "type": "string",
            "description": "As on every other error (see `Error`)."
          },
          "error": {
            "type": "string"
          }
        }
      },
      "ExtractMeta": {
        "type": "object",
        "required": [
          "doc",
          "pages"
        ],
        "properties": {
          "doc": {
            "type": "string"
          },
          "pages": {
            "type": "integer"
          }
        },
        "description": "The document, before any of it is read."
      },
      "ExtractEvent": {
        "description": "One server-sent event. Its `event:` line names it, and its `data:` line is the JSON of the object named here. SDKs hand it over as one object: the event's name as `event`, beside the data's own fields.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/ExtractMeta"
          },
          {
            "$ref": "#/components/schemas/TraceEntry"
          },
          {
            "$ref": "#/components/schemas/Answer"
          },
          {
            "$ref": "#/components/schemas/ValueEvent"
          },
          {
            "$ref": "#/components/schemas/EvidenceEvent"
          },
          {
            "$ref": "#/components/schemas/ExtractResult"
          },
          {
            "$ref": "#/components/schemas/StreamError"
          }
        ],
        "discriminator": {
          "propertyName": "event",
          "mapping": {
            "meta": "#/components/schemas/ExtractMeta",
            "trace": "#/components/schemas/TraceEntry",
            "answer": "#/components/schemas/Answer",
            "value": "#/components/schemas/ValueEvent",
            "evidence": "#/components/schemas/EvidenceEvent",
            "result": "#/components/schemas/ExtractResult",
            "error": "#/components/schemas/StreamError"
          },
          "x-fern-discriminator-context": "protocol"
        }
      },
      "Run": {
        "type": "object",
        "required": [
          "run",
          "status",
          "doc",
          "pages",
          "created_ms",
          "answers",
          "total_ms",
          "billable"
        ],
        "properties": {
          "run": {
            "type": "string",
            "description": "The run. The same id its extract replied with."
          },
          "status": {
            "type": "string",
            "const": "done",
            "description": "The run ended with its answers."
          },
          "doc": {
            "type": "string"
          },
          "pages": {
            "type": "integer"
          },
          "form": {
            "type": "string",
            "description": "`id@version`."
          },
          "created_ms": {
            "type": "integer",
            "description": "Unix milliseconds."
          },
          "total_ms": {
            "type": "integer",
            "description": "How long the run took, in ms."
          },
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Answer"
            },
            "description": "Every answer, as the extract gave it."
          },
          "billable": {
            "$ref": "#/components/schemas/Billable"
          }
        },
        "description": "A run that ended with its answers, in the shape of the extract that made it: the same `answers`, with the same evidence URLs."
      },
      "RunSummary": {
        "type": "object",
        "required": [
          "run",
          "doc",
          "form",
          "created_ms",
          "pages",
          "asked",
          "answered",
          "total_ms"
        ],
        "properties": {
          "run": {
            "type": "string"
          },
          "doc": {
            "type": "string"
          },
          "form": {
            "type": "string",
            "description": "`id@version`."
          },
          "created_ms": {
            "type": "integer"
          },
          "pages": {
            "type": "integer"
          },
          "asked": {
            "type": "integer"
          },
          "answered": {
            "type": "integer"
          },
          "total_ms": {
            "type": "integer"
          }
        }
      },
      "RunRunning": {
        "type": "object",
        "required": [
          "run",
          "status"
        ],
        "properties": {
          "run": {
            "type": "string",
            "description": "The run."
          },
          "status": {
            "type": "string",
            "const": "running",
            "description": "Still going: ask again after `Retry-After` seconds."
          }
        },
        "description": "A run still going."
      },
      "RunFailed": {
        "type": "object",
        "required": [
          "run",
          "status",
          "error",
          "code"
        ],
        "properties": {
          "run": {
            "type": "string",
            "description": "The run."
          },
          "status": {
            "type": "string",
            "const": "failed"
          },
          "error": {
            "type": "string",
            "description": "What went wrong, in words, for people."
          },
          "code": {
            "type": "string",
            "description": "What went wrong, for code to branch on, as on `Error`: `read_failed`, for one."
          }
        },
        "description": "A run that ended without answers: what an extract that waited would have been told, as its error. Nothing is billed for it."
      },
      "Record": {
        "type": "object",
        "description": "A field's track record: how many of its answers a person marked right, and wrong.",
        "required": [
          "right",
          "wrong"
        ],
        "properties": {
          "right": {
            "type": "integer",
            "minimum": 0
          },
          "wrong": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    }
  }
}
