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

Add a project to a task

Adds a task to a project and optionally places it in a specified section or position. Supply project and use at most one of insert_before or insert_after; use section to place the task in a section, with null anchors controlling whether it is placed at the beginning or end. A task can belong to at most 20 projects, and the operation requires the tasks:write scope.

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

1 body field

The project membership and optional section or positioning details for the task.

dataobjectoptional

6 status codes
200Returns an empty `data` object after the task has been added to the project.
dataobjectoptional
An empty object. Some endpoints do not return an object on success. The success is conveyed through a 2-- status code and returning an empty object.
400Returned when `project` is missing or the request is malformed, including when conflicting or invalid positioning options are supplied.
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 project, or lacks the required `tasks:write` scope.
errorsarray<object>optional
404Returned when the request does not identify a known action or the task, project, section, or referenced anchor 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 project is missing or the request is malformed, including when both insert_before and insert_after are supplied or a positioning 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, project, section, or anchor object does not exist, and a 500 indicates a server error.