setParent for task with Javascript library


I read through the Javascript library documentation and did not seem to find the setParent functionality.

in that case, can anyone help with how to assign an existing task with a parent task?
The asana JS library helps out a lot and I am kind of new with coding, so I haven’t gotten into actually using the JS http curl request yet


In the doc it says “The parent of this task, or null if this is not a subtask. This property cannot be modified using a PUT request but you can change it with the setParent endpoint. You can create subtasks by using the subtasks endpoint.”
Did you try to call this endpoint?


only familiar with using the JS library

client.tasks.update( {task to set as subtask}, {parent task gid} )

but above is using a PUT request, and seems like it cannot be done

I did find a create subtask function with the lib using

Tasks.prototype.addSubtask = function(

but cannot find one where I can set an existing task with a parent task

and as mentioned, not too sure how to do the curl request without using the node.js library

is it something like this? or can someone point me in the right direction?

var requesst = require(‘request’)
var headers = {
‘authorization’: 'Bearer ’
var parent_id = {parent task gid}
var options = {
‘url’: ‘{task gid}/setParent’,
‘headers’ : headers
‘data’: {“parent”: parentgid}

request(options).then(response => {console.log(response)}


Thanks for pointing out the endpoint, think I figured it out using the node request module

needed to use the json option instead of using body

var request = require( ‘request’)
var personalAccessToken = { personal access token }
var parenttaskid = { parent task gid }
var subtaskid = { existing task gid to set as subtask }
var headers = {
‘Authorization’: 'Bearer ’ + personalAccessToken
var jsondata = {“data”: {‘parent’ : parenttaskid}}

var options = {
url: ‘’+ subtaskid +’/setParent/’,
headers: headers,
method: ‘POST’,
json: jsondata

function callback(error, response, body) {



request(options, callback);