0

Update task

by
Published Oct 17, 2025

Updates a task. This can be used to update a task's configuration, or to update its completion state.

Script box Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Box = {
3
  token: string;
4
};
5
/**
6
 * Update task
7
 * Updates a task. This can be used to update a task's configuration, or to
8
update its completion state.
9
 */
10
export async function main(
11
  auth: Box,
12
  task_id: string,
13
  body: {
14
    action?: "review" | "complete";
15
    message?: string;
16
    due_at?: string;
17
    completion_rule?: "all_assignees" | "any_assignee";
18
  },
19
) {
20
  const url = new URL(`https://api.box.com/2.0/tasks/${task_id}`);
21

22
  const response = await fetch(url, {
23
    method: "PUT",
24
    headers: {
25
      "Content-Type": "application/json",
26
      Authorization: "Bearer " + auth.token,
27
    },
28
    body: JSON.stringify(body),
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36