The batch API won’t guarantee the order in which the actions are executed. Creating tasks in a particular order requires waiting for one task to be created before trying to create the next one, which would almost entirely counteract the benefits gained from using the batch API.
However, with a clever combination of creating tasks and ordering them, it is still possible to create tasks more quickly with the batch API and still have them be in a particular desired order. Knowing that the maximum batch size is 10, suppose you have 50 tasks to create. Create every 50/10 = 5th task through the normal
POST /tasks endpoint, leaving the project with tasks 1, 6, 11, 16, … 46 in the correct order.
Once those first tasks are created, make a batch request to create tasks 2, 7, 12, 17, …, 47. These will be out-of-order at the end of the project. Then make a second batch request that calls
POST /tasks/task-id/addProject on each of the tasks created in the first batch request, using the
insert_after parameter to put them in the correct place (task 2 goes after task 1, task 7 goes after task 6, …). After this second batch request, the project will have tasks 1, 2, 6, 7, 11, 12, …, 46, 47 in the correct order. With two requests, 10 tasks have been created in the correct location, which means tasks are still created five times faster than they could have been created through the normal endpoint.
You can repeat this process for tasks 3, 8, 13, …, 48 and so on until all tasks have been created.