# Evaluation Items

## Get a single evaluation item

`client.evaluationItems.retrieve(stringevaluationItemID, EvaluationItemRetrieveParamsquery?, RequestOptionsoptions?): EvaluationItem`

**get** `/v5/evaluation-items/{evaluation_item_id}`

Retrieve a single evaluation item by its ID within the caller's account.

By default only non-archived items are returned; pass `include_archived=true` to
also retrieve an item that has been archived. The response merges the item's cached
task results into its `data` field and exposes a `task_errors` map keyed by task
alias, so a task that failed on this item surfaces as an entry there rather than as a
request error. Use this to inspect one item's input data and per-task results; to page
through many items, use the list endpoint instead. The request fails if no item with
the given ID exists in the caller's account.

### Parameters

- `evaluationItemID: string`

- `query: EvaluationItemRetrieveParams`

  - `include_archived?: boolean`

### Returns

- `EvaluationItem`

  - `id: string`

    The unique identifier of the entity.

  - `created_at: string`

    The date and time when the entity was created in ISO format.

  - `created_by: Identity`

    The identity that created the entity.

    - `id: string`

    - `type: "user" | "service_account"`

      - `"user"`

      - `"service_account"`

    - `object?: "identity"`

      - `"identity"`

  - `data: Record<string, unknown>`

  - `evaluation_id: string`

  - `archived_at?: string`

    The date and time when the entity was archived in ISO format.

  - `dataset_item_id?: string`

  - `dataset_item_version_num?: number`

  - `files?: Record<string, string>`

  - `object?: "evaluation.item"`

    - `"evaluation.item"`

  - `task_errors?: Record<string, TaskError>`

    Map of task alias to error info.

    - `message: string`

      Error message

    - `type: string`

      Error type/category

  - `task_result_statuses?: Record<string, "completed" | "skipped" | "errored" | 2 more>`

    Per-alias task-result lifecycle status derived from `task_result_cache`. Present when at least one alias has a recorded status; `null` for legacy rows with an empty cache. Renderers use this to distinguish `prefilled` from `completed` on the wire (values themselves are already merged into `data` by `merge_task_result_cache_into_data`).

    - `"completed"`

    - `"skipped"`

    - `"errored"`

    - `"pending"`

    - `"prefilled"`

### Example

```typescript
import SGPClient from 'scale-gp';

const client = new SGPClient({
  accountID: 'My Account ID',
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

const evaluationItem = await client.evaluationItems.retrieve('evaluation_item_id');

console.log(evaluationItem.id);
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": {
    "id": "id",
    "type": "user",
    "object": "identity"
  },
  "data": {
    "foo": "bar"
  },
  "evaluation_id": "evaluation_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "dataset_item_id": "dataset_item_id",
  "dataset_item_version_num": 0,
  "files": {
    "foo": "string"
  },
  "object": "evaluation.item",
  "task_errors": {
    "foo": {
      "message": "message",
      "type": "type"
    }
  },
  "task_result_statuses": {
    "foo": "completed"
  }
}
```

## List and filter evaluation items

`client.evaluationItems.list(EvaluationItemListParamsquery?, RequestOptionsoptions?): CursorPage<EvaluationItem>`

**get** `/v5/evaluation-items`

Return a paginated list of evaluation items belonging to the caller's account.

Pass `evaluation_id` to restrict the results to a single evaluation's items. The
`completion_status` filter selects items by whether any of their tasks errored:
`failed` returns only items that have task errors, `passed` returns only items with no
task errors, and `all` (or omitting the parameter) returns every item. Archived items
are excluded unless `include_archived=true`. Each returned item has its cached task
results merged into `data` and its errors exposed in `task_errors`, identically to the
single-item endpoint.

### Parameters

