# Add a task to multiple projects via API

**URL:** <https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035>\
**Category:** API & Developers\
**Tags:** projects\
**Created:** [4 April 2022 19:47 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035 "2022-04-04T19:47:47Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![FreshyJon](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/freshyjon/32/6475_2.png) [@FreshyJon](https://forum.asana.com/u/FreshyJon)\
**Post date:** [4 April 2022 19:47 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/1 "2022-04-04T19:47:47Z")

</div>

Using the `addProject` API for “Add a project to a task”, is it possible to add the task to multiple projects?

> **[Add a project to a task](https://developers.asana.com/reference/addprojectfortask)**
>
> Adds the task to the specified project, in the optional locationspecified. If no location arguments are given, the task will be added tothe end of the project.addProject can also be used to reorder a task within a project orsection that already...

I see the body parameter expects the dat to include the `project` ID. But, can I simply add multiple project IDs (comma separated) to add the task to multiple projects?

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [4 April 2022 19:56 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/2 "2022-04-04T19:56:54Z")

</div>

No, sorry, only one project per call here.

---

<div class="post-metadata">

**Author:** ![FreshyJon](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/freshyjon/32/6475_2.png) [@FreshyJon](https://forum.asana.com/u/FreshyJon)\
**Post date:** [4 April 2022 19:59 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/3 "2022-04-04T19:59:02Z")

</div>

Do you happen to know of a simple way to add a task to multiple projects (other than duplicating the call X amount of times)? I’m using Zapier, and was hoping to do some basic code to handle this.

E.g., [https://i.imgur.com/gw8qpMW.png](https://i.imgur.com/gw8qpMW.png)

---

<div class="post-metadata">

**Author:** ![Frederic\_Malenfant](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/frederic_malenfant/32/8358_2.png) [@Frederic\_Malenfant](https://forum.asana.com/u/Frederic_Malenfant)\
**Post date:** [5 April 2022 12:11 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/4 "2022-04-05T12:11:54Z")

</div>

Is it for existing tasks, or for new tasks?

You can create new tasks to multiple projects in 1 call, like this:

POST [https://app.asana.com/api/1.1/tasks](https://app.asana.com/api/1.1/tasks)  
{“data”:{“name”:“my task”,“projects”:[“1132891571239348”,“1132891571239350”]}}

If you want to add a maximum of 10 projects to an existing task, you can do it using one single call to the “batch” endpoint.

[https://developers.asana.com/docs/batch-api](https://developers.asana.com/docs/batch-api)

---

<div class="post-metadata">

**Author:** ![FreshyJon](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/freshyjon/32/6475_2.png) [@FreshyJon](https://forum.asana.com/u/FreshyJon)\
**Post date:** [5 April 2022 15:43 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/5 "2022-04-05T15:43:12Z")

</div>

This would be for existing tasks. Based on a particular dropdown custom field value, I plan to assign the task to a certain set of projects.

E.g.,

- If dropdown of “Lead Category” is set to “Low”, add to Project A and Project B
- if dropdown of “Lead Category” is set to “Medium”, add to Project A and Project C
- if dropdown of “Lead Category” is set to “High”, add to Project X, Project Y, and Project Z

Regardless of the conditional aspect, do you have any code samples of using the `POST /batch` endpoint to set multiple projects to a given task ID?

---

<div class="post-metadata">

**Author:** ![anon97170346](https://luna1.co/8d76cd.png) [@anon97170346](https://forum.asana.com/u/anon97170346)\
**Post date:** [6 April 2022 07:40 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/6 "2022-04-06T07:40:40Z")

</div>

Hey ! In fact I have an application in vuejs. I use axios for ajax. However, when I make a get to the ASana api, here is the error that the server returns:  
Access to XMLHttpRequest at ‘[https://app.asana.com/api/1.0/projects](https://app.asana.com/api/1.0/projects)’ from origin ‘[http://localhost:8000](http://localhost:8000)’ has been blocked by CORS policy: Request header field x-csrf-token is not allowed by Access-Control-Allow-Headers in preflight response.

---

<div class="post-metadata">

**Author:** ![Frederic\_Malenfant](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/frederic_malenfant/32/8358_2.png) [@Frederic\_Malenfant](https://forum.asana.com/u/Frederic_Malenfant)\
**Post date:** [7 April 2022 18:46 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/7 "2022-04-07T18:46:28Z")

</div>

Hi, I have not tested it, but it should look like this, to add task “123” to projects “111” and “222”.

POST /batch  
payload:

```auto
{
"data": {
		"actions": [{
				"method": "POST",
				"relative_path": "/tasks/123/addProject",
				"data": {"project": "111"}
			}, {
				"method": "POST",
				"relative_path": "/tasks/123/addProject",
				"data": {"project": "222"}
			}
		]
	}
}

```

You can add up to 10 action in one single batch. So you can add your task to 10 projects at a time.

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [7 April 2022 19:45 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/8 "2022-04-07T19:45:56Z")

</div>

Just to make sure it’s clear for @FreshyJon - you’re still doing a separate API method to add to each project, there’s no way around that; but using the batch approach, you only have to go over the wire once (or more accurately, once for every 10 API methods) instead of **N** times where **N** is the number of API methods you need to do.

---

<div class="post-metadata">

**Author:** ![FreshyJon](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/freshyjon/32/6475_2.png) [@FreshyJon](https://forum.asana.com/u/FreshyJon)\
**Post date:** [7 April 2022 19:52 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/9 "2022-04-07T19:52:48Z")

</div>

Yeah, this is the code I tried using, via @Frederic_Malenfant’s post example, but Zapier is returning a message of `Bad Request`

 ![](https://us1.discourse-cdn.com/asana/original/3X/5/3/537b1c22bebb59dbac5ee9ce2fe715cf3e8e23a8.png)

---

<div class="post-metadata">

**Author:** ![Phil\_Seeman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/phil_seeman/32/81525_2.png) [@Phil\_Seeman](https://forum.asana.com/u/Phil_Seeman)\
**Post date:** [7 April 2022 21:01 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/10 "2022-04-07T21:01:50Z")

</div>

You’re missing the outer “data” element.

---

<div class="post-metadata">

**Author:** ![FreshyJon](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/freshyjon/32/6475_2.png) [@FreshyJon](https://forum.asana.com/u/FreshyJon)\
**Post date:** [8 April 2022 20:51 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/11 "2022-04-08T20:51:00Z")

</div>

Excellent. That made it work. 🙂

> <https://gist.github.com/Garconis/054e0beea31e1702123d77c09b71d9fa>

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:04 UTC](https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/12 "2025-05-30T19:04:23Z")

</div>

Closed on 30 May 2025 19:04 UTC


