> This page is for Developer.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.bigcommerce.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.bigcommerce.com/_mcp/server.

# Create Company User

POST https://api-b2b.bigcommerce.com/api/v3/io/users
Content-Type: application/json

Create a Company user within an existing Company.

With [Independent Company behavior](/developer/api-reference/rest/b2b/management/company/companies#independent-vs-dependent-companies-behavior) enabled, B2B Edition Company accounts are the source of truth for defining a Company user’s customer group assignment.

On stores without Independent Company behavior, each Company account has a one-to-one relationship with its customer group.

If no default customer group is configured, or the set value of `customerGroupId` is 0, the B2B Company will not be associated with any customer group. The Company users will have their corresponding customer records assigned to No Group in BigCommerce.

Reference: https://docs.bigcommerce.com/developer/api-reference/rest/b2b/management/users/companies-users-create

## Authentication

- `X-Auth-Token` header (required) — | Header | Argument | Description | |:-------|:---------|:------------| | `X-Auth-Token` | `access_token` | For more about API accounts that generate `access_token`s, see our [Guide to API Accounts](/developer/docs/overview/api-fundamentals/api-accounts). | For example requests and more information about authenticating BigCommerce APIs, see [Authentication and Example Requests](/developer/docs/overview/api-fundamentals/api-accounts#x-auth-token-header-example-requests). For more about BigCommerce OAuth scopes, see our [Guide to API Accounts](/developer/docs/overview/api-fundamentals/api-accounts#oauth-scopes). For a list of API status codes, see [API Status Codes](/developer/api-reference/rest/overview#rest-http-status-codes).
- `X-Store-Hash` header (required) — | Header | Argument | Description | |:-------|:---------|:------------| | `X-Store-Hash` | `store_hash` | The unique store hash associated with a BigCommerce store that has B2B Edition enabled. |

## Request

### Body (application/json)

This endpoint expects an userPost.

- `firstName` (string, required) — User's first name.
- `lastName` (string, required) — User's last name.
- `email` (string, required) — User's email address. This must be unique within B2B Edition.
- `role` (enum, required) — Numeric code representing the user's role as admin (`0`), senior buyer (`1`), or junior buyer (`2`).
  - Allowed values: `0`, `1`, `2`
- `companyId` (integer, required) — The unique numeric ID associated with the user's B2B Edition Company account.
- `channelIds` (list of integer, required) — List of numeric channel IDs the user is associated with. These represent the storefront channels the user can log in to and do business.
- `phoneNumber` (string, optional) — User's phone number.
- `companyRoleId` (integer, optional) — Numeric code representing the user's Company-specific role. When present this field overrides the value of the `role` field.
- `uuid` (string, optional) — External identifier for the user. This field may be used to represent any external user ID. Using the name `uuid`, B2B Edition does not require the field to be unique.
- `extraFields` (list of extraField, optional)
- `acceptWelcomeEmail` (boolean, optional) — Indicates whether the user will receive a welcome email when the account is created.
- `originChannelId` (integer, optional) — The ID of the originating channel. A value of `0` will unset the user's origin channel, which may result in unexpected behavior. To avoid errors, ensure all necessary channels are included in `channelIds`.

## Response

### 200

SUCCESS

- `code` (integer, optional, default: 200) — Operation status code.
- `data` (newIds, optional)
- `meta` (UsersPostResponsesContentApplicationJsonSchemaMeta, optional)

## Errors

### 422 Unprocessable Entity Error

Validation Error This error returns when one or more fields are invalid or if the email address provided already exists as a B2B Edition user.

- `code` (integer, optional, default: 422) — Operation status code.
- `data` (UsersPostResponsesContentApplicationJsonSchemaData, optional) — The content and explanation of the error(s) associated with the request. The format of this field depends on what errors are present.
- `meta` (UsersPostResponsesContentApplicationJsonSchemaMeta, optional)

## Types

### extraField

- `fieldName` (string, optional) — The name of the extra field displayed in B2B Edition.
- `fieldValue` (string, optional) — The user-specific value of the extra field.

### newIds

- `userId` (integer, optional) — The unique numeric identifier associated with the B2B Edition user account.
- `bcId` (integer, optional) — The unique numeric identifier associated with the BigCommerce customer account corresponding to the B2B Edition user account.

### UsersPostResponsesContentApplicationJsonSchemaMeta

- `message` (string, optional) — Human-readable status message.

### UsersPostResponsesContentApplicationJsonSchemaData

The content and explanation of the error(s) associated with the request. The format of this field depends on what errors are present.

- `errMsg` (errMsgPost, optional)

### errMsgPost

### Missing Required Fields

An unordered list of missing required fields. Fields will only be included in this list if they are missing from the request.

- `firstName` (list of string, optional)
- `lastName` (list of string, optional)
- `email` (list of string, optional)
- `companyId` (list of string, optional)

### Missing Role

A message indicating missing data not explicitly required for creation, but without which validation fails.

- `non_field_errors` (list of string, optional)

### Invalid Data

- `email` (list of string, optional)
- `role` (list of string, optional)

## Examples

**Request**

```json
{
  "firstName": "Marie",
  "lastName": "Curie",
  "email": "marie.curie@example.com",
  "role": 1,
  "companyId": 42,
  "channelIds": [
    101,
    202
  ]
}
```

**Response**

```json
{
  "code": 200,
  "data": {
    "userId": 34567,
    "bcId": 78901
  },
  "meta": {
    "message": "Success"
  }
}
```

**SDK Code**

```python Users_companies_users_create_example
import requests

url = "https://api-b2b.bigcommerce.com/api/v3/io/users"

payload = {
    "firstName": "Marie",
    "lastName": "Curie",
    "email": "marie.curie@example.com",
    "role": 1,
    "companyId": 42,
    "channelIds": [101, 202]
}
headers = {
    "X-Auth-Token": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Users_companies_users_create_example
const url = 'https://api-b2b.bigcommerce.com/api/v3/io/users';
const options = {
  method: 'POST',
  headers: {'X-Auth-Token': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"firstName":"Marie","lastName":"Curie","email":"marie.curie@example.com","role":1,"companyId":42,"channelIds":[101,202]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Users_companies_users_create_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-b2b.bigcommerce.com/api/v3/io/users"

	payload := strings.NewReader("{\n  \"firstName\": \"Marie\",\n  \"lastName\": \"Curie\",\n  \"email\": \"marie.curie@example.com\",\n  \"role\": 1,\n  \"companyId\": 42,\n  \"channelIds\": [\n    101,\n    202\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Auth-Token", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Users_companies_users_create_example
require 'uri'
require 'net/http'

url = URI("https://api-b2b.bigcommerce.com/api/v3/io/users")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Auth-Token"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"firstName\": \"Marie\",\n  \"lastName\": \"Curie\",\n  \"email\": \"marie.curie@example.com\",\n  \"role\": 1,\n  \"companyId\": 42,\n  \"channelIds\": [\n    101,\n    202\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Users_companies_users_create_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-b2b.bigcommerce.com/api/v3/io/users")
  .header("X-Auth-Token", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"firstName\": \"Marie\",\n  \"lastName\": \"Curie\",\n  \"email\": \"marie.curie@example.com\",\n  \"role\": 1,\n  \"companyId\": 42,\n  \"channelIds\": [\n    101,\n    202\n  ]\n}")
  .asString();
```

```php Users_companies_users_create_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-b2b.bigcommerce.com/api/v3/io/users', [
  'body' => '{
  "firstName": "Marie",
  "lastName": "Curie",
  "email": "marie.curie@example.com",
  "role": 1,
  "companyId": 42,
  "channelIds": [
    101,
    202
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Auth-Token' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Users_companies_users_create_example
using RestSharp;

var client = new RestClient("https://api-b2b.bigcommerce.com/api/v3/io/users");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Auth-Token", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"firstName\": \"Marie\",\n  \"lastName\": \"Curie\",\n  \"email\": \"marie.curie@example.com\",\n  \"role\": 1,\n  \"companyId\": 42,\n  \"channelIds\": [\n    101,\n    202\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Users_companies_users_create_example
import Foundation

let headers = [
  "X-Auth-Token": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "firstName": "Marie",
  "lastName": "Curie",
  "email": "marie.curie@example.com",
  "role": 1,
  "companyId": 42,
  "channelIds": [101, 202]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-b2b.bigcommerce.com/api/v3/io/users")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```