Appearance
Create a membership
API ReferenceCreates a new membership in a goal, project, portfolio, custom_type, or custom_field, where members can be Teams or Users.
Returns the full record of the newly created membership.
OpenAPI definition
json
{
"openapi": "3.0.0",
"info": {
"description": "This is the interface for interacting with the Asana Platform. Our API reference is generated from our [OpenAPI spec] (https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_oas.yaml).",
"x-public-description": "This is the interface for interacting with the Asana Platform. Our API reference is generated from our [OpenAPI spec] (https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_oas.yaml).",
"title": "Asana",
"termsOfService": "https://asana.com/terms",
"contact": {
"name": "Asana Support",
"url": "https://asana.com/support"
},
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0"
},
"version": "1.0",
"x-docs-schema-whitelist": [
"AsanaResource",
"AsanaNamedResource",
"AuditLogEvent",
"AttachmentResponse",
"AttachmentCompact",
"BatchResponse",
"CustomFieldSettingResponse",
"CustomFieldSettingCompact",
"CustomTypeResponse",
"CustomTypeBase",
"CustomTypeCompact",
"CustomTypeStatusOptionResponse",
"CustomTypeStatusOptionBase",
"CustomTypeStatusOptionCompact",
"CustomFieldResponse",
"CustomFieldCompact",
"CustomFieldMembershipCompact",
"CustomFieldMembershipResponse",
"EnumOption",
"EventResponse",
"ErrorResponse",
"GoalResponse",
"GoalCompact",
"GoalMembershipCompact",
"GoalMembershipBase",
"GoalMembershipResponse",
"GoalRelationshipResponse",
"GoalRelationshipCompact",
"GraphExportResponse",
"GraphExportCompact",
"JobResponse",
"JobCompact",
"OrganizationExportResponse",
"OrganizationExportCompact",
"PortfolioMembershipResponse",
"PortfolioMembershipCompact",
"PortfolioResponse",
"PortfolioCompact",
"ProjectBriefResponse",
"ProjectBriefCompact",
"ProjectMembershipCompactResponse",
"ProjectMembershipNormalResponse",
"ProjectMembershipCompact",
"ProjectResponse",
"ProjectCompact",
"ProjectStatusResponse",
"ProjectStatusCompact",
"ProjectTemplateCompact",
"ProjectTemplateResponse",
"RuleTriggerResponse",
"ResourceExportResponse",
"ResourceExportCompact",
"ResourceExportCompact",
"RbacRoleResponse",
"RbacRoleCompact",
"SectionResponse",
"SectionCompact",
"StatusUpdateResponse",
"StatusUpdateCompact",
"StoryResponse",
"StoryCompact",
"TagResponse",
"TagCompact",
"TaskResponse",
"TaskCompact",
"TaskCountResponse",
"TeamMembershipResponse",
"TeamMembershipCompact",
"TeamResponse",
"TeamCompact",
"TimePeriodResponse",
"TimePeriodCompact",
"TimeTrackingCategoryResponse",
"TimeTrackingCategoryCompact",
"UserTaskListResponse",
"UserTaskListCompact",
"UserResponse",
"UserCompact",
"WebhookFilter",
"WebhookResponse",
"WebhookCompact",
"WorkspaceMembershipResponse",
"WorkspaceMembershipCompact",
"WorkspaceResponse",
"WorkspaceCompact"
]
},
"servers": [
{
"url": "https://app.asana.com/api/1.0",
"description": "Main endpoint."
}
],
"security": [
{
"personalAccessToken": []
},
{
"oauth2": []
}
],
"x-readme": {
"proxy-enabled": false
},
"tags": [
{
"name": "Memberships",
"description": "A membership object represents the relationship between a team or user and an object in Asana. Currently, the\nsupported types of memberships are for goals, projects, custom fields, custom types,and portfolios. For example, a project membership\ncan be used to add a user to a project."
}
],
"components": {
"parameters": {
"pretty": {
"name": "opt_pretty",
"in": "query",
"description": "Provides “pretty” output.\nProvides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.",
"required": false,
"allowEmptyValue": true,
"schema": {
"type": "boolean"
},
"style": "form",
"example": true
}
},
"responses": {
"BadRequest": {
"description": "This usually occurs because of a missing or malformed parameter. Check the documentation and the syntax of your request and try again.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"Unauthorized": {
"description": "A valid authentication token was not provided with the request, so the API could not associate a user with the request.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"Forbidden": {
"description": "The authentication and request syntax was valid but the server is refusing to complete the request. This can happen if you try to read or write to objects or properties that the user does not have access to.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"NotFound": {
"description": "Either the request method and path supplied do not specify a known action in the API, or the object specified by the request does not exist.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"InternalServerError": {
"description": "There was a problem on Asana’s end. In the event of a server error the response body should contain an error phrase. These phrases can be used by Asana support to quickly look up the incident that caused the server error. Some errors are due to server load, and will not supply an error phrase.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
},
"schemas": {
"CustomFieldCompact": {
"description": "Custom Fields store the metadata that is used in order to add user-specified information to tasks in Asana. Be sure to reference the [custom fields](/reference/custom-fields/custom-fields) developer documentation for more information about how custom fields relate to various resources in Asana.\n\nUsers in Asana can lock custom fields, which will make them read-only when accessed by other users. Attempting to edit a locked custom field will return HTTP error code `403 Forbidden`.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "custom_field",
"x-insert-after": "gid"
},
"name": {
"description": "The name of the custom field.",
"type": "string",
"example": "Status"
},
"type": {
"description": "*Deprecated: new integrations should prefer the resource_subtype field.* The type of the custom field. Must be one of the given values.\n",
"type": "string",
"readOnly": true,
"enum": [
"text",
"enum",
"multi_enum",
"number",
"date",
"people"
]
},
"enum_options": {
"description": "*Conditional*. Only relevant for custom fields of type `enum` or `multi_enum`. This array specifies the possible values which an `enum` custom field can adopt. To modify the enum options, refer to [working with enum options](/reference/custom-fields/createenumoptionforcustomfield).",
"type": "array",
"items": {
"$ref": "#/components/schemas/EnumOption"
}
},
"enabled": {
"description": "*Conditional*. This field applies only to [custom field values](/guides/platform/custom-fields-guide#/accessing-custom-field-values-on-tasks-or-projects) and is not available for [custom field definitions](/guides/platform/custom-fields-guide#/accessing-custom-field-definitions).\nDetermines if the custom field is enabled or not. For more details, see the [Custom Fields documentation](/guides/platform/custom-fields-guide#/enabled-and-disabled-values).",
"type": "boolean",
"readOnly": true,
"example": true
},
"representation_type": {
"description": "This field tells the type of the custom field.",
"type": "string",
"example": "number",
"readOnly": true,
"enum": [
"text",
"enum",
"multi_enum",
"number",
"date",
"people",
"formula",
"custom_id"
]
},
"id_prefix": {
"description": "This field is the unique custom ID string for the custom field.",
"type": "string",
"nullable": true,
"example": "ID"
},
"input_restrictions": {
"description": "*Conditional*. Only relevant for custom fields of type `reference`. This array of strings reflects the allowed types of objects that can be written to a `reference` custom field value.",
"type": "array",
"items": {
"type": "string"
},
"example": "task"
},
"is_formula_field": {
"description": "*Conditional*. This flag describes whether a custom field is a formula custom field.",
"type": "boolean",
"example": false
},
"date_value": {
"description": "*Conditional*. Only relevant for custom fields of type `date`. This object reflects the chosen date (and optionally, time) value of a `date` custom field. If no date is selected, the value of `date_value` will be `null`.",
"type": "object",
"nullable": true,
"properties": {
"date": {
"type": "string",
"description": "A string representing the date in YYYY-MM-DD format.",
"example": "2024-08-23"
},
"date_time": {
"type": "string",
"description": "A string representing the date in ISO 8601 format. If no time value is selected, the value of `date-time` will be `null`.",
"example": "2024-08-23T22:00:00.000Z"
}
}
},
"enum_value": {
"allOf": [
{
"$ref": "#/components/schemas/EnumOption"
},
{
"type": "object",
"nullable": true,
"description": "*Conditional*. Only relevant for custom fields of type `enum`. This object is the chosen value of an `enum` custom field."
}
]
},
"multi_enum_values": {
"description": "*Conditional*. Only relevant for custom fields of type `multi_enum`. This object is the chosen values of a `multi_enum` custom field.",
"type": "array",
"items": {
"$ref": "#/components/schemas/EnumOption"
}
},
"number_value": {
"description": "*Conditional*. This number is the value of a `number` custom field.",
"type": "number",
"nullable": true,
"example": 5.2
},
"text_value": {
"description": "*Conditional*. This string is the value of a `text` custom field.",
"type": "string",
"nullable": true,
"example": "Some Value"
},
"display_value": {
"description": "A string representation for the value of the custom field. Integrations that don't require the underlying type should use this field to read values. Using this field will future-proof an app against new custom field types.",
"type": "string",
"readOnly": true,
"example": "blue",
"nullable": true
}
}
},
"CustomTypeCompact": {
"description": "Custom Types extend the types of Asana Objects, currently only Custom Tasks are supported.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "custom_type",
"x-insert-after": "gid"
},
"name": {
"type": "string",
"description": "The name of the custom type.",
"example": "Bug ticket"
}
}
},
"EnumOption": {
"description": "Enum options are the possible values which an enum custom field can adopt. An enum custom field must contain at least 1 enum option but no more than 500.\n\nYou can add enum options to a custom field by using the `POST /custom_fields/custom_field_gid/enum_options` endpoint.\n\n**It is not possible to remove or delete an enum option**. Instead, enum options can be disabled by updating the `enabled` field to false with the `PUT /enum_options/enum_option_gid` endpoint. Other attributes can be updated similarly.\n\nOn creation of an enum option, `enabled` is always set to `true`, meaning the enum option is a selectable value for the custom field. Setting `enabled=false` is equivalent to “trashing” the enum option in the Asana web app within the “Edit Fields” dialog. The enum option will no longer be selectable but, if the enum option value was previously set within a task, the task will retain the value.\n\nEnum options are an ordered list and by default new enum options are inserted at the end. Ordering in relation to existing enum options can be specified on creation by using `insert_before` or `insert_after` to reference an existing enum option. Only one of `insert_before` and `insert_after` can be provided when creating a new enum option.\n\nAn enum options list can be reordered with the `POST /custom_fields/custom_field_gid/enum_options/insert` endpoint.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "enum_option",
"x-insert-after": "gid"
},
"name": {
"description": "The name of the enum option.",
"type": "string",
"example": "Low"
},
"enabled": {
"description": "Whether or not the enum option is a selectable value for the custom field.",
"type": "boolean",
"example": true
},
"color": {
"description": "The color of the enum option. Defaults to `none`.",
"type": "string",
"example": "blue"
}
}
},
"Error": {
"type": "object",
"properties": {
"message": {
"type": "string",
"readOnly": true,
"description": "Message providing more detail about the error that occurred, if available.",
"example": "project: Missing input"
},
"help": {
"type": "string",
"readOnly": true,
"description": "Additional information directing developers to resources on how to address and fix the problem, if available.",
"example": "For more information on API status codes and how to handle them, read the docs on errors: https://asana.github.io/developer-docs/#errors'"
},
"phrase": {
"type": "string",
"readOnly": true,
"description": "*500 errors only*. A unique error phrase which can be used when contacting developer support to help identify the exact occurrence of the problem in Asana's logs.",
"example": "6 sad squid snuggle softly"
}
}
},
"ErrorResponse": {
"description": "Sadly, sometimes requests to the API are not successful. Failures can\noccur for a wide range of reasons. In all cases, the API should return\nan HTTP Status Code that indicates the nature of the failure,\nwith a response body in JSON format containing additional information.\n\n\nIn the event of a server error the response body will contain an error\nphrase. These phrases are automatically generated using the\nnode-asana-phrase\nlibrary and can be used by\nAsana support to quickly look up the incident that caused the server\nerror.",
"type": "object",
"properties": {
"errors": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"GoalCompact": {
"description": "A generic Asana Resource, containing a globally unique identifier.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "goal",
"x-insert-after": "gid"
},
"name": {
"type": "string",
"description": "The name of the goal.",
"example": "Grow web traffic by 30%"
},
"owner": {
"allOf": [
{
"$ref": "#/components/schemas/UserCompact"
},
{
"type": "object",
"nullable": true
}
]
}
}
},
"MemberCompact": {
"description": "A *member* object represents either a team or user.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"type": "string",
"description": "The type of the member (team or user)",
"example": "user"
},
"name": {
"type": "string",
"description": "The name of the member",
"example": "Greg Sanchez"
}
}
},
"PortfolioCompact": {
"description": "A *portfolio* gives a high-level overview of the status of multiple initiatives in Asana. Portfolios provide a dashboard overview of the state of multiple projects, including a progress report and the most recent [project status](/reference/project-statuses/project-statuses) update.\nPortfolios have some restrictions on size. Each portfolio has a max of 1500 items and, like projects, a max of 20 custom fields.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "portfolio",
"x-insert-after": "gid"
},
"name": {
"description": "The name of the portfolio.",
"type": "string",
"example": "Bug Portfolio"
}
}
},
"PortfolioMembershipCompact": {
"description": "This object determines if a user is a member of a portfolio.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "portfolio_membership",
"x-insert-after": "gid"
},
"parent": {
"description": "The portfolio the user is a member of.",
"$ref": "#/components/schemas/PortfolioCompact"
},
"member": {
"description": "Member can be a user or a team.",
"$ref": "#/components/schemas/MemberCompact"
},
"access_level": {
"description": "Whether the member has admin, editor, or viewer access to the portfolio. Portfolios do not support commenter access yet.",
"type": "string",
"enum": [
"admin",
"editor",
"viewer"
],
"readOnly": true,
"example": "admin"
}
}
},
"ProjectCompact": {
"description": "A *project* represents a prioritized list of tasks in Asana or a board with columns of tasks represented as cards. It exists in a single workspace or organization and is accessible to a subset of users in that workspace or organization, depending on its permissions.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "project",
"x-insert-after": "gid"
},
"name": {
"description": "Name of the project. This is generally a short sentence fragment that fits on a line in the UI for maximum readability. However, it can be longer.",
"type": "string",
"example": "Stuff to buy"
}
}
},
"CustomFieldMembershipCompact": {
"description": "This object describes a user or team's membership to a custom field including their level of access (Admin, Editor, or User).",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "custom_field_membership",
"x-insert-after": "gid"
},
"resource_subtype": {
"description": "Type of the membership.",
"type": "string",
"example": "custom_field_membership"
},
"parent": {
"description": "The custom field the user or team is a member of.",
"$ref": "#/components/schemas/CustomFieldCompact"
},
"member": {
"description": "Member can be a user or a team.",
"$ref": "#/components/schemas/MemberCompact"
},
"access_level": {
"description": "Whether the member has admin, editor, or user access to the custom field.",
"type": "string",
"enum": [
"admin",
"editor",
"user"
],
"readOnly": true,
"example": "admin"
}
}
},
"CustomTypeMembershipCompact": {
"description": "This object describes a user or team's membership to a custom type including their level of access (Admin, Editor, User, or Viewer).",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "custom_type_membership",
"x-insert-after": "gid"
},
"resource_subtype": {
"description": "Type of the membership.",
"type": "string",
"example": "custom_type_membership"
},
"parent": {
"description": "The custom type the user or team is a member of.",
"$ref": "#/components/schemas/CustomTypeCompact"
},
"member": {
"description": "Member can be a user or a team.",
"$ref": "#/components/schemas/MemberCompact"
},
"access_level": {
"description": "Whether the member has admin, editor, user, or viewer access to the custom type.",
"type": "string",
"enum": [
"admin",
"editor",
"user",
"viewer"
],
"readOnly": true,
"example": "admin"
}
}
},
"ProjectMembershipCompact": {
"description": "This object describes a team or a user's membership to a project including their level of access (Admin, Editor, Commenter, or Viewer).",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "project_membership",
"x-insert-after": "gid"
},
"parent": {
"description": "[Opt In](/guides/platform/inputoutput-options). The project the user is a member of.",
"$ref": "#/components/schemas/ProjectCompact"
},
"member": {
"description": "Member can be a user or a team.",
"$ref": "#/components/schemas/MemberCompact"
},
"access_level": {
"description": "Whether the member has admin, editor, commenter, or viewer access to the project.",
"type": "string",
"enum": [
"admin",
"editor",
"commenter",
"viewer"
],
"readOnly": true,
"example": "admin"
}
}
},
"ProjectMembershipCompactResponse": {
"allOf": [
{
"$ref": "#/components/schemas/ProjectMembershipCompact"
},
{
"type": "object",
"properties": {
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"example": "membership"
},
"resource_subtype": {
"description": "Type of the membership.",
"type": "string",
"example": "project_membership"
}
}
}
]
},
"UserCompact": {
"description": "A *user* object represents an account in Asana that can be given access to various workspaces, projects, and tasks.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "user",
"x-insert-after": "gid"
},
"name": {
"type": "string",
"description": "*Read-only except when same user as requester*. The user's name.",
"example": "Greg Sanchez"
}
}
},
"WorkspaceCompact": {
"description": "A *workspace* is the highest-level organizational unit in Asana. All projects and tasks have an associated workspace.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"readOnly": true,
"example": "workspace",
"x-insert-after": "gid"
},
"name": {
"description": "The name of the workspace.",
"type": "string",
"example": "My Company Workspace"
}
}
},
"GoalMembershipBase": {
"description": "This object represents a user's connection to a goal.",
"type": "object",
"properties": {
"gid": {
"description": "Globally unique identifier of the resource, as a string.",
"type": "string",
"readOnly": true,
"example": "12345",
"x-insert-after": false
},
"resource_type": {
"description": "The base type of this resource.",
"type": "string",
"example": "membership"
},
"resource_subtype": {
"type": "string",
"readOnly": true,
"description": "The type of membership.",
"example": "goal_membership"
},
"member": {
"$ref": "#/components/schemas/MemberCompact"
},
"parent": {
"allOf": [
{
"$ref": "#/components/schemas/GoalCompact"
},
{
"type": "object",
"readOnly": true
}
]
},
"role": {
"type": "string",
"description": "*Deprecated: Describes if the member is a commenter or editor in goal.*",
"enum": [
"commenter",
"editor"
],
"deprecated": true,
"example": "editor"
},
"access_level": {
"type": "string",
"description": "\"Describes the membership access level for the goal. This is preferred over role.\"",
"enum": [
"viewer",
"commenter",
"editor",
"admin"
],
"example": "editor"
},
"goal": {
"allOf": [
{
"$ref": "#/components/schemas/GoalCompact"
},
{
"type": "object",
"readOnly": true,
"deprecated": true,
"description": "*Deprecated: new integrations should prefer the `parent` field.* A *Goal* is an object in the goal-tracking system that helps your organization drive measurable results."
}
]
}
}
},
"GoalMembershipResponse": {
"allOf": [
{
"$ref": "#/components/schemas/GoalMembershipBase"
},
{
"type": "object",
"properties": {
"user": {
"allOf": [
{
"$ref": "#/components/schemas/UserCompact"
},
{
"type": "object",
"deprecated": true,
"readOnly": true,
"description": "*Deprecated: new integrations should prefer the `member` field.* A *user* object represents an account in Asana that can be given access to various workspaces, projects, and tasks."
}
]
},
"workspace": {
"allOf": [
{
"$ref": "#/components/schemas/WorkspaceCompact"
},
{
"type": "object",
"deprecated": true,
"readOnly": true,
"description": "*Deprecated:* A *workspace* is the highest-level organizational unit in Asana. All projects and tasks have an associated workspace."
}
]
}
}
}
]
},
"MembershipRequest": {
"type": "object",
"properties": {
"access_level": {
"description": "Sets the access level for the member. Goals can have access levels `viewer`, `commenter`, `editor` or `admin`. Projects can have access levels `admin`, `editor` or `commenter`. Portfolios can have access levels `admin`, `editor` or `viewer`. Custom Fields can have access levels `admin`, `editor` or `user`.",
"type": "string",
"example": "editor"
}
}
},
"CreateMembershipRequest": {
"allOf": [
{
"$ref": "#/components/schemas/MembershipRequest"
},
{
"type": "object",
"properties": {
"member": {
"description": "The gid of the user or team.",
"type": "string",
"example": 12345
},
"parent": {
"description": "The gid of the `goal`, `project`, or `portfolio` to add the member to.",
"type": "string",
"example": "987654"
},
"role": {
"description": "*Deprecated: new integrations should use access_level* The role given to the member. Optional argument, will default to `commenter` for goals and the default project role for projects. Can be `editor` or `commenter` for goals. Can be `admin`,`editor` or `commenter` for projects.",
"type": "string",
"deprecated": true,
"example": "editor"
}
}
}
]
},
"MembershipResponse": {
"anyOf": [
{
"$ref": "#/components/schemas/GoalMembershipResponse"
},
{
"$ref": "#/components/schemas/ProjectMembershipCompactResponse"
},
{
"$ref": "#/components/schemas/PortfolioMembershipCompact"
},
{
"$ref": "#/components/schemas/CustomFieldMembershipCompact"
},
{
"$ref": "#/components/schemas/CustomTypeMembershipCompact"
}
]
}
},
"securitySchemes": {
"personalAccessToken": {
"type": "http",
"description": "A personal access token allows access to the api for the user who created it. This should be kept a secret and be treated like a password.",
"scheme": "bearer"
},
"oauth2": {
"type": "oauth2",
"description": "We require that applications designed to access the Asana API on behalf of multiple users implement OAuth 2.0.\nAsana supports the Authorization Code Grant flow.",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://app.asana.com/-/oauth_authorize",
"tokenUrl": "https://app.asana.com/-/oauth_token",
"refreshUrl": "https://app.asana.com/-/oauth_token",
"scopes": {
"default": "Provides access to all endpoints documented in our API reference. If no scopes are requested, this scope is assumed by default.",
"openid": "Provides access to OpenID Connect ID tokens and the OpenID Connect user info endpoint.",
"email": "Provides access to the user’s email through the OpenID Connect user info endpoint.",
"profile": "Provides access to the user’s name and profile photo through the OpenID Connect user info endpoint.",
"attachments:read": "View access to attachments",
"attachments:write": "Create and modify access to attachments",
"attachments:delete": "Delete access to attachments",
"custom_fields:read": "View access to custom fields",
"custom_fields:write": "Create and modify access to custom fields",
"goals:read": "View access to goals",
"jobs:read": "View access to jobs",
"ooo_entries:read": "View access to OOO entries",
"ooo_entries:write": "Create and modify access to OOO entries",
"ooo_entries:delete": "Delete access to OOO entries",
"tasks:read": "View access to tasks",
"tasks:write": "Create and modify access to tasks",
"tasks:delete": "Delete access to tasks",
"task_custom_types:read": "View access to task custom types",
"task_templates:read": "View access to task templates",
"team_memberships:read": "View access to team memberships",
"portfolios:read": "View access to portfolios",
"portfolios:write": "Create and modify access to portfolios",
"project_templates:read": "View access to project templates",
"project_portfolio_settings:read": "View access to project portfolio settings",
"project_portfolio_settings:write": "Create and modify access to project portfolio settings",
"projects:delete": "Delete access to projects",
"projects:read": "View access to projects",
"projects:write": "Create and modify access to projects",
"roles:read": "View access to roles",
"roles:write": "Create and modify access to roles",
"roles:delete": "Delete access to roles",
"users:read": "View access to users",
"teams:read": "View access to teams",
"time_tracking_categories:read": "View access to time tracking categories",
"time_tracking_categories:write": "Create and modify access to time tracking categories",
"time_tracking_categories:delete": "Delete access to time tracking categories",
"time_tracking_entries:read": "View access to time tracking entries",
"timesheet_approval_statuses:read": "View access to timesheet approval statuses",
"timesheet_approval_statuses:write": "Create and modify access to timesheet approval statuses",
"stories:read": "View access to stories",
"stories:write": "Create and modify access to stories",
"tags:read": "View access to tags",
"tags:write": "Create and modify access to tags",
"webhooks:read": "View access to webhooks",
"webhooks:write": "Create and modify access to webhooks",
"webhooks:delete": "Delete access to webhooks",
"workspaces:read": "View access to workspaces"
}
}
}
}
}
},
"paths": {
"/memberships": {
"parameters": [
{
"$ref": "#/components/parameters/pretty"
}
],
"post": {
"summary": "Create a membership",
"description": "Creates a new membership in a `goal`, `project`, `portfolio`, `custom_type`, or `custom_field`, where members can be Teams or Users.\n\nReturns the full record of the newly created membership.",
"tags": [
"Memberships"
],
"operationId": "createMembership",
"requestBody": {
"description": "The updated fields for the membership.",
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"$ref": "#/components/schemas/CreateMembershipRequest"
}
}
}
}
}
},
"responses": {
"201": {
"description": "Successfully created the requested membership.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "object",
"$ref": "#/components/schemas/MembershipResponse"
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"$ref": "#/components/responses/NotFound"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
}
},
"security": [
{
"personalAccessToken": []
},
{
"oauth2": []
}
],
"x-readme": {
"code-samples": [
{
"language": "node",
"install": "npm install asana",
"code": "const Asana = require('asana');\n\nlet client = new Asana.ApiClient();\nclient.authentications.token.accessToken = '<YOUR_ACCESS_TOKEN>';\n\nlet membershipsApiInstance = new Asana.MembershipsApi(client);\nlet opts = { \n 'body': {\"data\": {\"<PARAM_1>\": \"<VALUE_1>\", \"<PARAM_2>\": \"<VALUE_2>\",}}\n};\nmembershipsApiInstance.createMembership(opts).then((result) => {\n console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));\n}, (error) => {\n console.error(error.response.body);\n});",
"name": "node-sdk-v3"
},
{
"language": "node",
"install": "npm install asana@1.0.5",
"code": "const asana = require('asana');\n\nconst client = asana.Client.create().useAccessToken('PERSONAL_ACCESS_TOKEN');\n\nclient.memberships.createMembership({field: \"value\", field: \"value\", pretty: true})\n .then((result) => {\n console.log(result);\n });",
"name": "node-sdk-v1"
},
{
"language": "python",
"install": "pip install asana",
"code": "import asana\nfrom asana.rest import ApiException\nfrom pprint import pprint\n\nconfiguration = asana.Configuration()\nconfiguration.access_token = '<YOUR_ACCESS_TOKEN>'\napi_client = asana.ApiClient(configuration)\n\n# create an instance of the API class\nmemberships_api_instance = asana.MembershipsApi(api_client)\nopts = {\n 'body': {\"data\": {\"<PARAM_1>\": \"<VALUE_1>\", \"<PARAM_2>\": \"<VALUE_2>\",}}, # dict | The updated fields for the membership.\n}\n\ntry:\n # Create a membership\n api_response = memberships_api_instance.create_membership(opts)\n pprint(api_response)\nexcept ApiException as e:\n print(\"Exception when calling MembershipsApi->create_membership: %s\\n\" % e)",
"name": "python-sdk-v5"
},
{
"language": "python",
"install": "pip install asana==3.2.3",
"code": "import asana\n\nclient = asana.Client.access_token('PERSONAL_ACCESS_TOKEN')\n\nresult = client.memberships.create_membership({'field': 'value', 'field': 'value'}, opt_pretty=True)",
"name": "python-sdk-v3"
},
{
"language": "php",
"install": "composer require asana/asana",
"code": "<?php\nrequire 'vendor/autoload.php';\n\n$client = Asana\\Client::accessToken('PERSONAL_ACCESS_TOKEN');\n\n$result = $client->memberships->createMembership(array('field' => 'value', 'field' => 'value'), array('opt_pretty' => 'true'))"
},
{
"language": "ruby",
"install": "gem install asana",
"code": "require 'asana'\n\nclient = Asana::Client.new do |c|\n c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN'\nend\n\nresult = client.memberships.create_membership(field: \"value\", field: \"value\", options: {pretty: true})"
}
]
}
}
}
}
}