Edits history of script submission #13719 for ' Create a Team (vercel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Vercel = {
      token: string;
    };
    /**
     * Create a Team
     * Create a new Team under your account. You need to send a POST request with the desired Team slug, and optionally the Team name.
     */
    export async function main(
      auth: Vercel,
      body: {
        slug: string;
        name?: string;
        attribution?: {
          sessionReferrer?: string;
          landingPage?: string;
          pageBeforeConversionPage?: string;
          utm?: {
            utmSource?: string;
            utmMedium?: string;
            utmCampaign?: string;
            utmTerm?: string;
          };
        };
      },
    ) {
      const url = new URL(`https://api.vercel.com/v1/teams`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 428 days ago