> This page is for In Vivo.

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

# Update study groups

PATCH https://acme-api.invivo.benchling.com/api/public/v1-beta/studies/{studyId}/groups
Content-Type: application/json

Applies a partial update to between 1 and 100 treatment groups on the study. A property left out keeps the value the group holds. Setting `no` moves a group to that position and renumbers the study's other groups around it, so the response lists only the groups you sent while the `no` of others may have changed. The request is validated as a whole; if any item is invalid, none are updated. The study may not be archived or canceled.

Reference: https://docs.invivo.benchling.com/in-vivo/api/study-groups/study-group-update

## Authentication

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

## Request

### Path parameters

- `studyId` (string, required) — The unique identifier of the study.

### Body (application/json)

This endpoint expects a list of StudyGroupUpdateV1.

- `list of StudyGroupUpdateV1`

## Response

### 200

The updated study groups.

- `data` (list of StudyGroupV1, required) — The study groups.

## Errors

### 400 Bad Request Error

The request was rejected. Validation failures return a `ValidationErrorResponse`; an unrecognised `X-Studies-Api-Version` header returns an `AuthErrorResponse` with the code `invalid_header`.

- `BadRequestErrorResponse`
  - ValidationErrorResponse: ValidationErrorResponse
  - AuthErrorResponse: AuthErrorResponse
  - ProblemDetail: ProblemDetail

### 401 Unauthorized Error

Authentication failed. The body is normally empty; when an otherwise valid access token is missing required claims the body is an `AuthErrorResponse` with the code `invalid_token`.

- `any`

### 403 Forbidden Error

The access token does not grant the scopes this operation requires. The body is normally empty; when the token's team is missing or deleted the body is an `AuthErrorResponse` with the code `invalid_data`.

- `any`

### 429 Too Many Requests Error

A rate limit was exceeded. Retry once the window resets; no `Retry-After` header is sent, so use `X-RateLimit-Reset`.

- `error` (any, required) — A machine-readable error code.
- `message` (string, required) — A human-readable explanation of the failure.

## Types

### StudyGroupUpdateV1

The changes to apply to one study group on the study. Omitted properties are left untouched, and every property rejects `null`.

- `id` (string, required) — The study group to update. Must be on the study.
- `name` (string, optional) — The name of the study group. May not be blank.
- `color` (string, optional) — The color of the study group, as a three- or six-digit hex code.
- `max_animals` (integer, optional) — The maximum number of animals the study group may hold. May not be below the number of animals already assigned to the group.
- `control` (boolean, optional) — Indicates this group is the control. A study has at most one control group, so a request may promote only one group, and promoting one is rejected while another group keeps the flag.
- `no` (integer, optional) — The position the group takes among all the study's groups. Each value must be unique within the request and between 1 and the number of groups on the study. The groups the request does not place keep their order and move to the positions left free, so the `no` of a group you did not send may change. A request that sets no `no` leaves the numbering untouched.
- `metadata` (map from string to any, optional) — Custom fields keyed by your team's active study group metadata glossary slugs, merged into the group's metadata. A value creates or updates the field, `null` clears it, and a field left out keeps its value. Fields your team marks mandatory cannot be cleared.

### StudyGroupV1

A treatment group within a study. You can retrieve it to see its name, sequence number, colour, capacity, whether it is the control group, and any metadata assigned.

- `id` (string, required) — Unique identifier for a study group.
- `name` (string, required) — The name of the study group.
- `no` (integer, required, nullable) — The sequence number of the study group.
- `color` (string, required, nullable) — The color of the study group.
- `max_animals` (integer, required, nullable) — The maximum number of animals allowed in the study group. Null when the group is uncapped.
- `control` (boolean, required) — Indicates this group is a control.
- `metadata` (map from string to any, required, nullable) — The metadata associated to the study group.
- `study` (StudyNestedV1, required, nullable) — The study of the study group.
- `created_at` (datetime, required) — UTC timestamp with microsecond precision, always suffixed with `Z`, in the form `yyyy-MM-ddTHH:mm:ss.SSSSSSZ`.
- `updated_at` (datetime, required) — UTC timestamp with microsecond precision, always suffixed with `Z`, in the form `yyyy-MM-ddTHH:mm:ss.SSSSSSZ`.

