Edits history of script submission #14680 for ' Create List From Template in Space. (clickup)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickup = {
      token: string;
    };
    /**
     * Create List From Template in Space.
     * Create a new List using a List template within a Space. 
    This request can be run asynchronously or synchronously via the `return_immediately` parameter.
    
     */
    export async function main(
      auth: Clickup,
      space_id: string,
      template_id: string,
      body: {
        name: string;
        options?: {
          return_immediately?: false | true;
          content?: string;
          time_estimate?: number;
          automation?: false | true;
          include_views?: false | true;
          old_due_date?: false | true;
          old_start_date?: false | true;
          old_followers?: false | true;
          comment_attachments?: false | true;
          recur_settings?: false | true;
          old_tags?: false | true;
          old_statuses?: false | true;
          subtasks?: false | true;
          custom_type?: false | true;
          old_assignees?: false | true;
          attachments?: false | true;
          comment?: false | true;
          old_status?: false | true;
          external_dependencies?: false | true;
          internal_dependencies?: false | true;
          priority?: false | true;
          custom_fields?: false | true;
          old_checklists?: false | true;
          relationships?: false | true;
          old_subtask_assignees?: false | true;
          start_date?: string;
          due_date?: string;
          remap_start_date?: false | true;
          skip_weekends?: false | true;
          archived?: 1 | 2;
        };
      },
    ) {
      const url = new URL(
        `https://api.clickup.com/api/v2/space/${space_id}/list_template/${template_id}`,
      );
    
      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