0

Update a Team

by
Published Apr 8, 2025

Update the information of a Team specified by the `teamId` parameter. The request body should contain the information that will be updated on the Team.

Script vercel Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Vercel = {
3
  token: string;
4
};
5
/**
6
 * Update a Team
7
 * Update the information of a Team specified by the `teamId` parameter. The request body should contain the information that will be updated on the Team.
8
 */
9
export async function main(
10
  auth: Vercel,
11
  teamId: string,
12
  slug: string | undefined,
13
  body: {
14
    avatar?: string;
15
    description?: string;
16
    emailDomain?: string;
17
    name?: string;
18
    previewDeploymentSuffix?: string;
19
    regenerateInviteCode?: false | true;
20
    saml?: { enforced?: false | true; roles?: {} };
21
    slug?: string;
22
    enablePreviewFeedback?: string;
23
    enableProductionFeedback?: string;
24
    sensitiveEnvironmentVariablePolicy?: string;
25
    remoteCaching?: { enabled?: false | true };
26
    hideIpAddresses?: false | true;
27
    hideIpAddressesInLogDrains?: false | true;
28
  },
29
) {
30
  const url = new URL(`https://api.vercel.com/v2/teams/${teamId}`);
31
  for (const [k, v] of [["slug", slug]]) {
32
    if (v !== undefined && v !== "" && k !== undefined) {
33
      url.searchParams.append(k, v);
34
    }
35
  }
36
  const response = await fetch(url, {
37
    method: "PATCH",
38
    headers: {
39
      "Content-Type": "application/json",
40
      Authorization: "Bearer " + auth.token,
41
    },
42
    body: JSON.stringify(body),
43
  });
44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48
  return await response.json();
49
}
50