### ValidationErrorResponse

Returned when a request body or parameter fails validation.

- `message` (string, required) — A summary of the failure.
- `errors` (map from string to list of string, required) — Failure messages keyed by the offending field, using the field's name as it appears on the wire. Nested fields are dotted, e.g. `schedule.duration`.

### AuthErrorResponse

Returned when a request is rejected during authentication, before it is processed.

- `error` (enum, required) — A machine-readable error code.
  - Allowed values: `invalid_header`, `invalid_token`, `invalid_data`
- `error_description` (string, required) — A human-readable explanation of the failure.

### ProblemDetail

An RFC 9457 problem detail, returned when a request is rejected before it reaches a controller method — most commonly an unparseable or absent JSON body. Unlike the rest of this API, null members are omitted rather than serialised as `null`.

- `title` (string, required) — A short, human-readable summary of the problem type.
- `status` (integer, required) — The HTTP status code, repeated in the body.
- `detail` (string, required) — A human-readable explanation specific to this occurrence.
- `instance` (string, required) — The path of the request that produced the problem.

### StudyNestedV1

The study a record belongs to, as embedded in animals, dosages, measurements, observations and samples. Carries the same attributes as a study retrieved directly, except that the project is given as an identifier rather than an embedded object, and the graph calculation settings are omitted.

- `id` (string, required) — Unique identifier for a study.
- `project_id` (string, required, nullable) — The project of the study. Null when the study is not in a project.
- `name` (string, required) — The name of the study.
- `code` (string, required, nullable) — The code of the study.
- `study_code_id` (string, required, nullable) — The unique identifier of the study code template.
- `type` (enum, required) — Whether the study is run in-house or by an external partner. The `all` value accepted by some filters is not a valid study type and is never returned.
  - Allowed values: `internal`, `external`
- `status` (enum, required) — Review status of a study.
  - Allowed values: `awaiting_approval`, `in_progress`, `rejected`
- `description` (string, required, nullable) — The description of the study.
- `timezone` (string, required, nullable) — The timezone of the study, as an IANA timezone identifier.
- `metadata` (map from string to any, required, nullable) — The metadata associated to the study.
- `author` (StudyAuthorUserV1, required, nullable) — The author of the study.
- `owner` (StudyAuthorUserV1, required, nullable) — The owner of the study.
- `started_on` (date, required) — Calendar date with no time or offset component, in ISO-8601 form.
- `tracking_day_base` (integer, required, nullable) — The day number assigned to the study's start date, from which all subsequent tracking days are counted.
- `completed_at` (datetime, required, nullable) — The completed timestamp of the study.
- `canceled_at` (datetime, required, nullable) — The canceled timestamp of the study.
- `created_at` (datetime, required) — UTC timestamp with microsecond precision, always suffixed with `Z`, in the form `yyyy-MM-ddTHH:mm:ss.SSSSSSZ`.
- `updated_at` (datetime, required) — UTC timestamp with microsecond precision, always suffixed with `Z`, in the form `yyyy-MM-ddTHH:mm:ss.SSSSSSZ`.

### StudyAuthorUserV1

A user referenced as the author or owner of a study.

- `id` (string, required) — Unique identifier for a user.
- `name` (string, required) — The name of the user.
- `email` (string, required) — The email address of the user.
- `timezone` (string, required) — The timezone of the user. Defaults to `UTC` when the user has none set.

## Examples

**Request**

```json
[
  {
    "id": "grp_1OEdawZKhmLCf88R4AnCZm",
    "name": "Vehicle control",
    "color": "#e9429d",
    "max_animals": 16,
    "control": false,
    "metadata": {
      "study-group-internal-id": "GROUP-1234"
    }
  },
  {
    "id": "grp_9nT4kZpMvR2xQw8YbCdFgJ",
    "control": true
  }
]
```

**Response**

