0

Update a task

by
Published Oct 17, 2025

Updates an existing task by `task_id`. At present, only the `deadline_at`, `is_completed`, `linked_records`, and `assignees` fields can be updated. Required scopes: `task:read-write`, `object_configuration:read`, `record_permission:read`, `user_management:read`.

Script attio Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Attio = {
3
  token: string;
4
};
5
/**
6
 * Update a task
7
 * Updates an existing task by `task_id`. At present, only the `deadline_at`, `is_completed`, `linked_records`, and `assignees` fields can be updated.
8

9
Required scopes: `task:read-write`, `object_configuration:read`, `record_permission:read`, `user_management:read`.
10
 */
11
export async function main(
12
  auth: Attio,
13
  task_id: string,
14
  body: {
15
    data: {
16
      deadline_at?: string;
17
      is_completed?: false | true;
18
      linked_records?:
19
        | { target_object: string; target_record_id: string }
20
        | {
21
            target_object: string;
22
            "[slug_or_id_of_matching_attribute]":
23
              | { domain?: string }
24
              | { email_address?: string }
25
              | { value?: number }
26
              | {
27
                  original_phone_number?: string;
28
                  country_code?:
29
                    | "AF"
30
                    | "AX"
31
                    | "AL"
32
                    | "DZ"
33
                    | "AS"
34
                    | "AD"
35
                    | "AO"
36
                    | "AI"
37
                    | "AQ"
38
                    | "AG"
39
                    | "AR"
40
                    | "AM"
41
                    | "AW"
42
                    | "AU"
43
                    | "AT"
44
                    | "AZ"
45
                    | "BS"
46
                    | "BH"
47
                    | "BD"
48
                    | "BB"
49
                    | "BY"
50
                    | "BE"
51
                    | "BZ"
52
                    | "BJ"
53
                    | "BM"
54
                    | "BT"
55
                    | "BO"
56
                    | "BA"
57
                    | "BW"
58
                    | "BV"
59
                    | "BR"
60
                    | "IO"
61
                    | "BN"
62
                    | "BG"
63
                    | "BF"
64
                    | "BI"
65
                    | "KH"
66
                    | "CM"
67
                    | "CA"
68
                    | "CV"
69
                    | "KY"
70
                    | "CF"
71
                    | "TD"
72
                    | "CL"
73
                    | "CN"
74
                    | "CX"
75
                    | "CC"
76
                    | "CO"
77
                    | "KM"
78
                    | "CG"
79
                    | "CD"
80
                    | "CK"
81
                    | "CR"
82
                    | "CI"
83
                    | "HR"
84
                    | "CU"
85
                    | "CW"
86
                    | "CY"
87
                    | "CZ"
88
                    | "DK"
89
                    | "DJ"
90
                    | "DM"
91
                    | "DO"
92
                    | "EC"
93
                    | "EG"
94
                    | "SV"
95
                    | "GQ"
96
                    | "ER"
97
                    | "EE"
98
                    | "ET"
99
                    | "FK"
100
                    | "FO"
101
                    | "FJ"
102
                    | "FI"
103
                    | "FR"
104
                    | "GF"
105
                    | "PF"
106
                    | "TF"
107
                    | "GA"
108
                    | "GM"
109
                    | "GE"
110
                    | "DE"
111
                    | "GH"
112
                    | "GI"
113
                    | "GR"
114
                    | "GL"
115
                    | "GD"
116
                    | "GP"
117
                    | "GU"
118
                    | "GT"
119
                    | "GG"
120
                    | "GN"
121
                    | "GW"
122
                    | "GY"
123
                    | "HT"
124
                    | "HM"
125
                    | "VA"
126
                    | "HN"
127
                    | "HK"
128
                    | "HU"
129
                    | "IS"
130
                    | "IN"
131
                    | "ID"
132
                    | "IR"
133
                    | "IQ"
134
                    | "IE"
135
                    | "IM"
136
                    | "IL"
137
                    | "IT"
138
                    | "JM"
139
                    | "JP"
140
                    | "JE"
141
                    | "JO"
142
                    | "KZ"
143
                    | "KE"
144
                    | "KI"
145
                    | "KR"
146
                    | "KW"
147
                    | "KG"
148
                    | "LA"
149
                    | "LV"
150
                    | "LB"
151
                    | "LS"
152
                    | "LR"
153
                    | "LY"
154
                    | "LI"
155
                    | "LT"
156
                    | "LU"
157
                    | "MO"
158
                    | "MK"
159
                    | "MG"
160
                    | "MW"
161
                    | "MY"
162
                    | "MV"
163
                    | "ML"
164
                    | "MT"
165
                    | "MH"
166
                    | "MQ"
167
                    | "MR"
168
                    | "MU"
169
                    | "YT"
170
                    | "MX"
171
                    | "FM"
172
                    | "MD"
173
                    | "MC"
174
                    | "MN"
175
                    | "ME"
176
                    | "MS"
177
                    | "MA"
178
                    | "MZ"
179
                    | "MM"
180
                    | "NA"
181
                    | "NR"
182
                    | "NP"
183
                    | "NL"
184
                    | "AN"
185
                    | "NC"
186
                    | "NZ"
187
                    | "NI"
188
                    | "NE"
189
                    | "NG"
190
                    | "NU"
191
                    | "NF"
192
                    | "MP"
193
                    | "NO"
194
                    | "OM"
195
                    | "PK"
196
                    | "PW"
197
                    | "PS"
198
                    | "PA"
199
                    | "PG"
200
                    | "PY"
201
                    | "PE"
202
                    | "PH"
203
                    | "PN"
204
                    | "PL"
205
                    | "PT"
206
                    | "PR"
207
                    | "QA"
208
                    | "RE"
209
                    | "RO"
210
                    | "RU"
211
                    | "RW"
212
                    | "BL"
213
                    | "SH"
214
                    | "KN"
215
                    | "LC"
216
                    | "MF"
217
                    | "PM"
218
                    | "VC"
219
                    | "WS"
220
                    | "SM"
221
                    | "ST"
222
                    | "SA"
223
                    | "SN"
224
                    | "SS"
225
                    | "RS"
226
                    | "SC"
227
                    | "SL"
228
                    | "SG"
229
                    | "SK"
230
                    | "SI"
231
                    | "SB"
232
                    | "SO"
233
                    | "ZA"
234
                    | "GS"
235
                    | "ES"
236
                    | "LK"
237
                    | "SD"
238
                    | "SR"
239
                    | "SJ"
240
                    | "SZ"
241
                    | "SE"
242
                    | "CH"
243
                    | "SY"
244
                    | "TW"
245
                    | "TJ"
246
                    | "TZ"
247
                    | "TH"
248
                    | "TL"
249
                    | "TG"
250
                    | "TK"
251
                    | "TO"
252
                    | "TT"
253
                    | "TN"
254
                    | "TR"
255
                    | "TM"
256
                    | "TC"
257
                    | "TV"
258
                    | "UG"
259
                    | "UA"
260
                    | "AE"
261
                    | "GB"
262
                    | "US"
263
                    | "UM"
264
                    | "UY"
265
                    | "UZ"
266
                    | "VU"
267
                    | "VE"
268
                    | "VN"
269
                    | "VG"
270
                    | "VI"
271
                    | "WF"
272
                    | "EH"
273
                    | "YE"
274
                    | "ZM"
275
                    | "ZW";
276
                }
277
              | { value?: string }[];
278
          }[];
279
      assignees?:
280
        | {
281
            referenced_actor_type: "workspace-member";
282
            referenced_actor_id: string;
283
          }
284
        | { workspace_member_email_address: string }[];
285
    };
286
  },
287
) {
288
  const url = new URL(`https://api.attio.com/v2/tasks/${task_id}`);
289

290
  const response = await fetch(url, {
291
    method: "PATCH",
292
    headers: {
293
      "Content-Type": "application/json",
294
      Authorization: "Bearer " + auth.token,
295
    },
296
    body: JSON.stringify(body),
297
  });
298
  if (!response.ok) {
299
    const text = await response.text();
300
    throw new Error(`${response.status} ${text}`);
301
  }
302
  return await response.json();
303
}
304