0

Update View

by
Published Oct 17, 2025

Rename a view, update the grouping, sorting, filters, columns, and settings of a view.

Script clickup Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Clickup = {
3
  token: string;
4
};
5
/**
6
 * Update View
7
 * Rename a view, update the grouping, sorting, filters, columns, and settings of a view.
8
 */
9
export async function main(
10
  auth: Clickup,
11
  view_id: string,
12
  body: {
13
    name: string;
14
    type: string;
15
    parent: { id: string; type: number };
16
    grouping: {
17
      field: string;
18
      dir: number;
19
      collapsed: string[];
20
      ignore: false | true;
21
    };
22
    divide: { field?: null; dir?: null; collapsed: false | true };
23
    sorting: { fields: string[] };
24
    filters: {
25
      op: string;
26
      fields: string[];
27
      search: string;
28
      show_closed: false | true;
29
    };
30
    columns: { fields: string[] };
31
    team_sidebar: {
32
      assignees: string[];
33
      assigned_comments: false | true;
34
      unassigned_tasks: false | true;
35
    };
36
    settings: {
37
      show_task_locations: false | true;
38
      show_subtasks: number;
39
      show_subtask_parent_names: false | true;
40
      show_closed_subtasks: false | true;
41
      show_assignees: false | true;
42
      show_images: false | true;
43
      collapse_empty_columns: string;
44
      me_comments: false | true;
45
      me_subtasks: false | true;
46
      me_checklists: false | true;
47
    };
48
  },
49
) {
50
  const url = new URL(`https://api.clickup.com/api/v2/view/${view_id}`);
51

52
  const response = await fetch(url, {
53
    method: "PUT",
54
    headers: {
55
      "Content-Type": "application/json",
56
      Authorization: auth.token,
57
    },
58
    body: JSON.stringify(body),
59
  });
60
  if (!response.ok) {
61
    const text = await response.text();
62
    throw new Error(`${response.status} ${text}`);
63
  }
64
  return await response.json();
65
}
66