# Review

## Create Extract Review

`ExtractReview extract().review().create(ReviewCreateParamsparams = ReviewCreateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**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

- `ReviewCreateParams params`

  - `Optional<String> jobId`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

  - `Optional<Double> confidenceThreshold`

    Fields read below this confidence are flagged.

  - `Optional<List<String>> fieldsInScope`

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

  - `Optional<List<String>> requiredFields`

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

### Returns

- `class ExtractReview:`

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

  - `String id`

    Unique identifier of the review.

  - `double confidenceThreshold`

    Fields read below this confidence are flagged.

  - `LocalDateTime createdAt`

    When review was turned on.

  - `Optional<LocalDateTime> decidedAt`

    When it was approved or rejected.

  - `Optional<String> decidedBy`

    ID of the user who approved or rejected it.

  - `Optional<String> decidedReason`

    Why it was rejected.

  - `FieldActions fieldActions`

    The latest action per field, keyed by JSON Pointer.

    - `Action action`

      confirm, correct or clear.

      - `CLEAR("clear")`

      - `CONFIRM("confirm")`

      - `CORRECT("correct")`

    - `String actorId`

      ID of the user who acted.

    - `LocalDateTime at`

      When they acted.

    - `Optional<JsonValue> value`

      The corrected value, for `correct`.

  - `List<String> fieldsInScope`

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

  - `List<Flag> flags`

    Fields the review asks a person to check.

    - `boolean handled`

      Whether someone confirmed, corrected or cleared it.

    - `String path`

      JSON Pointer of the field.

    - `Reason reason`

      below_threshold, or required_empty for a required field left empty.

      - `BELOW_THRESHOLD("below_threshold")`

      - `REQUIRED_EMPTY("required_empty")`

    - `Optional<Cell> cell`

      Where in a list the least confident value is.

      - `long row`

        Index of the row, from 0.

      - `Optional<String> column`

        Property of the row, when rows are objects.

    - `Optional<Double> confidence`

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

  - `String jobId`

    The extract job reviewed.

  - `List<String> openFlags`

    JSON Pointers of flagged fields nobody checked.

  - `Optional<OriginalResult> originalResult`

    The result as the model read it.

  - `List<String> requiredFields`

    JSON Pointers of fields flagged when empty.

  - `LocalDateTime retainUntil`

    When the job and its document may be deleted.

  - `ReviewedResult reviewedResult`

    The result with the field actions.

  - `long revision`

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

  - `Optional<String> sourceFileId`

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

  - `Status status`

    pending until approved or rejected.

    - `APPROVED("approved")`

    - `PENDING("pending")`

    - `REJECTED("rejected")`

  - `LocalDateTime updatedAt`

    When the review last changed.

### Example

```java
package ai.llamaindex.llamacloud.example;

