---
title: "Update Testset"
method: PATCH
path: "/testsets/{testsetId}"
---

# Update Testset

`PATCH /testsets/{testsetId}`

Update a Testset. Only the fields provided in the request body will be updated.
If a field is provided, the new content will replace the existing content.
If a field is not provided, the existing content will remain unchanged.

When updating the schema:
- If field mappings are not provided and existing mappings reference fields that no longer exist, those mappings will be automatically removed
- To preserve all existing mappings, ensure all referenced fields remain in the updated schema
- For complete control, provide both schema and fieldMapping when updating the schema

## Path parameters

- `testsetId` string, required

## Request body

- object
  - `name` string — The name of the Testset.
  - `description` string — The description of the Testset.
  - `jsonSchema` object — The JSON schema for each Testcase in the Testset.
  - `fieldMapping` object — Maps top-level keys of the Testcase schema to their roles (input/expected output). Unmapped fields are treated as metadata.
    - `inputs` string[], required — Fields that represent inputs to the AI system.
    - `expected` string[], required — Fields that represent expected outputs.
    - `metadata` string[], required — Fields that are not inputs or expected outputs.

## Response `200`

Testset updated successfully

- Testset — A collection of Testcases that share the same schema. Each Testset defines the structure of its Testcases through a JSON schema. The `fieldMapping` object maps top-level keys of the Testcase schema to their roles (input/expected output). Fields not mentioned in the `fieldMapping` during creation or update are treated as metadata. ## JSON Schema validation constraints supported: - **Required fields** - Fields listed in the schema's `required` array must be present in Testcases. - **Type validation** - Values must match the specified type (string, number, boolean, null, integer, object, array). - **Enum validation** - Values must be one of the options specified in the `enum` array. - **Object property validation** - Properties of objects must conform to their defined schemas. - **Array item validation** - Items in arrays must conform to the `items` schema. - **Logical composition** - Values must conform to at least one schema in the `anyOf` array. Testcases that fail validation will still be stored, but will include `validationErrors` detailing the issues. Extra fields in the Testcase data that are not in the schema will be stored but are ignored during validation.
  - `id` string, required — The ID of the Testset.
  - `name` string, required — The name of the Testset.
  - `description` string, required — The description of the Testset.
  - `jsonSchema` object, required — The JSON schema for each Testcase in the Testset.
  - `fieldMapping` object, required — Maps top-level keys of the Testcase schema to their roles (input/expected output). Unmapped fields are treated as metadata.
    - `inputs` string[], required — Fields that represent inputs to the AI system.
    - `expected` string[], required — Fields that represent expected outputs.
    - `metadata` string[], required — Fields that are not inputs or expected outputs.

## Other responses

- `401` — Error indicating that the request is not authenticated.
- `500` — An internal service error indicating an issue with the Scorecard service.

## Changes

> 37 revisions in range; 1 could not be searched.

- **2025-05-28** `97ddfea9a000` — 2 breaking, 1 warning, 1 info
  - added the new required request property `fieldMapping/expected`
  - removed the required property `fieldMapping/labels` from the response with the `200` status
  - removed the request property `fieldMapping/labels`
  - added the required property `fieldMapping/expected` to the response with the `200` status

[Change history](https://skmtc.dev/scorecard-ai/apis/scorecard-api/changes/testsets/:testsetId/patch.md)

---

[API](https://skmtc.dev/scorecard-ai/apis/scorecard-api.md) · [All operations](https://skmtc.dev/scorecard-ai/apis/scorecard-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/scorecard-ai/scorecard-api/revisions/121aaa257802/schema)
