All URIs are relative to https://app.asana.com/api/1.0
Method | HTTP request | Description |
---|---|---|
createMembership | POST /memberships | Create a membership |
deleteMembership | DELETE /memberships/{membership_gid} | Delete a membership |
getMembership | GET /memberships/{membership_gid} | Get a membership |
getMemberships | GET /memberships | Get multiple memberships |
updateMembership | PUT /memberships/{membership_gid} | Update a membership |
Create a membership
Creates a new membership in a goal
or project
. Teams
or users
can be a member of goals
or projects
. Returns the full record of the newly created membership.
const Asana = require('asana');
let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';
let membershipsApiInstance = new Asana.MembershipsApi();
let opts = {
'body': {"data": {"<PARAM_1>": "<VALUE_1>", "<PARAM_2>": "<VALUE_2>",}}
};
membershipsApiInstance.createMembership(opts).then((result) => {
console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
console.error(error.response.body);
});
Name | Type | Description | Notes |
---|---|---|---|
body | Object | The updated fields for the membership. | [optional] |
object
- Content-Type: application/json; charset=UTF-8
- Accept: application/json; charset=UTF-8
Delete a membership
A specific, existing membership for a goal
or project
can be deleted by making a DELETE
request on the URL for that membership. Returns an empty data record.
const Asana = require('asana');
let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';
let membershipsApiInstance = new Asana.MembershipsApi();
let membership_gid = "12345"; // String | Globally unique identifier for the membership.
membershipsApiInstance.deleteMembership(membership_gid).then((result) => {
console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
console.error(error.response.body);
});
Name | Type | Description | Notes |
---|---|---|---|
membership_gid | String | Globally unique identifier for the membership. |
object
- Content-Type: Not defined
- Accept: application/json; charset=UTF-8
Get a membership
Returns compact project_membership
record for a single membership. GET
only supports project memberships currently
const Asana = require('asana');
let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';
let membershipsApiInstance = new Asana.MembershipsApi();
let membership_gid = "12345"; // String | Globally unique identifier for the membership.
let opts = {
'opt_fields': "access_level,member,member.name,parent,parent.name,resource_subtype"
};
membershipsApiInstance.getMembership(membership_gid, opts).then((result) => {
console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
console.error(error.response.body);
});
Name | Type | Description | Notes |
---|---|---|---|
membership_gid | String | Globally unique identifier for the membership. | |
opt_fields | Object | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include. | [optional] |
object
- Content-Type: Not defined
- Accept: application/json; charset=UTF-8
Get multiple memberships
Returns compact goal_membership
, project_membership
, or portfolio_membership
records. The possible types for parent
in this request are goal
, project
, or portfolio
. An additional member (user GID or team GID) can be passed in to filter to a specific membership. Teams are not supported for portfolios yet.
const Asana = require('asana');
let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';
let membershipsApiInstance = new Asana.MembershipsApi();
let opts = {
'parent': "159874",
'member': "1061493",
'limit': 50,
'offset': "eyJ0eXAiOJiKV1iQLCJhbGciOiJIUzI1NiJ9",
'opt_fields': "offset,path,uri"
};
membershipsApiInstance.getMemberships(opts).then((result) => {
console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
console.error(error.response.body);
});
Name | Type | Description | Notes |
---|---|---|---|
parent | String | Globally unique identifier for `goal`, `project`, or `portfolio`. | [optional] |
member | String | Globally unique identifier for `team` or `user`. | [optional] |
limit | Number | Results per page. The number of objects to return per page. The value must be between 1 and 100. | [optional] |
offset | String | Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. Note: You can only pass in an offset that was returned to you via a previously paginated request. | [optional] |
opt_fields | Object | This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include. | [optional] |
object
- Content-Type: Not defined
- Accept: application/json; charset=UTF-8
Update a membership
An existing membership can be updated by making a PUT
request on the URL for that goal. Only the fields provided in the data
block will be updated; any unspecified fields will remain unchanged. Memberships on goals
and projects
can be updated. Returns the full record of the updated membership.
const Asana = require('asana');
let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = '<YOUR_ACCESS_TOKEN>';
let membershipsApiInstance = new Asana.MembershipsApi();
let body = {"data": {"<PARAM_1>": "<VALUE_1>", "<PARAM_2>": "<VALUE_2>",}}; // Object | The membership to update.
let membership_gid = "12345"; // String | Globally unique identifier for the membership.
membershipsApiInstance.updateMembership(body, membership_gid).then((result) => {
console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
console.error(error.response.body);
});
Name | Type | Description | Notes |
---|---|---|---|
body | Object | The membership to update. | |
membership_gid | String | Globally unique identifier for the membership. |
object
- Content-Type: application/json; charset=UTF-8
- Accept: application/json; charset=UTF-8