import ai.llamaindex.llamacloud.client.LlamaCloudClient;
import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient;
import ai.llamaindex.llamacloud.models.extract.review.ExtractReview;
import ai.llamaindex.llamacloud.models.extract.review.ReviewCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ExtractReview extractReview = client.extract().review().create("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"
}
```

## Get Extract Review

`ExtractReview extract().review().get(ReviewGetParamsparams = ReviewGetParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

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

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

Get an extract job's review: its flags, field actions and decision, with the
result as the model read it and as reviewed. A job without a review answers 404.

### Parameters

- `ReviewGetParams params`

  - `Optional<String> jobId`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

### Returns

- `class ExtractReview:`

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

  - `String id`

    Unique identifier of the review.

  - `double confidenceThreshold`

    Fields read below this confidence are flagged.

  - `LocalDateTime createdAt`

    When review was turned on.

  - `Optional<LocalDateTime> decidedAt`

    When it was approved or rejected.

  - `Optional<String> decidedBy`

    ID of the user who approved or rejected it.

  - `Optional<String> decidedReason`

    Why it was rejected.

  - `FieldActions fieldActions`

    The latest action per field, keyed by JSON Pointer.

    - `Action action`

      confirm, correct or clear.

      - `CLEAR("clear")`

      - `CONFIRM("confirm")`

      - `CORRECT("correct")`

    - `String actorId`

      ID of the user who acted.

    - `LocalDateTime at`

      When they acted.

    - `Optional<JsonValue> value`

      The corrected value, for `correct`.

  - `List<String> fieldsInScope`

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

  - `List<Flag> flags`

    Fields the review asks a person to check.

    - `boolean handled`

      Whether someone confirmed, corrected or cleared it.

    - `String path`

      JSON Pointer of the field.

    - `Reason reason`

      below_threshold, or required_empty for a required field left empty.

      - `BELOW_THRESHOLD("below_threshold")`

      - `REQUIRED_EMPTY("required_empty")`

    - `Optional<Cell> cell`

      Where in a list the least confident value is.

      - `long row`

        Index of the row, from 0.

      - `Optional<String> column`

        Property of the row, when rows are objects.

    - `Optional<Double> confidence`

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

  - `String jobId`

    The extract job reviewed.

  - `List<String> openFlags`

    JSON Pointers of flagged fields nobody checked.

  - `Optional<OriginalResult> originalResult`

    The result as the model read it.

  - `List<String> requiredFields`

    JSON Pointers of fields flagged when empty.

  - `LocalDateTime retainUntil`

    When the job and its document may be deleted.

  - `ReviewedResult reviewedResult`

    The result with the field actions.

  - `long revision`

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

  - `Optional<String> sourceFileId`

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

  - `Status status`

    pending until approved or rejected.

    - `APPROVED("approved")`

    - `PENDING("pending")`

    - `REJECTED("rejected")`

  - `LocalDateTime updatedAt`

    When the review last changed.

### Example

```java
package ai.llamaindex.llamacloud.example;

import ai.llamaindex.llamacloud.client.LlamaCloudClient;
import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient;
import ai.llamaindex.llamacloud.models.extract.review.ExtractReview;
import ai.llamaindex.llamacloud.models.extract.review.ReviewGetParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ExtractReview extractReview = client.extract().review().get("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"
}
```

## Change Extract Review Fields

`ExtractReview extract().review().changeFields(ReviewChangeFieldsParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

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

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

Confirm, correct, clear, restore or undo fields of a completed job.

The changes apply in order, in one write. A job without a review gets one with
the default settings, at revision 0. A path that is not a field of the job, or a
value the field's schema refuses, answers 400 and changes nothing.
A job that has not completed answers 409 with `code: job_not_reviewable`. A `revision` other than the review's latest answers 409 with `code: stale_revision` and the latest `revision`.

### Parameters

- `ReviewChangeFieldsParams params`

  - `Optional<String> jobId`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

  - `List<Change> changes`

    Changes to apply, in order.

    - `InnerChange change`

      confirm, correct to `value`, clear, restore the model's value, or undo.

      - `CLEAR("clear")`

      - `CONFIRM("confirm")`

      - `CORRECT("correct")`

      - `RESTORE("restore")`

      - `UNDO("undo")`

    - `String path`

      JSON Pointer of the field.

    - `Optional<JsonValue> value`

      The corrected value, for `correct`.

  - `long revision`

    The review's revision as the caller last read it.

### Returns

- `class ExtractReview:`

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

  - `String id`

    Unique identifier of the review.

  - `double confidenceThreshold`

    Fields read below this confidence are flagged.

  - `LocalDateTime createdAt`

    When review was turned on.

  - `Optional<LocalDateTime> decidedAt`

    When it was approved or rejected.

  - `Optional<String> decidedBy`

    ID of the user who approved or rejected it.

  - `Optional<String> decidedReason`

    Why it was rejected.

  - `FieldActions fieldActions`

    The latest action per field, keyed by JSON Pointer.

    - `Action action`

      confirm, correct or clear.

      - `CLEAR("clear")`

      - `CONFIRM("confirm")`

      - `CORRECT("correct")`

    - `String actorId`

      ID of the user who acted.

    - `LocalDateTime at`

      When they acted.

    - `Optional<JsonValue> value`

      The corrected value, for `correct`.

  - `List<String> fieldsInScope`

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

  - `List<Flag> flags`

    Fields the review asks a person to check.

    - `boolean handled`

      Whether someone confirmed, corrected or cleared it.

    - `String path`

      JSON Pointer of the field.

    - `Reason reason`

      below_threshold, or required_empty for a required field left empty.

      - `BELOW_THRESHOLD("below_threshold")`

      - `REQUIRED_EMPTY("required_empty")`

    - `Optional<Cell> cell`

      Where in a list the least confident value is.

      - `long row`

        Index of the row, from 0.

      - `Optional<String> column`

        Property of the row, when rows are objects.

    - `Optional<Double> confidence`

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

  - `String jobId`

    The extract job reviewed.

  - `List<String> openFlags`

    JSON Pointers of flagged fields nobody checked.

  - `Optional<OriginalResult> originalResult`

    The result as the model read it.

  - `List<String> requiredFields`

    JSON Pointers of fields flagged when empty.

  - `LocalDateTime retainUntil`

    When the job and its document may be deleted.

  - `ReviewedResult reviewedResult`

    The result with the field actions.

  - `long revision`

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

  - `Optional<String> sourceFileId`

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

  - `Status status`

    pending until approved or rejected.

    - `APPROVED("approved")`

    - `PENDING("pending")`

    - `REJECTED("rejected")`

  - `LocalDateTime updatedAt`

    When the review last changed.

### Example

```java
package ai.llamaindex.llamacloud.example;

import ai.llamaindex.llamacloud.client.LlamaCloudClient;
import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient;
import ai.llamaindex.llamacloud.models.extract.review.ExtractReview;
import ai.llamaindex.llamacloud.models.extract.review.ReviewChangeFieldsParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ReviewChangeFieldsParams params = ReviewChangeFieldsParams.builder()
            .jobId("job_id")
            .addChange(ReviewChangeFieldsParams.Change.builder()
                .change(ReviewChangeFieldsParams.Change.InnerChange.CORRECT)
                .path("/total")
                .build())
            .revision(0L)
            .build();
        ExtractReview extractReview = client.extract().review().changeFields(params);
    }
}
```

#### 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"
}
```

