> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# CreateAccountAsCollaborator

# Package: accounts

# Namespace: AccountService

# Method link: https://dev.wix.com/docs/api-reference/account-level/accounts/create-account-as-collaborator.md

## Introduction

Creates a new Wix account with a user as the account owner and immediately assigns the account as a collaborator on a specified site with defined roles.

This method combines account creation, user registration, and site collaboration assignment in a single operation. The newly created account becomes a child account of the requesting account, establishing a parent-child relationship that allows for centralized management and inherited configurations like custom branding.

> **Important**: This call requires an account level API key.

---

## REST API

### Schema

```
 Method: createAccountAsCollaborator
 Description: Creates a new Wix account with a user as the account owner and immediately assigns the account as a collaborator on a specified site with defined roles.  This method combines account creation, user registration, and site collaboration assignment in a single operation. The newly created account becomes a child account of the requesting account, establishing a parent-child relationship that allows for centralized management and inherited configurations like custom branding.  > **Important**: This call requires an account level API key.
 URL: https://www.wixapis.com/accounts/v1/accounts/create-as-collaborator
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  user, siteId, collaboratorRoles
 Method parameters: 
   param name: collaboratorRoles | type: array<collaboratorRoles> | description: Role GUIDs to assign to the account for the specified site. These roles define the collaborator's permissions and access level on the site. To retrieve available roles, call [Get Roles Info](https://dev.wix.com/docs/api-reference/account-level/user-management/accounts/users/get-roles-info.md). Minimum: 1 role, Maximum: 5 roles. | required: true | validation: minItems 1, maxItems 5, maxLength 100
   param name: parentAsOwner | type: ParentAsOwnerWithRoles    
        - name: userRoles | type: array<string> | description: Role GUIDs for the user (team member) on the created account. At least one required when using parent-as-owner flow.  | validation: minItems 1, maxItems 5, maxLength 100
   param name: siteId | type: siteId | description: Site GUID where the created account will be assigned as a collaborator. The site must exist and the requesting account must have permission to add collaborators to this site. | required: true | validation: format GUID
   param name: useExistingAccount | type: useExistingAccount | description: Whether to assign the existing child account as the collaborator, if one already exists for the specified email address.  
   param name: user | type: User | description: A User to be created under an implicitly provided accountId: must have a unique email. | required: true 
        - name: email | type: Email | description: User's unique email address details. Required.  
           - name: emailAddress | type: string | description: User's email address.  | validation: format EMAIL
           - name: isVerified | type: boolean | description: Whether the caller has verified the user's email address.  
        - name: ssoIdentities | type: array<SsoIdentity> | description: User's single sign on identity, when the user is identified via SSO authentication response token params, as specified by [OpenGUID Connect](https://openid.net/developers/how-connect-works/) (aka. OIDC) protocol.  
           - name: ssoId | type: string | description: An SSO setting (URLs, clientId, secret, etc. as required by OIDC protocol) for a specific Identity-Provider (aka. IdP) for a specific Wix account.  
           - name: userId | type: string | description: User GUID as stored in IdP. For example a "sub" claim of OIDC protocol, or any other alternative, specified by IdP (Identity Provider).  
        - name: userDetails | type: UserDetails | description: Additional user details.  
           - name: firstName | type: string | description: User's first name.  | validation: maxLength 64
           - name: lastName | type: string | description: User's last name.  | validation: maxLength 64
           - name: profilePictureUrl | type: string | description: URL to location of user's profile picture.  | validation: format WEB_URL
           - name: language | type: string | description: User's preferred language in [ISO 639-1:2002](https://en.wikipedia.org/wiki/ISO_639-1) format. For example, "en", "es".  | validation: maxLength 2
           - name: clientIp | type: string | description: Original Client IP from which a request was made. This is useful in case where a createUser API is called by some server call, which, in turn, has been called by some client from another IP. Wix checks this IP against the [OFAC sanctioned countries](https://ofac.treasury.gov/sanctions-programs-and-country-information).  
           - name: contactEmail | type: string | description: if defined then emails to the user will be sent to this email instead of the user's primary email  | validation: format EMAIL
 Return type: CreateAccountAsCollaboratorResponse
  - name: account | type: AccountV2 | description: Created account. When parent_as_owner was omitted, the user from the request is the account owner. When parent_as_owner was set, the parent account's owner is the account owner and the user was added as a team member. This account is a child of the requesting account and inherits applicable configurations.  
     - name: accountId | type: string | description: Account GUID.  | validation: format GUID
  - name: assignedCollaboratorRoles | type: array<SiteRoleAssignment> | description: Site role assignments for each requested collaborator role.  
     - name: assignmentId | type: string | description: Unique identifier mapping the role to the contributor on the site.  | validation: maxLength 100
     - name: roleId | type: string | description: Role GUID that was successfully assigned to the account for the site.  | validation: maxLength 100


```

### Examples

