Skip to main content

Create new companies for existing users

In a marketplace, every user is associated with a company. However, there may be instances where a user needs to be associated with multiple companies. The platform has a limitation where once a user is part of a company, they cannot create a second company using the same email address.

Create a company

To create a company for an existing user, perform the following:

Example: A user with the email john.smith@company.com already exists in the marketplace, and now a new company should be created for the same user.

  1. Authenticate to the marketplace using the authentication API.

  2. Create a new company using another email address or the current user's email address using an alias.

    REST example

    POST /account/v2/companies

    {
    "countryCode": "US",
    "emailAddress": "xyz@company.com",
    "firstUser": {
    "email": "john.smith+1@company.com",
    "firstName": "John",
    "lastName": "Smith",
    "roles": [
    "ROLE_SYS_ADMIN"
    ]
    },
    "name": "Company Example"
    }

    GraphQL example (preview)

    mutation createAccount($input: CreateAccountInput!) {
    createAccount(input: $input) {
    account {
    id
    name
    status
    accessTypes
    }
    userErrors
    }
    }

    variables:
    {
    "input": {
    "name": "Company Example",
    "countryCode": "US",
    "firstUser": {
    "firstName": "John",
    "lastName": "Smith",
    "email": "john.smith+1@company.com",
    "roles": ["ROLE_SYS_ADMIN"]
    }
    }
    }

3. Activate the new company.
4. Add existing user john.smith@company.com to the newly created company.

**REST example**

```json
POST /account/v2/companies/{companyUuid}/memberships

{
"roles": [
"ROLE_SYS_ADMIN"
],
"user": {
"email": "john.smith@company.com"
}
}

GraphQL example (preview)

mutation createAccountMembership($input: CreateAccountMembershipInput!) {
createAccountMembership(input: $input) {
accountMembership {
user {
id
createdOn
email
}
account {
id
name
status
accessTypes
}
}
}
}

variables:
{
"input": {
"accountId": 34827
"roles": ["ROLE_SYS_ADMIN"],
"email": "john.smith@company.com"
}
}
  1. Accept the invitation email.

  2. Remove previously created user (john.smith+1@company.com in this instance) from the company.

    REST example

    DELETE /account/v2/companies/{companyUuid}/memberships/{userUuid}

    GraphQL example (preview)

    mutation deleteAccountMembership($input: DeleteAccountMembershipInput!) {
    deleteAccountMembership(input: $input) {
    success
    }
    }

    variables:
    {
    "input": {
    "accountId": 34827,
    "userId": 34827
    }
    }

Was this page helpful?