REST API - Company Settings

Plan: B2B Developer

Lesson 10 of 19 · 30 min

Roles and Permissions

GET All Roles

To get a list of all available company roles for your store, run the following request.

Example Request:

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

The request will return a list of all the roles available for your store, including predefined and custom roles as the roleType. A value of 1 defines the role as a predefined role, and the value of 2 defines the role as a custom role.

roleLevel tells you that the role is a store-level role or another specified level. Right now, the only custom roles you can create are at the store level. There might be more levels in future releases of B2B Edition.

Create a Custom Role

You can use the API to create custom roles when needed with the following request URL.

Example Request:

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

The required fields for this request include the following:

  • name - the role name
  • permissions - submitted as an array if there are multiple permissions to be assigned to the new custom role
  • code - the permission code (for each permission submitted)
  • permissionLevel - this field defines scope of the permission. 1 = user level permission, 2 = company level permission

Permission Levels

User level permissions allow the buyer to only view or manage records associated with their own user account. Company level permissions allow the buyer to view or manage all permission-specific records in the account.

To get the information for permission fields, you might need to run a request to get all permissions (discussed later in this lesson).

Example Body:

{
"name": "Custom test 2",
"permissions": [
{
"code": "get_addresses",
"permissionLevel": 2
},
{
"code": "get_orders",
"permissionLevel": 1
},
{
"code": "get_quotes",
"permissionLevel": 2
}
]
}

GET Company Role Details

This request will return a list of permissions assigned to a specific company role. You will need the roleId of a specific role for this request.

Example Request:

GET https://api-b2b.bigcommerce.com/api/v3/io/companies/roles/{roleId}

GET All Permissions

This request will return a list of all company permissions that exist on your storefront. This list is not associated with roles.

Example Request:

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

Company Credit and Payment Terms

GET Company Credit

The request URL below will return a list of credit configurations for the company specified in the URL.

Example Request:

GET https://api-b2b.bigcommerce.com/api/v3/io/companies/{company_id}/credit

The response will tell you whether credit has been enabled for the company, the credit currency, the company’s available credit, if purchases are limited to the available credit, and whether there is a credit hold enabled for the company.

Updating Company Credit

The request URL below allows you to edit the credit configurations for a company account.

Example Request:

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

There are no required fields for the request body, but there needs to be at least one field of information in order for the request to be successful. If a company does not have credit enabled, other fields cannot be updated.

The request body below is an example of all the possible fields you can update.

Example Body:

{
"creditEnabled": true,
"creditCurrency": "USD",
"availableCredit": 1000.0,
"limitPurchases": false,
"creditHold": false
}

GET Company Payment Terms

The request URL below will return a list of the payment term configurations for a company account.

Example Request:

GET https://api-b2b.bigcommerce.com/api/v3/io/companies/{companyId}/payment-terms

The response will tell you if payment terms have been enabled for the company account and how many days the company will have to pay an invoice. If payment terms are disabled for a company account, the paymentTerms field will show the store default payment terms.

Update Company Payment Terms

The request URL below allows you to change a company’s payment terms.

Example Request:

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

There are only two fields for this request body: isEnabled tells you if payment terms are enabled for the specified company account, and paymentTerms is how many days a company has to pay an invoice.

Example Body:

{
"isEnabled": true,
"paymentTerms": 30
}

Resources