0

Request access to a team

by
Published Apr 8, 2025

Request access to a team as a member. An owner has to approve the request. Only 10 users can request access to a team at the same time.

Script vercel Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Vercel = {
3
  token: string;
4
};
5
/**
6
 * Request access to a team
7
 * Request access to a team as a member. An owner has to approve the request. Only 10 users can request access to a team at the same time.
8
 */
9
export async function main(
10
  auth: Vercel,
11
  teamId: string,
12
  body: {
13
    joinedFrom: {
14
      origin:
15
        | "import"
16
        | "teams"
17
        | "github"
18
        | "gitlab"
19
        | "bitbucket"
20
        | "feedback"
21
        | "organization-teams";
22
      commitId?: string;
23
      repoId?: string;
24
      repoPath?: string;
25
      gitUserId?: string | number;
26
      gitUserLogin?: string;
27
    };
28
  },
29
) {
30
  const url = new URL(`https://api.vercel.com/v1/teams/${teamId}/request`);
31

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