0

Get configurations for the authenticated user or team

by
Published Apr 8, 2025

Allows to retrieve all configurations for an authenticated integration. When the `project` view is used, configurations generated for the authorization flow will be filtered out of the results.

Script vercel Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Vercel = {
3
  token: string;
4
};
5
/**
6
 * Get configurations for the authenticated user or team
7
 * Allows to retrieve all configurations for an authenticated integration. When the `project` view is used, configurations generated for the authorization flow will be filtered out of the results.
8
 */
9
export async function main(
10
  auth: Vercel,
11
  view: "account" | "project" | undefined,
12
  installationType: "marketplace" | "external" | undefined,
13
  integrationIdOrSlug: string | undefined,
14
  teamId: string | undefined,
15
  slug: string | undefined,
16
) {
17
  const url = new URL(`https://api.vercel.com/v1/integrations/configurations`);
18
  for (const [k, v] of [
19
    ["view", view],
20
    ["installationType", installationType],
21
    ["integrationIdOrSlug", integrationIdOrSlug],
22
    ["teamId", teamId],
23
    ["slug", slug],
24
  ]) {
25
    if (v !== undefined && v !== "" && k !== undefined) {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "GET",
31
    headers: {
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42