Edits history of script submission #14782 for ' Invite User To Workspace (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Invite User To Workspace
     * Invite someone to join your Workspace as a member. To invite someone as a guest, use the [Invite Guest](ref:inviteguesttoworkspace) endpoint.\
     \
    ***Note:** This endpoint is only available to Workspaces on our [Enterprise Plan](https://clickup.com/pricing).*
     */
    export async function main(
      auth: Clickup,
      team_id: string,
      body: { email: string; admin: false | true; custom_role_id?: number },
    ) {
      const url = new URL(`https://api.clickup.com/api/v2/team/${team_id}/user`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: 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 235 days ago