Update a task in a specific place in a section by API

Hi guys!
I have an integration that creates and assigns tasks to section. What I’m missing is how to update the task in a specific place in the section. For instance, if a section contains 15 tasks that ordered according to their due date. When I create a new task and assign it to the section, I want it to be placed in the right place according to its due date. I read the DOC below, but honestly, I didn’t understand if what I’m looking for is possible at all :slight_smile:
Thanks!

https://developers.asana.com/docs/#add-task-to-section

Yes, it’s possible! But you won’t be able to tell it to insert the new task by due date. Instead, you’ll need to get the ID of the task just above where you want it inserted (or just below, if you want it to be inserted as the top task of the section) and then use the insert_after parameter (or insert_before for that top task).

In practice this likely means you’ll need to retrieve all of the tasks in the section so you can write some code to examine them and figure out which task is the one to pass the ID of in the parameter.

1 Like

Thanks Phil! Appreaciate your help here