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

# Batch create TestDefinition

POST https://{tenant_name}.benchling.com/api/v3/test-definition:batch-create
Content-Type: application/json

Batch create Test Definitions synchronously in one transaction. Maximum 25 items per request.

Each item follows the same field requirements as the single-create endpoint. If any item fails validation, the transaction fails and no Test Definitions are created.

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

## Authentication

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

## Request

### Headers

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

### Body (application/json)

This endpoint expects an object.

- `items` (list of CreateTestDefinitionInput, required)

## Response

### 201

Created

- `items` (list of TestDefinition, required)

## Errors

### 400 Test Definition Batch Create 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 Batch Create 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 Batch Create 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 Batch Create 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 Batch Create 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 Batch Create 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

### CreateTestDefinitionInput

- `description` (string, required) — Human-readable description for the test definition. Empty strings are allowed; values must be at most 255 characters.
- `name` (string, required) — Display name for the test definition. Must be non-empty after trimming whitespace and unique within the organization.
- `organizationId` (string, required) — The API ID of the organization that owns the test definition.
- `resultSchemaId` (string, required) — The API ID of the result schema that defines the shape of results captured for this test.

### TestDefinition

A Test Definition is a configuration object that specifies a type of test or assay that can be ordered against samples. Each Test Definition is associated with a `ResultSchema` that defines the structure of measurement data captured when the test is performed. Test Definitions serve as templates—when a test needs to be performed on a sample, a `TestOrder` is created referencing the appropriate Test Definition. Test Definitions are used within clinical and preclinical study workflows (see `StudySampleTestPlan`) and can be linked to `Procedure` assays for execution. Belongs to an `Organization` and can be archived when no longer needed.

- `__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.

### GeneralErrorDetail

### TooManyRequestsErrorBodyDetail

### InternalServerErrorBodyDetail

### PrincipalRef

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

### OrganizationRef

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

### ResultSchemaRef

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

## Examples

**Request**

```json
{
  "items": [
    {
      "description": "Standard blood chemistry measurements collected for study samples.",
      "name": "Blood Chemistry Panel",
      "organizationId": "org_v7Q9m2Kx",
      "resultSchemaId": "assaysch_Z3xY7vQb"
    }
  ]
}
```

**Response**

```json
{
  "items": [
    {
      "__typename": "__typename",
      "archiveReason": "archiveReason",
      "archived": true,
      "createdAt": "createdAt",
      "description": "description",
      "id": "id",
      "modifiedAt": "modifiedAt",
      "name": "name"
    }
  ]
}
```

**SDK Code**

```python
import requests

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

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

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

print(response.json())
```

```javascript
const url = 'https://{tenant_name}.benchling.com/api/v3/test-definition:batch-create';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"items":[{"description":"Standard blood chemistry measurements collected for study samples.","name":"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);
}
```