Edits history of script submission #14682 for ' Create Space (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Create Space
     * Add a new Space to a Workspace.
     */
    export async function main(
      auth: Clickup,
      team_id: string,
      body: {
        name: string;
        multiple_assignees: false | true;
        features: {
          due_dates: {
            enabled: false | true;
            start_date: false | true;
            remap_due_dates: false | true;
            remap_closed_due_date: false | true;
          };
          time_tracking: { enabled: false | true };
          tags: { enabled: false | true };
          time_estimates: { enabled: false | true };
          checklists: { enabled: false | true };
          custom_fields: { enabled: false | true };
          remap_dependencies: { enabled: false | true };
          dependency_warning: { enabled: false | true };
          portfolios: { enabled: false | true };
        };
      },
    ) {
      const url = new URL(`https://api.clickup.com/api/v2/team/${team_id}/space`);
    
      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