REST API - Company Management

Plan: B2B Developer

Lesson 9 of 19 · 30 min

Get a List of Company Accounts

Example request:

GET https://api-b2b.bigcommerce.com/api/v3/io/companies

Update a Company Status

Example request:

PUT https://api-b2b.bigcommerce.com/api/v3/io/companies/{companyId}/status

Example body:

{
"companyStatus": 1
}

You will need to know the companyId, which can be found by running a GET all companies request. You will also need to know the account’s new status and the correct status code which can be found below:

  • Pending: 0
  • Approved: 1
  • Rejected: 2
  • Inactive: 3
  • Deleted: 4

Creating Company Accounts

Example request:

POST https://api-b2b.bigcommerce.com/api/v3/io/companies

Example body:

{
"companyName": "V2 Test Company",
"companyPhone": "111-222-3333",
"companyEmail": "email@company.com",
"addressLine1": "987 Park Place",
"city": "Austin",
"state": "Texas",
"country": "United States",
"zipCode": "78726",
"adminFirstName": "John",
"adminLastName": "Foo",
"adminEmail": "email@company.com",
"adminPhoneNumber": "222-333-4444",
"customerGroupId": 4,
"channelIds": [1]
}

Required fields:

  • companyName
  • companyPhone
  • companyEmail
  • country - full name of the country or ISO2 country code
  • adminFirstName
  • adminLastName
  • adminEmail

You can use the customerGroupId field to assign a customer group to the new company. If the customerGroupId field is not provided, the company will be associated with the default customer group you have configured. If there is no default customer group, the customerGroupId value will be set to 0 and the company will not be associated with any customer group.

There are more fields that can be filled in when creating a company account if you have the correct information, see B2B Edition Create a Company reference.

You can also create multiple companies in one API call by using the bulk endpoint. For more information, see the B2B Edition Bulk Company Creation API reference.

If you are on an older version of B2B Edition, Companies will already have an assigned customerGroupId.

Updating Company Information

Example request:

PUT https://api-b2b.bigcommerce.com/api/v3/io/companies/{companyId}

Example body:

{
"companyName": "{Your company name}",
"companyEmail": "{Your email address}",
"companyPhone": "{Company phone number}",
"addressLine1": "{Company address}",
"city": "{Your city}",
"state": "{Your state}",
"country": "{Your country}",
"zipCode": "{Your zip code}"
}

The request will return a confirmation of the companyId.

Get a List of Addresses

The following request will return a list of addresses.

Example request:

GET https://api-b2b.bigcommerce.com/api/v3/io/addresses

Filtering

This request can be filtered to narrow the results. The following filters are applicable for this request:

  • companyId
  • isBilling
  • isShipping
  • address
  • city
  • state
  • country
  • zipcode

The query below is an example of how you can filter a list of addresses by companyId and shipping address.

Example request:

GET https://api-b2b.bigcommerce.com/api/v3/io/addresses?companyId={{company_id}}&isShipping=true

Create a Company Address

The following request will create a new address.

Example request:

POST https://api-b2b.bigcommerce.com/api/v3/io/companies

For the request body, there are several fields required to create a new address such as:

  • addressLine1
  • city
  • firstName
  • lastName
  • companyId
  • countryName
  • countryCode

Below is an example of the request body. You will need to include company-specific information for each of the required fields.

Example body:

{
"addressLine1": "321 Park Place",
"addressLine2": "Ste 3",
"city": "Austin",
"stateCode": "TX",
"countryCode": "US",
"zipCode": "78726",
"firstName": "Jane",
"lastName": "Foo",
"isBilling": true,
"isDefaultBilling": true,
"isShipping": true,
"isDefaultShipping": true,
"phoneNumber": "888-777-6666",
"companyId": {{company_id}},
"label": "Main Address"
}

Get a List of Users

The following request URL will return a list of users that have accounts on your B2B Edition storefront.

Example request:

GET https://api-b2b.bigcommerce.com/api/v3/io/users

This is another request that allows you to use filters to narrow the results. Some common filters include:

  • companyId
  • roles: 0 = admin user, 1 = senior buyer, 2 = junior buyer

The example below shows a request URL for company users for a specific company.

Example request:

GET https://api-b2b.bigcommerce.com/api/v3/io/users?companyId={{company_id}}

Create a User

The following request URL can be used to create a new user. If the user is an existing BigCommerce customer, the customer group, company, and name will be overridden.

Example request:

POST https://api-b2b.bigcommerce.com/api/v3/io/users

The required fields for the request body include:

  • companyId
  • email
  • firstName
  • lastName
  • role: 0 = admin, 1 = senior buyer, 2 = junior buyer
  • companyRoleId

While the role field utilizes static integer values, the companyRoleId field supports all possible roles, expecting an ID value corresponding to a role. The built-in Admin, Senior Buyer, and Junior Buyer roles also have IDs compatible with companyRoleId as well, so it’s possible to use this field instead of role to manage built-in roles. You can find role IDs with the Company Roles endpoint.

Example using static role:

{
"companyId": {{company_id}},
"channelIds": [1],
"email": "email@company.com",
"firstName": "Jack",
"lastName": "Foo",
"phoneNumber": "444-777-9999",
"role": 2
}

Example using companyRoleId:

{
"companyId": {{company_id}},
"channelIds": [1],
"email": "email@company.com",
"firstName": "Jack",
"lastName": "Foo",
"phoneNumber": "444-777-9999",
"companyRoleId": 11223
}

B2B Edition company accounts are the source of truth for defining a company user’s customer group assignment. If there is no default customer group, the company will not be associated with any customer group.

Company users can also be created in bulk when needed. See the Bulk User Creation API reference for more information.

Resources