Retrieving Company User Information

The Company Account feature provided by Spryker Commerce OS allows corporate customers to create Company User Accounts for their employees. This capability enables customers to organize purchasing activities in their companies. Company Accounts are typically organized in Business Units depending on the job roles they perform. Any user can impersonate as multiple Company Accounts they have access to, which provides them the freedom to organize their work when performing different roles in a company.

The Company Accounts API provides REST access to retrieving Company User information.

Authentication
The endpoints provided by this API cannot be accessed anonymously. To access them, you need to impersonate users as Company Accounts and pass the authentication tokens received. For details on how to authenticate and retrieve such a token, see Logging In as Company User.

In your development, the API can help you to provide information on Company User Accounts within the company that the authenticated user belongs to.

Installation

For detailed information on the modules that provide the API functionality and related installation instructions, see Company Account Feature Integration.

Retrieving All Company Users

To retrieve a list of all the Company Users that belong to the company of the logged in user, send a GET request to the following endpoint:

/company-users

Sample request: GET http://glue.mysprykershop.com/company-users

Authentication Required
To get a list of Company Users, you need to authenticate first and pass an access token as a part of your request. For details, see Authentication and Authorization.

Response

The endpoint responds with a RestCompanyUserCollectionResponse that contains the Company Users in the company of the logged in user.

Response Attributes:

Attribute* Type Description
isActive Boolean Indicates whether the Company User is active.
isDefault Boolean Indicates whether the Company User is the default one for the logged in customer.

*The attributes mentioned are all attributes in the response. Type and ID are not mentioned.

Retrieving Available Company Users

To retrieve a list of the Company Users that the currently logged in user can impersonate as, send a GET request to the following endpoint:

/company-users/mine

Sample request: GET http://glue.mysprykershop.com/company-users/mine

Authentication Required
To get a list of Company Users, you need to authenticate first and pass an access token as a part of your request. For details, see Authentication and Authorization.

Response

The endpoint responds with a RestCompanyUserCollectionResponse that contains the Company Users available to the currently logged in user.

If the currently logged in user does not have access to any Company User accounts, the endpoint returns an empty RestCompanyUserCollectionResponse response.

Response Attributes:

Attribute* Type Description
id String

Specifies the Company User ID.

isActive Boolean Indicates whether the Company User is active.
isDefault Boolean Indicates whether the Company User is the default one for the logged in customer.

*The attributes mentioned are all attributes in the response. Type is not mentioned.

The company user identifier contained in the id member can be used to access the Company User in the future as well as impersonate as that account. For details, see Logging In as Company User.

Retrieving Specific Company Users

To retrieve information on a specific Company User, send a GET request to the following endpoint:

/company-users/{{company_user_id}}

Sample request: GET http://glue.mysprykershop.com/company-users/e1019900-88c4-5582-af83-2c1ea8775ac5

Authentication Required
To get information on a Company User, you need to authenticate first and pass an access token as a part of your request. For details, see Authentication and Authorization.

Response

The endpoint responds with a RestCompanyUserResponse that contains information on the requested Company User.

If the currently logged in user does not have access to the specified Company User account, the endpoint responds with the 404 Not Found status code.

Response Attributes:

Attribute* Type Description
isActive Boolean Indicates whether the Company User is active.
isDefault Boolean Indicates whether the Company User is the default one for the logged in customer.

*The attributes mentioned are all attributes in the response. Type is not mentioned.

Fetching Additional Information

To help customers understand which of the Company User Accounts they need, you can provide additional information, such as the company and business unit that each account belongs to. Also, you can identify which roles the corporate accounts can perform within the company. To fetch such information, extend the response of the endpoint with the companies and company-business-units, and company-roles resource relationships.

Sample request: GET http://glue.mysprykershop.com/company-users/mine?include=companies,company-business-units,company-roles

In this case, the following additional attributes will be added to the response:

Resource Attribute* Type Description
companies name String Specifies the name of the Company.

isActive

Boolean Indicates whether the Company is active.
status String Specifies the status of the Company. Possible values: Pending, Approved or Denied.
company-roles name String Specifies the name of the Company Role.
isDefault Boolean Indicates whether the Company Role is the default role for the company.
company-business-units name String Specifies the name of the Business Unit.
email String Specifies the email address of the Business Unit.
phone String Specifies the telephone number of the Business Unit.
externalUrl String Specifies the url of the website of the Business Unit.

bic

String Specifies the Bank Identifier Code of the Business Unit.

iban

String Specifies the International Bank Account Number of the Business Unit.
defaultBillingAddress String Specifies the default billing address of the Business Unit.

*The attributes mentioned are all attributes in the response. Type and ID are not mentioned.

Possible Errors

Status Reason
401 The access token is invalid.
403

The access token is missing.
- OR -
The current Company Account is not set.

This can occur if you didn't properly impersonate the user as a Company User Account. For details on how to do so, see Logging In as Company User.

404

The specified Company User was not found or the user does not have permissions to view the account.

See also:

 

Last review date: July 17, 2019