## Approve Extract Review

`ExtractReview extract().review().approve(ReviewApproveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

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

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

Approve the reviewed result.

While flagged fields nobody checked remain, answers 409 with `code: open_flags`
and their `paths`, unless `sign_off` confirms them as part of approving.
A job that has not completed answers 409 with `code: job_not_reviewable`. A `revision` other than the review's latest answers 409 with `code: stale_revision` and the latest `revision`.

### Parameters

- `ReviewApproveParams params`

  - `Optional<String> jobId`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

  - `long revision`

    The review's revision as the caller last read it.

  - `Optional<Boolean> signOff`

    Confirm the flagged fields nobody checked as part of approving.

### Returns

- `class ExtractReview:`

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

  - `String id`

    Unique identifier of the review.

  - `double confidenceThreshold`

    Fields read below this confidence are flagged.

  - `LocalDateTime createdAt`

    When review was turned on.

  - `Optional<LocalDateTime> decidedAt`

    When it was approved or rejected.

  - `Optional<String> decidedBy`

    ID of the user who approved or rejected it.

  - `Optional<String> decidedReason`

    Why it was rejected.

  - `FieldActions fieldActions`

    The latest action per field, keyed by JSON Pointer.

    - `Action action`

      confirm, correct or clear.

      - `CLEAR("clear")`

      - `CONFIRM("confirm")`

      - `CORRECT("correct")`

    - `String actorId`

      ID of the user who acted.

    - `LocalDateTime at`

      When they acted.

    - `Optional<JsonValue> value`

      The corrected value, for `correct`.

  - `List<String> fieldsInScope`

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

  - `List<Flag> flags`

    Fields the review asks a person to check.

    - `boolean handled`

      Whether someone confirmed, corrected or cleared it.

    - `String path`

      JSON Pointer of the field.

    - `Reason reason`

      below_threshold, or required_empty for a required field left empty.

      - `BELOW_THRESHOLD("below_threshold")`

      - `REQUIRED_EMPTY("required_empty")`

    - `Optional<Cell> cell`

      Where in a list the least confident value is.

      - `long row`

        Index of the row, from 0.

      - `Optional<String> column`

        Property of the row, when rows are objects.

    - `Optional<Double> confidence`

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

  - `String jobId`

    The extract job reviewed.

  - `List<String> openFlags`

    JSON Pointers of flagged fields nobody checked.

  - `Optional<OriginalResult> originalResult`

    The result as the model read it.

  - `List<String> requiredFields`

    JSON Pointers of fields flagged when empty.

  - `LocalDateTime retainUntil`

    When the job and its document may be deleted.

  - `ReviewedResult reviewedResult`

    The result with the field actions.

  - `long revision`

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

  - `Optional<String> sourceFileId`

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

  - `Status status`

    pending until approved or rejected.

    - `APPROVED("approved")`

    - `PENDING("pending")`

    - `REJECTED("rejected")`

  - `LocalDateTime updatedAt`

    When the review last changed.

### Example

```java
package ai.llamaindex.llamacloud.example;

