Sample - Asana API
POST/tasks/{task_gid}/setParent

Set the parent of a task

Updates the parent of a task by making it a subtask of another task or removing its existing parent. Supply parent and optionally use insert_before or insert_after to position the task among the parent's subtasks; those options cannot be used together and must identify subtasks of the parent.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

1 parameter · 1 body field
opt_fieldsarray<string>optional
Comma-separated list of optional task properties to include in the response, including nested properties such as `assignee.name`. Values must be selected from the documented task property fields.

The new parent and optional position for the task.

dataobjectoptional

6 status codes
200Returns the complete, updated task record with the new parent relationship applied.
dataobjectoptional
400Returned when a required or malformed value is supplied, or when `insert_before` and `insert_after` are both specified or do not reference valid subtasks of the parent.
errorsarray<object>optional
401Returned when a valid authentication token was not provided with the request.
errorsarray<object>optional
403Returned when the authenticated user does not have access to the task or requested properties, or lacks the required `tasks:write` scope.
errorsarray<object>optional
404Returned when the request does not identify a known action or a specified task or related object does not exist.
errorsarray<object>optional
500Returned when the API encounters a server-side problem; the response may include an error phrase.
errorsarray<object>optional

Error handling

A 400 is returned when parent is missing or the request is malformed, or when both insert_before and insert_after are supplied or an anchor is invalid. A 401 is returned when the authenticated user does not provide a valid authentication token, and a 403 is returned when the authenticated user lacks access or the tasks:write scope. A 404 is returned when the task or referenced object does not exist, and a 500 indicates a server error.