### Create Account As Collaborator
```curl
curl -X POST \
'https://www.wixapis.com/accounts/v1/accounts/create-as-collaborator' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-d '{
      "user": {
        "ssoIdentities": [
          {
            "ssoId": "b2a01868-3438-44a3-b6ad-3f1ea47ea6b0",
            "userId": "73d3dcf3-afba-423d-86e0-c8d3d04b99b8"
          }
        ],
        "email": {
          "isVerified": true,
          "emailAddress": "collaborator@example.com"
        },
        "userDetails": {
          "firstName": "John",
          "lastName": "Collaborator",
          "profilePictureUrl": "https://example.com/profile.jpg",
          "clientIp": "192.168.1.100",
          "language": "en"
        }
      },
      "siteId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "collaboratorRoles": [
        "website_manager_role_id",
        "content_editor_role_id"
      ],
      "parentAsOwner": {
        "userRoles": [
          "member_role_id"
        ]
      }
    }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.userManagement.accounts.createAccountAsCollaborator(user, options)
 Description: Creates a new Wix account with a user as the account owner and immediately assigns the account as a collaborator on a specified site with defined roles.  This method combines account creation, user registration, and site collaboration assignment in a single operation. The newly created account becomes a child account of the requesting account, establishing a parent-child relationship that allows for centralized management and inherited configurations like custom branding.  > **Important**: This call requires an account level API key.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  user, options.siteId, options.collaboratorRoles, options
 Method parameters: 
   param name: options | type: CreateAccountAsCollaboratorOptions  none | required: true 
        - name: siteId | type: string | description: Site GUID where the created account will be assigned as a collaborator. The site must exist and the requesting account must have permission to add collaborators to this site. | required: true | validation: format GUID
        - name: collaboratorRoles | type: array<string> | description: Role GUIDs to assign to the account for the specified site. These roles define the collaborator's permissions and access level on the site. To retrieve available roles, call [Get Roles Info](https://dev.wix.com/docs/api-reference/account-level/user-management/accounts/users/get-roles-info.md). Minimum: 1 role, Maximum: 5 roles. | required: true | validation: minItems 1, maxItems 5, maxLength 100
        - name: useExistingAccount | type: boolean | description: Whether to assign the existing child account as the collaborator, if one already exists for the specified email address.  
        - name: parentAsOwner | type: ParentAsOwnerWithRoles | description: When omitted: user in request is account owner. When set: parent account's owner is account owner; user in request is team member with user_roles.  
           - name: userRoles | type: array<string> | description: Role GUIDs for the user (team member) on the created account. At least one required when using parent-as-owner flow.  | validation: minItems 1, maxItems 5, maxLength 100
   param name: user | type: User | description: A User to be created under an implicitly provided accountId: must have a unique email. | required: true 
        - name: email | type: Email | description: User's unique email address details. Required.  
           - name: emailAddress | type: string | description: User's email address.  | validation: format EMAIL
           - name: isVerified | type: boolean | description: Whether the caller has verified the user's email address.  
        - name: ssoIdentities | type: array<SsoIdentity> | description: User's single sign on identity, when the user is identified via SSO authentication response token params, as specified by [OpenGUID Connect](https://openid.net/developers/how-connect-works/) (aka. OIDC) protocol.  
           - name: ssoId | type: string | description: An SSO setting (URLs, clientId, secret, etc. as required by OIDC protocol) for a specific Identity-Provider (aka. IdP) for a specific Wix account.  
           - name: userId | type: string | description: User GUID as stored in IdP. For example a "sub" claim of OIDC protocol, or any other alternative, specified by IdP (Identity Provider).  
        - name: userDetails | type: UserDetails | description: Additional user details.  
           - name: firstName | type: string | description: User's first name.  | validation: maxLength 64
           - name: lastName | type: string | description: User's last name.  | validation: maxLength 64
           - name: profilePictureUrl | type: string | description: URL to location of user's profile picture.  | validation: format WEB_URL
           - name: language | type: string | description: User's preferred language in [ISO 639-1:2002](https://en.wikipedia.org/wiki/ISO_639-1) format. For example, "en", "es".  | validation: maxLength 2
           - name: clientIp | type: string | description: Original Client IP from which a request was made. This is useful in case where a createUser API is called by some server call, which, in turn, has been called by some client from another IP. Wix checks this IP against the [OFAC sanctioned countries](https://ofac.treasury.gov/sanctions-programs-and-country-information).  
           - name: contactEmail | type: string | description: if defined then emails to the user will be sent to this email instead of the user's primary email  | validation: format EMAIL
 Return type: PROMISE<CreateAccountAsCollaboratorResponse>
  - name: account | type: AccountV2 | description: Created account. When parent_as_owner was omitted, the user from the request is the account owner. When parent_as_owner was set, the parent account's owner is the account owner and the user was added as a team member. This account is a child of the requesting account and inherits applicable configurations.  
     - name: accountId | type: string | description: Account GUID.  | validation: format GUID
  - name: assignedCollaboratorRoles | type: array<SiteRoleAssignment> | description: Site role assignments for each requested collaborator role.  
     - name: assignmentId | type: string | description: Unique identifier mapping the role to the contributor on the site.  | validation: maxLength 100
     - name: roleId | type: string | description: Role GUID that was successfully assigned to the account for the site.  | validation: maxLength 100


```

### Examples

### createAccountAsCollaborator
```javascript
import { accounts } from '@wix/user-management';

async function createAccountAsCollaborator(user,options) {
  const response = await accounts.createAccountAsCollaborator(user,options);
};
```

### createAccountAsCollaborator (with elevated permissions)
```javascript
import { accounts } from '@wix/user-management';
import { auth } from '@wix/essentials';

async function myCreateAccountAsCollaboratorMethod(user,options) {
  const elevatedCreateAccountAsCollaborator = auth.elevate(accounts.createAccountAsCollaborator);
  const response = await elevatedCreateAccountAsCollaborator(user,options);
}
```

### createAccountAsCollaborator (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { accounts } from '@wix/user-management';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { accounts },
  // Include the auth strategy and host as relevant
});


async function createAccountAsCollaborator(user,options) {
  const response = await myWixClient.accounts.createAccountAsCollaborator(user,options);
};
```

---