import ai.llamaindex.llamacloud.client.LlamaCloudClient;
import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient;
import ai.llamaindex.llamacloud.models.extract.review.ExtractReview;
import ai.llamaindex.llamacloud.models.extract.review.ReviewApproveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ReviewApproveParams params = ReviewApproveParams.builder()
            .jobId("job_id")
            .revision(0L)
            .build();
        ExtractReview extractReview = client.extract().review().approve(params);
    }
}
```

#### 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"
}
```

## Reject Extract Review

`ExtractReview extract().review().reject(ReviewRejectParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

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

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

Reject the result, with a reason. A job that failed or was cancelled can be rejected,
which closes a review turned on while it ran. A job still queued or running answers
409 with `code: job_not_reviewable`. A `revision` other than the review's latest answers 409 with `code: stale_revision` and the latest `revision`.

### Parameters

- `ReviewRejectParams params`

  - `Optional<String> jobId`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

  - `String reason`

    Why the result was rejected.

  - `long revision`

    The review's revision as the caller last read it.

### Returns

- `class ExtractReview:`

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

  - `String id`

    Unique identifier of the review.

  - `double confidenceThreshold`

    Fields read below this confidence are flagged.

  - `LocalDateTime createdAt`

    When review was turned on.

  - `Optional<LocalDateTime> decidedAt`

    When it was approved or rejected.

  - `Optional<String> decidedBy`

    ID of the user who approved or rejected it.

  - `Optional<String> decidedReason`

    Why it was rejected.

  - `FieldActions fieldActions`

    The latest action per field, keyed by JSON Pointer.

    - `Action action`

      confirm, correct or clear.

      - `CLEAR("clear")`

      - `CONFIRM("confirm")`

      - `CORRECT("correct")`

    - `String actorId`

      ID of the user who acted.

    - `LocalDateTime at`

      When they acted.

    - `Optional<JsonValue> value`

      The corrected value, for `correct`.

  - `List<String> fieldsInScope`

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

  - `List<Flag> flags`

    Fields the review asks a person to check.

    - `boolean handled`

      Whether someone confirmed, corrected or cleared it.

    - `String path`

      JSON Pointer of the field.

    - `Reason reason`

      below_threshold, or required_empty for a required field left empty.

      - `BELOW_THRESHOLD("below_threshold")`

      - `REQUIRED_EMPTY("required_empty")`

    - `Optional<Cell> cell`

      Where in a list the least confident value is.

      - `long row`

        Index of the row, from 0.

      - `Optional<String> column`

        Property of the row, when rows are objects.

    - `Optional<Double> confidence`

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

  - `String jobId`

    The extract job reviewed.

  - `List<String> openFlags`

    JSON Pointers of flagged fields nobody checked.

  - `Optional<OriginalResult> originalResult`

    The result as the model read it.

  - `List<String> requiredFields`

    JSON Pointers of fields flagged when empty.

  - `LocalDateTime retainUntil`

    When the job and its document may be deleted.

  - `ReviewedResult reviewedResult`

    The result with the field actions.

  - `long revision`

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

  - `Optional<String> sourceFileId`

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

  - `Status status`

    pending until approved or rejected.

    - `APPROVED("approved")`

    - `PENDING("pending")`

    - `REJECTED("rejected")`

  - `LocalDateTime updatedAt`

    When the review last changed.

### Example

```java
package ai.llamaindex.llamacloud.example;

