0

Patch a group by supplying partial updates

by
Published Oct 17, 2025

Apply a sequence of operations to modify attributes of a SCIM Group resource. Supports 'add', 'remove', and 'replace' operations per RFC 7644 Section 3.5.2. Operations are applied atomically — if any operation fails, no changes are applied. The request body must include the 'schemas' field set to 'urn:ietf:params:scim:api:messages:2.0:PatchOp'. Can be used by the following roles assigned at the organization scope: - ORG_ADMIN

Script cockroachdb Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Cockroachdb = {
3
  token: string;
4
};
5
/**
6
 * Patch a group by supplying partial updates
7
 * Apply a sequence of operations to modify attributes of a SCIM Group resource. Supports 'add', 'remove', and 'replace' operations per RFC 7644 Section 3.5.2. Operations are applied atomically — if any operation fails, no changes are applied. The request body must include the 'schemas' field set to 'urn:ietf:params:scim:api:messages:2.0:PatchOp'.
8

9
Can be used by the following roles assigned at the organization scope:
10
- ORG_ADMIN
11

12
 */
13
export async function main(
14
  auth: Cockroachdb,
15
  id: string,
16
  body: {
17
    Operations: { op: string; path?: string; value?: unknown }[];
18
    schemas: string[];
19
  },
20
) {
21
  const url = new URL(`https://cockroachlabs.cloud/api/scim/v2/Groups/${id}`);
22

23
  const response = await fetch(url, {
24
    method: "PATCH",
25
    headers: {
26
      "Content-Type": "application/json",
27
      Authorization: "Bearer " + auth.token,
28
    },
29
    body: JSON.stringify(body),
30
  });
31
  if (!response.ok) {
32
    const text = await response.text();
33
    throw new Error(`${response.status} ${text}`);
34
  }
35
  return await response.json();
36
}
37