## Create Extract Review

`$ llp extract:review create`

**post** `/api/v2/extract/{job_id}/review`

Beta: answers 403 until extract review is enabled for the caller and their organization.

Turn review on for an extract job.

Fields read below `confidence_threshold`, and required fields left empty, are
flagged for a person to check. Every setting has a default, so the body can be
left out. A job still running can be named: it waits for review once it
completes. A job that failed or was cancelled without a review, or that cannot
be reviewed, answers 409 with `code: job_not_reviewable`; a field in
`fields_in_scope` the job's schema does not have answers 400.

Answers 201 with the new review, or 200 with the job's existing review, whose
settings stay as they are.

### Parameters

- `--job-id: string`

  Path param

- `--organization-id: optional string`

  Query param

- `--project-id: optional string`

  Query param

- `--confidence-threshold: optional number`

  Body param: Fields read below this confidence are flagged.

- `--fields-in-scope: optional array of string`

  Body param: JSON Pointers of the fields the threshold applies to; empty means all.

- `--required-field: optional array of string`

  Body param: JSON Pointers of fields flagged when empty; defaults to the schema's required.

### Returns

- `extract_review: object { id, confidence_threshold, created_at, 16 more }`

  An extract job's review: its settings, flags, field actions and decision,
  with the result as read and as reviewed.

  - `id: string`

    Unique identifier of the review.

  - `confidence_threshold: number`

    Fields read below this confidence are flagged.

  - `created_at: string`

    When review was turned on.

  - `decided_at: string`

    When it was approved or rejected.

  - `decided_by: string`

    ID of the user who approved or rejected it.

  - `decided_reason: string`

    Why it was rejected.

  - `field_actions: map[object { action, actor_id, at, value } ]`

    The latest action per field, keyed by JSON Pointer.

    - `action: "clear" or "confirm" or "correct"`

      confirm, correct or clear.

      - `"clear"`

      - `"confirm"`

      - `"correct"`

    - `actor_id: string`

      ID of the user who acted.

    - `at: string`

      When they acted.

    - `value: optional unknown`

      The corrected value, for `correct`.

  - `fields_in_scope: array of string`

    JSON Pointers of the fields the threshold applies to; empty means all.

  - `flags: array of object { handled, path, reason, 2 more }`

    Fields the review asks a person to check.

    - `handled: boolean`

      Whether someone confirmed, corrected or cleared it.

    - `path: string`

      JSON Pointer of the field.

    - `reason: "below_threshold" or "required_empty"`

      below_threshold, or required_empty for a required field left empty.

      - `"below_threshold"`

      - `"required_empty"`

    - `cell: optional object { row, column }`

      Where in a list the least confident value is.

      - `row: number`

        Index of the row, from 0.

      - `column: optional string`

        Property of the row, when rows are objects.

    - `confidence: optional number`

      The field's confidence; for a list, its least confident value.

  - `job_id: string`

    The extract job reviewed.

  - `open_flags: array of string`

    JSON Pointers of flagged fields nobody checked.

  - `original_result: map[unknown]`

    The result as the model read it.

  - `required_fields: array of string`

    JSON Pointers of fields flagged when empty.

  - `retain_until: string`

    When the job and its document may be deleted.

  - `reviewed_result: map[unknown]`

    The result with the field actions.

  - `revision: number`

    Bumped by every change; actions name the one they saw.

  - `source_file_id: string`

    The file the job read, or the file behind the parse job it read; null for a URL.

  - `status: "approved" or "pending" or "rejected"`

    pending until approved or rejected.

    - `"approved"`

    - `"pending"`

    - `"rejected"`

  - `updated_at: string`

    When the review last changed.

### Example

```cli
llp extract:review create \
  --api-key 'My API Key' \
  --job-id job_id
```

#### Response

```json
{
  "id": "id",
  "confidence_threshold": 0,
  "created_at": "2019-12-27T18:11:19.117Z",
  "decided_at": "2019-12-27T18:11:19.117Z",
  "decided_by": "decided_by",
  "decided_reason": "decided_reason",
  "field_actions": {
    "foo": {
      "action": "clear",
      "actor_id": "actor_id",
      "at": "2019-12-27T18:11:19.117Z",
      "value": {}
    }
  },
  "fields_in_scope": [
    "string"
  ],
  "flags": [
    {
      "handled": true,
      "path": "path",
      "reason": "below_threshold",
      "cell": {
        "row": 0,
        "column": "column"
      },
      "confidence": 0
    }
  ],
  "job_id": "job_id",
  "open_flags": [
    "string"
  ],
  "original_result": {
    "foo": "bar"
  },
  "required_fields": [
    "string"
  ],
  "retain_until": "2019-12-27T18:11:19.117Z",
  "reviewed_result": {
    "foo": "bar"
  },
  "revision": 0,
  "source_file_id": "source_file_id",
  "status": "approved",
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```