import ai.llamaindex.llamacloud.client.LlamaCloudClient;
import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient;
import ai.llamaindex.llamacloud.models.extract.review.ExtractReview;
import ai.llamaindex.llamacloud.models.extract.review.ReviewRejectParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ReviewRejectParams params = ReviewRejectParams.builder()
            .jobId("job_id")
            .reason("The invoice total does not match the line items.")
            .revision(0L)
            .build();
        ExtractReview extractReview = client.extract().review().reject(params);
    }
}
```

#### 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"
}
```

## Reopen Extract Review

`ExtractReview extract().review().reopen(ReviewReopenParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

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

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

Put an approved or rejected review back to pending. Its field actions stay.

A `revision` other than the review's latest answers 409 with `code: stale_revision` and the latest `revision`.

### Parameters

- `ReviewReopenParams params`

  - `Optional<String> jobId`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

  - `long revision`

    The review's revision as the caller last read it.

### Returns

- `class ExtractReview:`

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

  - `String id`

    Unique identifier of the review.

  - `double confidenceThreshold`

    Fields read below this confidence are flagged.

  - `LocalDateTime createdAt`

    When review was turned on.

  - `Optional<LocalDateTime> decidedAt`

    When it was approved or rejected.

  - `Optional<String> decidedBy`

    ID of the user who approved or rejected it.

  - `Optional<String> decidedReason`

    Why it was rejected.

  - `FieldActions fieldActions`

    The latest action per field, keyed by JSON Pointer.

    - `Action action`

      confirm, correct or clear.

      - `CLEAR("clear")`

      - `CONFIRM("confirm")`

      - `CORRECT("correct")`

    - `String actorId`

      ID of the user who acted.

    - `LocalDateTime at`

      When they acted.

    - `Optional<JsonValue> value`

      The corrected value, for `correct`.

  - `List<String> fieldsInScope`

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

  - `List<Flag> flags`

    Fields the review asks a person to check.

    - `boolean handled`

      Whether someone confirmed, corrected or cleared it.

    - `String path`

      JSON Pointer of the field.

    - `Reason reason`

      below_threshold, or required_empty for a required field left empty.

      - `BELOW_THRESHOLD("below_threshold")`

      - `REQUIRED_EMPTY("required_empty")`

    - `Optional<Cell> cell`

      Where in a list the least confident value is.

      - `long row`

        Index of the row, from 0.

      - `Optional<String> column`

        Property of the row, when rows are objects.

    - `Optional<Double> confidence`

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

  - `String jobId`

    The extract job reviewed.

  - `List<String> openFlags`

    JSON Pointers of flagged fields nobody checked.

  - `Optional<OriginalResult> originalResult`

    The result as the model read it.

  - `List<String> requiredFields`

    JSON Pointers of fields flagged when empty.

  - `LocalDateTime retainUntil`

    When the job and its document may be deleted.

  - `ReviewedResult reviewedResult`

    The result with the field actions.

  - `long revision`

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

  - `Optional<String> sourceFileId`

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

  - `Status status`

    pending until approved or rejected.

    - `APPROVED("approved")`

    - `PENDING("pending")`

    - `REJECTED("rejected")`

  - `LocalDateTime updatedAt`

    When the review last changed.

### Example

```java
package ai.llamaindex.llamacloud.example;