```json
{
  "data": [
    {
      "id": "grp_1OEdawZKhmLCf88R4AnCZm",
      "name": "Vehicle control",
      "no": 1,
      "color": "#e9429d",
      "max_animals": 16,
      "control": false,
      "metadata": {
        "study-group-internal-id": "GROUP-1234"
      },
      "study": {
        "id": "sdy_6y9Wop1uArRjD93UiQ5qFy",
        "project_id": "pjt_7IrvD7jMtAGvBl4AQUUr3g",
        "name": "Benchling In Vivo",
        "code": "CD-26-445",
        "study_code_id": "sdc_n6vkWmmHoACZ15pTxztHk",
        "type": "internal",
        "status": "in_progress",
        "description": "Efficacy study in a xenograft model.",
        "timezone": "America/Los_Angeles",
        "metadata": {
          "study-internal-id": "STUDY-1234"
        },
        "author": {
          "id": "usr_72aeLmlraBB7Ekzu2zTsMW",
          "name": "Jo Harper",
          "email": "jo.harper@example.com",
          "timezone": "UTC"
        },
        "owner": {
          "id": "usr_5TSgutt2ZHPnKOdYbaNlRo",
          "name": "Sam Ellis",
          "email": "sam.ellis@example.com",
          "timezone": "UTC"
        },
        "started_on": "2026-09-10",
        "tracking_day_base": 0,
        "completed_at": null,
        "canceled_at": null,
        "created_at": "2026-09-10T07:27:34.132511Z",
        "updated_at": "2026-09-10T07:27:34.132511Z"
      },
      "created_at": "2026-09-10T07:27:34.132511Z",
      "updated_at": "2026-09-11T09:14:02.884210Z"
    },
    {
      "id": "grp_9nT4kZpMvR2xQw8YbCdFgJ",
      "name": "Compound A 10 mg/kg",
      "no": 2,
      "color": "#34e8eb",
      "max_animals": 24,
      "control": true,
      "metadata": {
        "study-group-internal-id": "GROUP-1235"
      },
      "study": {
        "id": "sdy_6y9Wop1uArRjD93UiQ5qFy",
        "project_id": "pjt_7IrvD7jMtAGvBl4AQUUr3g",
        "name": "Benchling In Vivo",
        "code": "CD-26-445",
        "study_code_id": "sdc_n6vkWmmHoACZ15pTxztHk",
        "type": "internal",
        "status": "in_progress",
        "description": "Efficacy study in a xenograft model.",
        "timezone": "America/Los_Angeles",
        "metadata": {
          "study-internal-id": "STUDY-1234"
        },
        "author": {
          "id": "usr_72aeLmlraBB7Ekzu2zTsMW",
          "name": "Jo Harper",
          "email": "jo.harper@example.com",
          "timezone": "UTC"
        },
        "owner": {
          "id": "usr_5TSgutt2ZHPnKOdYbaNlRo",
          "name": "Sam Ellis",
          "email": "sam.ellis@example.com",
          "timezone": "UTC"
        },
        "started_on": "2026-09-10",
        "tracking_day_base": 0,
        "completed_at": null,
        "canceled_at": null,
        "created_at": "2026-09-10T07:27:34.132511Z",
        "updated_at": "2026-09-10T07:27:34.132511Z"
      },
      "created_at": "2026-09-10T07:27:34.132511Z",
      "updated_at": "2026-09-11T09:14:02.884210Z"
    }
  ]
}
```

**SDK Code**

```python Two study group updates
import requests

url = "https://acme-api.invivo.benchling.com/api/public/v1-beta/studies/sdy_3vQ8kZpLmN2xRt7YwBcDfG/groups"

payload = [
    {
        "id": "grp_1OEdawZKhmLCf88R4AnCZm",
        "name": "Vehicle control",
        "color": "#e9429d",
        "max_animals": 16,
        "control": False,
        "metadata": { "study-group-internal-id": "GROUP-1234" }
    },
    {
        "id": "grp_9nT4kZpMvR2xQw8YbCdFgJ",
        "control": True
    }
]
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Two study group updates
const url = 'https://acme-api.invivo.benchling.com/api/public/v1-beta/studies/sdy_3vQ8kZpLmN2xRt7YwBcDfG/groups';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '[{"id":"grp_1OEdawZKhmLCf88R4AnCZm","name":"Vehicle control","color":"#e9429d","max_animals":16,"control":false,"metadata":{"study-group-internal-id":"GROUP-1234"}},{"id":"grp_9nT4kZpMvR2xQw8YbCdFgJ","control":true}]'
};

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