0

Create a Team

by
Published Apr 8, 2025

Create a new Team under your account. You need to send a POST request with the desired Team slug, and optionally the Team name.

Script vercel Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Vercel = {
3
  token: string;
4
};
5
/**
6
 * Create a Team
7
 * Create a new Team under your account. You need to send a POST request with the desired Team slug, and optionally the Team name.
8
 */
9
export async function main(
10
  auth: Vercel,
11
  body: {
12
    slug: string;
13
    name?: string;
14
    attribution?: {
15
      sessionReferrer?: string;
16
      landingPage?: string;
17
      pageBeforeConversionPage?: string;
18
      utm?: {
19
        utmSource?: string;
20
        utmMedium?: string;
21
        utmCampaign?: string;
22
        utmTerm?: string;
23
      };
24
    };
25
  },
26
) {
27
  const url = new URL(`https://api.vercel.com/v1/teams`);
28

29
  const response = await fetch(url, {
30
    method: "POST",
31
    headers: {
32
      "Content-Type": "application/json",
33
      Authorization: "Bearer " + auth.token,
34
    },
35
    body: JSON.stringify(body),
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43