REST API - Company Settings
Roles and Permissions
GET All Roles
To get a list of all available company roles for your store, run the following request.
Example Request:
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:
The required fields for this request include the following:
name- the role namepermissions- submitted as an array if there are multiple permissions to be assigned to the new custom rolecode- 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:
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 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:
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:
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:
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:
GET Company Payment Terms
The request URL below will return a list of the payment term configurations for a company account.
Example Request:
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:
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: