0

Update task assignment

by
Published Oct 17, 2025

Updates a task assignment. This endpoint can be used to update the state of a task assigned to a user.

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 assignment
7
 * Updates a task assignment. This endpoint can be
8
used to update the state of a task assigned to a user.
9
 */
10
export async function main(
11
  auth: Box,
12
  task_assignment_id: string,
13
  body: {
14
    message?: string;
15
    resolution_state?: "completed" | "incomplete" | "approved" | "rejected";
16
  },
17
) {
18
  const url = new URL(
19
    `https://api.box.com/2.0/task_assignments/${task_assignment_id}`,
20
  );
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