import ai.llamaindex.llamacloud.client.LlamaCloudClient;
import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient;
import ai.llamaindex.llamacloud.models.extract.review.ExtractReview;
import ai.llamaindex.llamacloud.models.extract.review.ReviewReopenParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ReviewReopenParams params = ReviewReopenParams.builder()
            .jobId("job_id")
            .revision(0L)
            .build();
        ExtractReview extractReview = client.extract().review().reopen(params);
    }
}
```

#### 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"
}
```

## List Extract Review Events

`ReviewListEventsPage extract().review().listEvents(ReviewListEventsParamsparams = ReviewListEventsParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/api/v2/extract/{job_id}/review/events`

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

List a review's history, newest first.

### Parameters

- `ReviewListEventsParams params`

  - `Optional<String> jobId`

  - `Optional<String> organizationId`

  - `Optional<Long> pageSize`

    Events per page.

  - `Optional<String> pageToken`

    Token from the previous page.

  - `Optional<String> projectId`

### Returns

- `class ExtractReviewEvent:`

  One entry in a review's history.

  - `String id`

    Unique identifier of the entry.

  - `String actorId`

    ID of the user who acted.

  - `LocalDateTime createdAt`

    When it happened.

  - `Kind kind`

    What happened.

    - `APPROVED("approved")`

    - `CREATED("created")`

    - `FIELD_CLEARED("field_cleared")`

    - `FIELD_CONFIRMED("field_confirmed")`

    - `FIELD_CORRECTED("field_corrected")`

    - `FIELD_RESTORED("field_restored")`

    - `FIELD_UNDONE("field_undone")`

    - `FLAGS_SIGNED_OFF("flags_signed_off")`

    - `REJECTED("rejected")`

    - `REOPENED("reopened")`

  - `Optional<Detail> detail`

    The settings for `created`, the reason for `rejected`, and the fields for `flags_signed_off`; null for the rest.

    - `class ExtractReviewCreatedDetail:`

      What a `created` entry records: where review was turned on, and its settings.

      - `double confidenceThreshold`

        Fields read below this confidence are flagged.

      - `List<String> fieldsInScope`

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

      - `Origin origin`

        Turned on as the job ran, from History, by a first edit, or by the API.

        - `API("api")`

        - `EDIT("edit")`

        - `HISTORY("history")`

        - `RUN("run")`

      - `List<String> requiredFields`

        JSON Pointers of fields flagged when empty.

    - `class ExtractReviewRejectedDetail:`

      What a `rejected` entry records.

      - `String reason`

        Why the result was rejected.

    - `class ExtractReviewSignedOffDetail:`

      What a `flags_signed_off` entry records.

      - `List<String> paths`

        JSON Pointers of the flagged fields confirmed as part of approving.

  - `Optional<String> path`

    JSON Pointer of the field it changed.

  - `Optional<JsonValue> valueAfter`

    The field's value after the change.

  - `Optional<JsonValue> valueBefore`

    The field's value before the change.

### Example

```java
package ai.llamaindex.llamacloud.example;

import ai.llamaindex.llamacloud.client.LlamaCloudClient;
import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient;
import ai.llamaindex.llamacloud.models.extract.review.ReviewListEventsPage;
import ai.llamaindex.llamacloud.models.extract.review.ReviewListEventsParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ReviewListEventsPage page = client.extract().review().listEvents("job_id");
    }
}
```

#### Response

```json
{
  "items": [
    {
      "id": "id",
      "actor_id": "actor_id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "kind": "approved",
      "detail": {
        "confidence_threshold": 0,
        "fields_in_scope": [
          "string"
        ],
        "origin": "api",
        "required_fields": [
          "string"
        ]
      },
      "path": "path",
      "value_after": {},
      "value_before": {}
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}
```

## Domain Types

### Extract Review

