> This page is for Developer Documentation.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.benchling.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.benchling.com/_mcp/server.

# Update TestDefinition

PATCH https://{tenant_name}.benchling.com/api/v3/test-definition/{test_definition_id}
Content-Type: application/json

Update an existing Test Definition.

## Updatable fields

| Field | Description |
| --- | --- |
| `name` | New display name. Names are trimmed and must be unique within the organization. |
| `organizationId` | New owning organization. Use `GET /benchling/organization/items` to find organization IDs. |
| `resultSchemaId` | New result schema. Use `GET /benchling/result-schema/items` to find result schema IDs. |
| `description` | New description. Empty strings are allowed. |
| `archived`, `archiveReason`, `archiveUserId` | Archive or unarchive the test definition. |

## Constraints

- The caller must have read access to the result schema.
- Moving the Test Definition to a different organization requires admin access to the target organization. Re-specifying the current organization only requires read access to it.
- `resultSchemaId` cannot be changed after any Test Orders exist for the Test Definition.
- Archiving fails if the Test Definition has pending, in-progress, or blocked Test Orders.
- Archiving also fails while the Test Definition is associated with an unarchived assay.
- `archiveSubtreeId` and `legacyArchiveRecordId` are legacy archival fields and should normally be omitted.

Reference: https://docs.benchling.com/docs/api/benchling-api/test-definition/update

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `test_definition_id` (string, required) — ID of the TestDefinition.

### Headers

- `EARLY-ACCESS` (string, optional) — Set to true to access beta operations via /api/v3.

### Body (application/json)

This endpoint expects an object.

- `archiveReason` (string, optional)
- `archived` (boolean, optional)
- `description` (string, optional) — Updated human-readable description. Empty strings are allowed; values must be at most 255 characters.
- `name` (string, optional) — Updated display name. When provided, it is trimmed and must be non-empty and unique within the organization.
- `organizationId` (string, optional) — Updated owning organization. Moving to a different organization requires admin access to that organization.
- `resultSchemaId` (string, optional) — Updated result schema. Cannot be changed after test orders have been created for this test definition.

## Response

### 200

OK

- `__typename` (string, optional)
- `archiveReason` (string, optional, nullable)
- `archived` (boolean, optional)
- `createdAt` (string, optional) — Timestamp of when the test definition was created.
- `creator` (PrincipalRef, optional) — The user that created the test definition.
- `description` (string, optional) — The description of the test definition. Empty strings are allowed.
- `id` (string, optional) — The ID of the test definition.
- `modifiedAt` (string, optional) — Timestamp of when the test definition was last modified.
- `name` (string, optional) — The name of the test definition.
- `organization` (OrganizationRef, optional) — The organization that owns the test definition, used for auth.
- `resultSchema` (ResultSchemaRef, optional) — The result schema of the test definition, defines the measurement data shape.

## Errors

### 400 Test Definition Update Request Bad Request Error

Bad Request

- `detail` (GeneralErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 403 Test Definition Update Request Forbidden Error

Forbidden

- `detail` (GeneralErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 404 Test Definition Update Request Not Found Error

Not Found

- `detail` (GeneralErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 409 Test Definition Update Request Conflict Error

Conflict

- `detail` (GeneralErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 429 Test Definition Update Request Too Many Requests Error

Too Many Requests

- `detail` (TooManyRequestsErrorBodyDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)
- `violated-policies` (list of enum, optional) — The budget policies that rejected the request, in canonical order: `user`, `integration`, then `tenant`.
  - Allowed values: `user`, `integration`, `tenant`

### 500 Test Definition Update Request Internal Server Error

Internal Server Error

- `detail` (InternalServerErrorBodyDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `errorId` (string, optional)

## Types

### PrincipalRef

- `__typename` (string, optional)
- `id` (string, optional)

### OrganizationRef

- `__typename` (string, optional)
- `id` (string, optional)

### ResultSchemaRef

- `__typename` (string, optional)
- `id` (string, optional)

### GeneralErrorDetail

### TooManyRequestsErrorBodyDetail

### InternalServerErrorBodyDetail

## Examples

**Request**

```json
{
  "archived": false,
  "description": "Updated set of blood chemistry measurements collected for study samples.",
  "name": "Updated Blood Chemistry Panel",
  "organizationId": "org_v7Q9m2Kx",
  "resultSchemaId": "assaysch_Z3xY7vQb"
}
```

**Response**

```json
{
  "__typename": "__typename",
  "archiveReason": "archiveReason",
  "archived": true,
  "createdAt": "createdAt",
  "creator": {
    "__typename": "__typename",
    "id": "id"
  },
  "description": "description",
  "id": "id",
  "modifiedAt": "modifiedAt",
  "name": "name",
  "organization": {
    "__typename": "__typename",
    "id": "id"
  },
  "resultSchema": {
    "__typename": "__typename",
    "id": "id"
  }
}
```

**SDK Code**

```python
import requests

url = "https://{tenant_name}.benchling.com/api/v3/test-definition/test_definition_id"

payload = {
    "archived": False,
    "description": "Updated set of blood chemistry measurements collected for study samples.",
    "name": "Updated Blood Chemistry Panel",
    "organizationId": "org_v7Q9m2Kx",
    "resultSchemaId": "assaysch_Z3xY7vQb"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://{tenant_name}.benchling.com/api/v3/test-definition/test_definition_id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"archived":false,"description":"Updated set of blood chemistry measurements collected for study samples.","name":"Updated Blood Chemistry Panel","organizationId":"org_v7Q9m2Kx","resultSchemaId":"assaysch_Z3xY7vQb"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```