- `query: EvaluationItemListParams`

  - `completion_status?: "failed" | "passed" | "all"`

    Filter items by completion status. Pass 'failed' to return only items with errors, 'passed' for items without errors. Pass 'all' or omit to return all items.

    - `"failed"`

    - `"passed"`

    - `"all"`

  - `ending_before?: string`

  - `evaluation_id?: string`

  - `include_archived?: boolean`

  - `limit?: number`

  - `sort_by?: string`

  - `sort_order?: SortOrder`

    - `"asc"`

    - `"desc"`

  - `starting_after?: string`

### Returns

- `EvaluationItem`

  - `id: string`

    The unique identifier of the entity.

  - `created_at: string`

    The date and time when the entity was created in ISO format.

  - `created_by: Identity`

    The identity that created the entity.

    - `id: string`

    - `type: "user" | "service_account"`

      - `"user"`

      - `"service_account"`

    - `object?: "identity"`

      - `"identity"`

  - `data: Record<string, unknown>`

  - `evaluation_id: string`

  - `archived_at?: string`

    The date and time when the entity was archived in ISO format.

  - `dataset_item_id?: string`

  - `dataset_item_version_num?: number`

  - `files?: Record<string, string>`

  - `object?: "evaluation.item"`

    - `"evaluation.item"`

  - `task_errors?: Record<string, TaskError>`

    Map of task alias to error info.

    - `message: string`

      Error message

    - `type: string`

      Error type/category

  - `task_result_statuses?: Record<string, "completed" | "skipped" | "errored" | 2 more>`

    Per-alias task-result lifecycle status derived from `task_result_cache`. Present when at least one alias has a recorded status; `null` for legacy rows with an empty cache. Renderers use this to distinguish `prefilled` from `completed` on the wire (values themselves are already merged into `data` by `merge_task_result_cache_into_data`).

    - `"completed"`

    - `"skipped"`

    - `"errored"`

    - `"pending"`

    - `"prefilled"`

### Example

```typescript
import SGPClient from 'scale-gp';

const client = new SGPClient({
  accountID: 'My Account ID',
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const evaluationItem of client.evaluationItems.list()) {
  console.log(evaluationItem.id);
}
```

#### Response

```json
{
  "has_more": true,
  "items": [
    {
      "id": "id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "created_by": {
        "id": "id",
        "type": "user",
        "object": "identity"
      },
      "data": {
        "foo": "bar"
      },
      "evaluation_id": "evaluation_id",
      "archived_at": "2019-12-27T18:11:19.117Z",
      "dataset_item_id": "dataset_item_id",
      "dataset_item_version_num": 0,
      "files": {
        "foo": "string"
      },
      "object": "evaluation.item",
      "task_errors": {
        "foo": {
          "message": "message",
          "type": "type"
        }
      },
      "task_result_statuses": {
        "foo": "completed"
      }
    }
  ],
  "total": 0,
  "limit": 0,
  "object": "list"
}
```

## Export evaluation items to a file

`client.evaluationItems.export(EvaluationItemExportParamsbody, RequestOptionsoptions?): EvaluationItemExport`

**post** `/v5/evaluation-items/export`

Export all evaluation items for a single evaluation as a downloadable file.

The evaluation is specified by `evaluation_id` in the request body. `export_format`
selects CSV, JSON, or JSONL; for CSV the per-item `data` and `files` fields are
flattened into individual columns and metric-like result columns are expanded.
`export_method` controls delivery: `direct` returns the file contents inline in the
response, while `signed_url` uploads the file to object storage and returns a
pre-signed download URL. Requesting `signed_url` in an environment where object
storage is not configured fails with a 501, so use `direct` there instead. Set
`include_archived=true` to include archived items in the export. This endpoint reads
items only and does not modify the evaluation.

### Parameters

- `body: EvaluationItemExportParams`

  - `evaluation_id: string`

    The ID of the evaluation to export items from.

  - `export_format?: ExportFormat`

    The format of the exported evaluation items. `json` returns a single JSON array, while `jsonl` returns one JSON object per line.

    - `"json"`

    - `"jsonl"`

    - `"csv"`

  - `export_method?: ExportMethod`

    The method for exporting evaluation items. `signed_url` returns a pre-signed URL, while `direct` returns the raw content.

    - `"signed_url"`

    - `"direct"`

  - `include_archived?: boolean`

    If true, include archived evaluation items in the export.