- `class ExtractReview:`

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

  - `String id`

    Unique identifier of the review.

  - `double confidenceThreshold`

    Fields read below this confidence are flagged.

  - `LocalDateTime createdAt`

    When review was turned on.

  - `Optional<LocalDateTime> decidedAt`

    When it was approved or rejected.

  - `Optional<String> decidedBy`

    ID of the user who approved or rejected it.

  - `Optional<String> decidedReason`

    Why it was rejected.

  - `FieldActions fieldActions`

    The latest action per field, keyed by JSON Pointer.

    - `Action action`

      confirm, correct or clear.

      - `CLEAR("clear")`

      - `CONFIRM("confirm")`

      - `CORRECT("correct")`

    - `String actorId`

      ID of the user who acted.

    - `LocalDateTime at`

      When they acted.

    - `Optional<JsonValue> value`

      The corrected value, for `correct`.

  - `List<String> fieldsInScope`

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

  - `List<Flag> flags`

    Fields the review asks a person to check.

    - `boolean handled`

      Whether someone confirmed, corrected or cleared it.

    - `String path`

      JSON Pointer of the field.

    - `Reason reason`

      below_threshold, or required_empty for a required field left empty.

      - `BELOW_THRESHOLD("below_threshold")`

      - `REQUIRED_EMPTY("required_empty")`

    - `Optional<Cell> cell`

      Where in a list the least confident value is.

      - `long row`

        Index of the row, from 0.

      - `Optional<String> column`

        Property of the row, when rows are objects.

    - `Optional<Double> confidence`

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

  - `String jobId`

    The extract job reviewed.

  - `List<String> openFlags`

    JSON Pointers of flagged fields nobody checked.

  - `Optional<OriginalResult> originalResult`

    The result as the model read it.

  - `List<String> requiredFields`

    JSON Pointers of fields flagged when empty.

  - `LocalDateTime retainUntil`

    When the job and its document may be deleted.

  - `ReviewedResult reviewedResult`

    The result with the field actions.

  - `long revision`

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

  - `Optional<String> sourceFileId`

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

  - `Status status`

    pending until approved or rejected.

    - `APPROVED("approved")`

    - `PENDING("pending")`

    - `REJECTED("rejected")`

  - `LocalDateTime updatedAt`

    When the review last changed.

### Extract Review Event

- `class ExtractReviewEvent:`

  One entry in a review's history.

  - `String id`

    Unique identifier of the entry.

  - `String actorId`

    ID of the user who acted.

  - `LocalDateTime createdAt`

    When it happened.

  - `Kind kind`

    What happened.

    - `APPROVED("approved")`

    - `CREATED("created")`

    - `FIELD_CLEARED("field_cleared")`

    - `FIELD_CONFIRMED("field_confirmed")`

    - `FIELD_CORRECTED("field_corrected")`

    - `FIELD_RESTORED("field_restored")`

    - `FIELD_UNDONE("field_undone")`

    - `FLAGS_SIGNED_OFF("flags_signed_off")`

    - `REJECTED("rejected")`

    - `REOPENED("reopened")`

  - `Optional<Detail> detail`

    The settings for `created`, the reason for `rejected`, and the fields for `flags_signed_off`; null for the rest.

    - `class ExtractReviewCreatedDetail:`

      What a `created` entry records: where review was turned on, and its settings.

      - `double confidenceThreshold`

        Fields read below this confidence are flagged.

      - `List<String> fieldsInScope`

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

      - `Origin origin`

        Turned on as the job ran, from History, by a first edit, or by the API.

        - `API("api")`

        - `EDIT("edit")`

        - `HISTORY("history")`

        - `RUN("run")`

      - `List<String> requiredFields`

        JSON Pointers of fields flagged when empty.

    - `class ExtractReviewRejectedDetail:`

      What a `rejected` entry records.

      - `String reason`

        Why the result was rejected.

    - `class ExtractReviewSignedOffDetail:`

      What a `flags_signed_off` entry records.

      - `List<String> paths`

        JSON Pointers of the flagged fields confirmed as part of approving.

  - `Optional<String> path`

    JSON Pointer of the field it changed.

  - `Optional<JsonValue> valueAfter`

    The field's value after the change.

  - `Optional<JsonValue> valueBefore`

    The field's value before the change.
