Create company/account memberships
This topic describes how you can perform various primary membership tasks for companies and accounts using APIs.
Account memberships represent the link between users and accounts in the AppDirect platform and provide the context under which user actions are performed and authorized. Authorization is determined by specifying the roles that users have within the account, which define what each user can do.
Create a company membership (REST)
Company memberships represent the link between users and companies on the AppDirect platform and provide the context under which user actions are performed and authorized. All users and companies must have at least one membership associated with them.
When you create a company membership, a new user account is also created if no user exists with the given email address. The allowLogin
body parameter determines whether to invite the user to the company (true
) or to create a managed user without login access or email notifications (false
). If the user is invited, the membership remains in a pending activation state until the user activates their account.
Use the following POST
request to create a company membership.
POST https://{marketplaceUrl}/api/account/v2/companies/{companyUuid}/memberships
See the Create company membership API reference for details on authorization rules and the complete list of supported request body and query parameters. Request
{
"user": {
"allowLogin": true,
"email": "mary.gonsalez@example.com",
"firstName": "Mary",
"lastName": "Gonsalez"
},
"roles": [
"ROLE_USER"
]
}
Create an account membership (GraphQL)
The first membership of a given account is created at the time that the account itself is created. You can associate more users with an account by creating new account memberships.
Two mutations can be used to create a new account membership. These mutations are equivalent to the REST APIs Create company membership and Create company membership (Add User).
- createAccountMembership - creates a new account membership that links a user (determined by email address) with an existing account (identified by the account uuid). The specified user is assigned membership in the account and receives an activation notice. If the user does not exist, a new user with the specified email address is created. With the
sendInvitation
field, you can specify whether the user will be sent an invitation, or activated automatically. You can set this field to false if the user does not have login access. If the user is invited, the membership remains in a pending activation state until the user activates their account. - createAccountMembershipWithPassword - creates a new account membership for a new user with a temporary password. The password is emailed to the recipient specified in the request body. This means that the new user has login access to the marketplace. The new user is automatically invited to join the marketplace.
When creating an account membership, you identify the user by email. If no user with that email address exists in the marketplace, a new user is created.
Both of these mutations return the new AccountMembership
object as the payload. An account membership does not have an identifier of its own. Mutations and queries that use or refer to an account membership must identify it using the unique identifiers for both the account and the user.
The user in a new account membership is assigned the USER role by default if no other role is specified. You can modify roles after the user has been created by changing the role or adding more roles. For more information, see Update account memberships.
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!