### Returns

- `EvaluationItemExport`

  Response model for exporting evaluation items.
  This class represents the response when users export evaluation items.
  It contains either a signed URL to download the exported data from object storage,
  or the actual content bytes when direct download is used (in environments where object storage is not configured).

  - `filename: string`

    The name of the exported file

  - `content?: string`

    The raw file content as bytes, used when direct download is enabled

  - `signed_url?: string`

    Pre-signed URL to download the file from object storage, if applicable

### Example

```typescript
import SGPClient from 'scale-gp';

const client = new SGPClient({
  accountID: 'My Account ID',
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

const evaluationItemExport = await client.evaluationItems.export({
  evaluation_id: 'evaluation_id',
});

console.log(evaluationItemExport.filename);
```

#### Response

```json
{
  "filename": "filename",
  "content": "content",
  "signed_url": "signed_url"
}
```

## Domain Types

### Component

- `Component`

  - `data: ItemLocator`

    A pointer to the data in each evaluation item to be displayed within the component

  - `label?: string`

### Container

- `Container`

  - `children: Array<Container | Component>`

    The children to be displayed within the container

    - `Container`

    - `Component`

      - `data: ItemLocator`

        A pointer to the data in each evaluation item to be displayed within the component

      - `label?: string`

  - `direction?: "row" | "column"`

    The axis that children are placed in the container. Based on CSS `flex-direction` (see: https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction)

    - `"row"`

    - `"column"`

### Evaluation Item

- `EvaluationItem`

  - `id: string`

    The unique identifier of the entity.

  - `created_at: string`

    The date and time when the entity was created in ISO format.

  - `created_by: Identity`

    The identity that created the entity.

    - `id: string`

    - `type: "user" | "service_account"`

      - `"user"`

      - `"service_account"`

    - `object?: "identity"`

      - `"identity"`

  - `data: Record<string, unknown>`

  - `evaluation_id: string`

  - `archived_at?: string`

    The date and time when the entity was archived in ISO format.

  - `dataset_item_id?: string`

  - `dataset_item_version_num?: number`

  - `files?: Record<string, string>`

  - `object?: "evaluation.item"`

    - `"evaluation.item"`

  - `task_errors?: Record<string, TaskError>`

    Map of task alias to error info.

    - `message: string`

      Error message

    - `type: string`

      Error type/category

  - `task_result_statuses?: Record<string, "completed" | "skipped" | "errored" | 2 more>`

    Per-alias task-result lifecycle status derived from `task_result_cache`. Present when at least one alias has a recorded status; `null` for legacy rows with an empty cache. Renderers use this to distinguish `prefilled` from `completed` on the wire (values themselves are already merged into `data` by `merge_task_result_cache_into_data`).

    - `"completed"`

    - `"skipped"`

    - `"errored"`

    - `"pending"`

    - `"prefilled"`

### Evaluation Item Export

- `EvaluationItemExport`

  Response model for exporting evaluation items.
  This class represents the response when users export evaluation items.
  It contains either a signed URL to download the exported data from object storage,
  or the actual content bytes when direct download is used (in environments where object storage is not configured).

  - `filename: string`

    The name of the exported file

  - `content?: string`

    The raw file content as bytes, used when direct download is enabled

  - `signed_url?: string`

    Pre-signed URL to download the file from object storage, if applicable

### Export Format

- `ExportFormat = "json" | "jsonl" | "csv"`

  - `"json"`

  - `"jsonl"`

  - `"csv"`

### Export Method

- `ExportMethod = "signed_url" | "direct"`

  - `"signed_url"`

  - `"direct"`

### Task Error

- `TaskError`

  - `message: string`

    Error message

  - `type: string`

    Error type/category
