Retrieving Company Information

Edit on GitHub
You are browsing a previous version of the document. The latest version is 202212.0.

Spryker provides the Company Account feature that allows purchasing goods and performing other actions on behalf of a user’s company. The endpoints provided by the Company API allow retrieving information on companies.

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](/docs/scos/dev/glue-api-guides/201907.0/managing-b2b-account/authenticating-as-a-company-user.html).

In your development, the API can help you to provide information on 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 GLUE: Company Account Feature Integration

Retrieving Company Information

Information on the User’s Company

To retrieve information on the company a user belongs to, send a GET request to the following endpoint:

/companies/mine

Request sample: GET http://glue.mysprykershop.com/companies/mine

Note
You can use the Accept-Language header to specify the locale.Sample header: [{"key":"Accept-Language","value":"de, en;q=0.9"}]where de, en are the locales; q=0.9 is the user's preference for a specific locale. For details, see [14.4 Accept-Language](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4).

Response

The endpoint responds with a collection of RestCompanyResponse consisting of a single item that represents the user’s company.

Response Attributes:

Attribute* Type Description
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.

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

Sample Response
{
    "data": [
        {
            "type": "companies",
            "id": "88efe8fb-98bd-5423-a041-a8f866c0f913",
            "attributes": {
                "isActive": true,
                "name": "BoB-Hotel Mitte",
                "status": "approved"
            },
            "links": {
                "self": "http://glue.mysprykershop.com/companies/88efe8fb-98bd-5423-a041-a8f866c0f913"
            }
        }
    ],
    "links": {
        "self": "http://glue.mysprykershop.com/companies/mine"
    }
}

Information on a Specific Company

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

/companies/{{company_id}}

Request sample: GET http://glue.mysprykershop.com/companies/**59b6c025-cc00-54ca-b101-191391adf2af** where 59b6c025-cc00-54ca-b101-191391adf2af is the ID of the company you need.

Info
The endpoint provides information only on the companies a user has access to. If an attempt is made to access a company that a user doesn't have access to, the endpoint will respond with a **404 Not Found** error code.
Note
You can use the Accept-Language header to specify the locale.Sample header: [{"key":"Accept-Language","value":"de, en;q=0.9"}]where de, en are the locales; q=0.9 is the user's preference for a specific locale. For details, see [14.4 Accept-Language](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4).

Response

The endpoint responds with a RestCompanyResponse containing information on the requested company.

Response Attributes:

Attribute* Type Description
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.

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

Sample Response
{
    "data": {
        "type": "companies",
        "id": "59b6c025-cc00-54ca-b101-191391adf2af",
        "attributes": {
            "isActive": true,
            "name": "BoB-Hotel Jim",
            "status": "approved"
        },
        "links": {
            "self": "http://glue.mysprykershop.com/companies/59b6c025-cc00-54ca-b101-191391adf2af"
        }
    }
}

Possible Errors

Code 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 was not found, or the user does not have access to it.