# Upsert a group

Operation ID: `patient.commsUpsertGroup`

Create or update a CareConnect group, keyed by client-supplied `id`. Idempotent. Requires a Bearer JWT (any authenticated pool type).

## Public method

`upsertGroup`

Signature: `patient.upsertGroup(request)`

Return type: `Promise<GroupRecord>`

## Authentication

Classification: **AUTHENTICATED**

Schemes: `bearerAuth`

## Prerequisites

None documented.

## HTTP

`POST /communications/groups`

## Path parameters

None.

## Query parameters

None.

## Body parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `body` | [`UpsertGroupRequest`](../models/UpsertGroupRequest.md) | Yes |  |  |  | No |  |

Request model: [`UpsertGroupRequest`](../models/UpsertGroupRequest.md)

## Request example

```json
{
  "callEnabled": false,
  "createdAt": "2026-08-10T23:37:14.884134Z",
  "createdBy": "sdk-contact-20260811-013559",
  "description": "Care team for the example patient",
  "groupKind": "team",
  "id": "sdk-group-20260811-013559",
  "memberIds": [
    "sdk-contact-20260811-013559"
  ],
  "name": "SDK Patient Test",
  "updatedAt": "2026-08-10T23:37:14.884142Z"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `201` | [`CommGroupRecord`](../models/CommGroupRecord.md) | application/json | Group upserted |

## Success response examples

### 201

```json
{
  "callEnabled": false,
  "createdAt": "2026-08-10T23:37:14.884134Z",
  "createdBy": "sdk-contact-20260811-013559",
  "description": "Care team for the example patient",
  "groupKind": "team",
  "id": "sdk-group-20260811-013559",
  "memberIds": [
    "sdk-contact-20260811-013559"
  ],
  "name": "SDK Patient Test",
  "updatedAt": "2026-08-10T23:37:14.884142Z"
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | The request body failed schema validation |
| `401` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | Authorization required — missing or invalid Bearer JWT |
| `403` | [`patient.ErrorResponse`](../models/patient.ErrorResponse.md) | application/json | The caller's token carries no tenant context |

## Error examples

### 400 — The request body failed validation

```json
{
  "details": [
    {
      "loc": [
        "name"
      ],
      "msg": "Field required",
      "type": "missing"
    }
  ],
  "error": "Invalid request body"
}
```

### 401 — Missing or invalid access token

```json
{
  "error": "Authorization required"
}
```

### 403 — Tenant context unavailable

```json
{
  "error": "Tenant context unavailable"
}
```

## NodeJS / TypeScript implementation

```ts
import { HCSDK } from "@healthcloudai/hc-sdk";
import type { UpsertGroupRequest } from "@healthcloudai/hc-sdk";
```

```ts
const request = {
  "callEnabled": false,
  "createdAt": "2026-08-10T23:37:14.884134Z",
  "createdBy": "sdk-contact-20260811-013559",
  "description": "Care team for the example patient",
  "groupKind": "team",
  "id": "sdk-group-20260811-013559",
  "memberIds": [
    "sdk-contact-20260811-013559"
  ],
  "name": "SDK Patient Test",
  "updatedAt": "2026-08-10T23:37:14.884142Z"
};

const result = await patient.upsertGroup(request);
```

## cURL

```bash
curl -X POST \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{"callEnabled":false,"createdAt":"2026-08-10T23:37:14.884134Z","createdBy":"sdk-contact-20260811-013559","description":"Care team for the example patient","groupKind":"team","id":"sdk-group-20260811-013559","memberIds":["sdk-contact-20260811-013559"],"name":"SDK Patient Test","updatedAt":"2026-08-10T23:37:14.884142Z"}' \
  'https://dev-api-patient.health.cloud/communications/groups'
```

## Notes

None.

## Prepared Test Console scenario

No canonical scenario is currently associated.

## Real response

No approved real integration response is currently published. Unapproved candidates are never rendered as examples.
