Edits history of script submission #14781 for ' Invite Guest To Workspace (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Invite Guest To Workspace
     * Invite a guest to join a Workspace. To invite a member to your Workspace, use the [Invite User to Workspace](ref:inviteusertoworkspace) endpoint. \
     \
    You'll also need to grant the guest access to specific items using the following endpoints: [Add Guest to Folder](ref:addguesttofolder), [Add Guest to List](ref:addguesttolist), or [Add Guest to Task](ref:addguesttotask). \
     \
    ***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;
        can_edit_tags?: false | true;
        can_see_time_spent?: false | true;
        can_see_time_estimated?: false | true;
        can_create_views?: false | true;
        can_see_points_estimated?: false | true;
        custom_role_id?: number;
      },
    ) {
      const url = new URL(`https://api.clickup.com/api/v2/team/${team_id}/guest`);
    
      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