# Criteria

## Add a criterion to a rubric

`client.rubrics.criteria.create(stringrubricID, CriterionCreateParamsbody, RequestOptionsoptions?): RubricCriteriaResponse`

**post** `/v5/rubrics/{rubric_id}/criteria`

Add a single criterion to an existing rubric.

Creates a new criterion at version 1 under the given rubric. Criteria are
versioned independently of the rubric they belong to. The request is rejected
if the target rubric is archived.

### Parameters

- `rubricID: string`

- `body: CriterionCreateParams`

  - `title: string`

    The Criteria text

  - `annotations?: Record<string, unknown>`

    Free-form metadata for the Criteria

  - `weight?: number`

    Weight multiplier for scoring

### Returns

- `RubricCriteriaResponse`

  - `id: string`

  - `created_at: string`

  - `rubric_id: string`

  - `title: string`

  - `version: number`

  - `annotations?: Record<string, unknown>`

  - `object?: "rubric_criteria"`

    - `"rubric_criteria"`

  - `weight?: number`

### 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 rubricCriteriaResponse = await client.rubrics.criteria.create('rubric_id', { title: 'x' });

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

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "rubric_id": "rubric_id",
  "title": "title",
  "version": 0,
  "annotations": {
    "foo": "bar"
  },
  "object": "rubric_criteria",
  "weight": 0
}
```

## Update a criterion

`client.rubrics.criteria.update(stringrubricCriteriaID, CriterionUpdateParamsparams, RequestOptionsoptions?): RubricCriteriaResponse`

**patch** `/v5/rubrics/{rubric_id}/criteria/{rubric_criteria_id}`

Apply a partial update to a criterion, creating a new version.

Updates are append-only: rather than overwriting the criterion in place, each
update inserts a new immutable version with an incremented version number, so
every prior state stays available through the versions endpoint. Fields not
supplied are carried forward from the current version. The request is rejected
if the criterion does not belong to the rubric named in the path.

### Parameters

- `rubricCriteriaID: string`

- `params: CriterionUpdateParams`

  - `rubric_id: string`

    Path param

  - `annotations?: Record<string, unknown>`

    Body param: Free-form metadata for the Criteria

  - `title?: string`

    Body param: The Criteria text

  - `weight?: number`

    Body param: Weight multiplier for scoring

### Returns

- `RubricCriteriaResponse`

  - `id: string`

  - `created_at: string`

  - `rubric_id: string`

  - `title: string`

  - `version: number`

  - `annotations?: Record<string, unknown>`

  - `object?: "rubric_criteria"`

    - `"rubric_criteria"`

  - `weight?: number`

### 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 rubricCriteriaResponse = await client.rubrics.criteria.update('rubric_criteria_id', {
  rubric_id: 'rubric_id',
});

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

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "rubric_id": "rubric_id",
  "title": "title",
  "version": 0,
  "annotations": {
    "foo": "bar"
  },
  "object": "rubric_criteria",
  "weight": 0
}
```

## List criterion versions

`client.rubrics.criteria.listVersions(stringrubricCriteriaID, CriterionListVersionsParamsparams, RequestOptionsoptions?): CriterionListVersionsResponse`

**get** `/v5/rubrics/{rubric_id}/criteria/{rubric_criteria_id}/versions`

List the full version history of a single criterion, paginated.

Because criterion updates are append-only, this returns one entry per version,
exposing every prior state of the criterion, ordered by version descending
(newest first) by default. The request is rejected if the criterion does not
belong to the rubric named in the path.

### Parameters

- `rubricCriteriaID: string`

- `params: CriterionListVersionsParams`

  - `rubric_id: string`

    Path param

  - `ending_before?: string`

    Query param

  - `limit?: number`

    Query param

  - `sort_by?: string`

    Query param

  - `sort_order?: SortOrder`

    Query param

    - `"asc"`

    - `"desc"`

  - `starting_after?: string`

    Query param

### Returns

- `CriterionListVersionsResponse`

  - `has_more: boolean`

    Whether there are more items left to be fetched.

  - `items: Array<RubricCriteriaResponse>`

    - `id: string`

    - `created_at: string`

    - `rubric_id: string`

    - `title: string`

    - `version: number`

    - `annotations?: Record<string, unknown>`

    - `object?: "rubric_criteria"`

      - `"rubric_criteria"`

    - `weight?: number`

  - `total: number`

    The total of items that match the query. This is greater than or equal to the number of items returned.

  - `limit?: number`

    The maximum number of items to return.

  - `object?: "list"`

    - `"list"`

### 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 response = await client.rubrics.criteria.listVersions('rubric_criteria_id', {
  rubric_id: 'rubric_id',
});

console.log(response.has_more);
```

#### Response

```json
{
  "has_more": true,
  "items": [
    {
      "id": "id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "rubric_id": "rubric_id",
      "title": "title",
      "version": 0,
      "annotations": {
        "foo": "bar"
      },
      "object": "rubric_criteria",
      "weight": 0
    }
  ],
  "total": 0,
  "limit": 0,
  "object": "list"
}
```

## Domain Types

### Rubric Criteria Input

- `RubricCriteriaInput`

  - `title: string`

    The Criteria text

  - `annotations?: Record<string, unknown>`

    Free-form metadata for the Criteria

  - `weight?: number`

    Weight multiplier for scoring

### Rubric Criteria Response

- `RubricCriteriaResponse`

  - `id: string`

  - `created_at: string`

  - `rubric_id: string`

  - `title: string`

  - `version: number`

  - `annotations?: Record<string, unknown>`

  - `object?: "rubric_criteria"`

    - `"rubric_criteria"`

  - `weight?: number`

### Rubric Criteria Summary Response

- `RubricCriteriaSummaryResponse`

  Slim criteria projection for list endpoints (title + weight only).

  - `title: string`

  - `weight?: number`

### Criterion List Versions Response

- `CriterionListVersionsResponse`

  - `has_more: boolean`

    Whether there are more items left to be fetched.

  - `items: Array<RubricCriteriaResponse>`

    - `id: string`

    - `created_at: string`

    - `rubric_id: string`

    - `title: string`

    - `version: number`

    - `annotations?: Record<string, unknown>`

    - `object?: "rubric_criteria"`

      - `"rubric_criteria"`

    - `weight?: number`

  - `total: number`

    The total of items that match the query. This is greater than or equal to the number of items returned.

  - `limit?: number`

    The maximum number of items to return.

  - `object?: "list"`

    - `"list"`
