Creating a sub-task when creating a task

Hi everyone.

I am just starting to dig into this API for work.
I have been reading and testing and everything looks good. Very good explanations in the documentations and everything.

I have one question tho.
I do know how to create a task and a sub-task.

But what I need is to create a sub-task when I create a task.
I have a form that is gonna create a task with a title and some sections in the form should be a subtask. Any tips on how to do this?

Sorry for the stupid question tho :slight_smile:

Hi @Joakim_Paulsen and welcome to the forum,

There are no stupid questions!!

Unfortunately there’s no way to create both the task and the subtask in the same API call. You’ll need to do a call to create the task, get back its ID, then use that ID to do another call to create the subtask underneath it.

3 Likes

Or, you can create both master and subtask at the same time in a batch, but the subtasks will be standard tasks for a few seconds.

Then, you can call setParent, to link subtasks to master task.
Set the parent of a task – Asana

But, in both solutions, you need to do multiple calls. So, i think it’s better to, first create the parent, then create the subtasks, as suggested by @Phil_Seeman .

2 Likes