Retrieving Company Role Information
Edit on GitHubIn corporate environments, where users act as company representatives rather than private buyers, companies can leverage Company Roles in order to distribute scopes and permissions among Company Users. To identify which roles company users are assigned to, you can use the endpoints provided by the Company Role API.
In your development, the endpoint can help you to identify the roles existing in the company of the currently logged in user.
Installation
For detailed information on the modules that provide the API functionality and related installation instructions, see Glue API: Company Account Feature Integration.
Retrieving Company Role Information
Roles Performed by the Current User
To retrieve information on the Company Roles assigned to the currently logged in Company User, send a GET request to the following endpoint:
/company-roles/mine
Request sample: GET http://glue.mysprykershop.com/company-roles/mine
Response
The endpoint responds with a collection of RestCompanyRoleResponse, each containing information on a specific role.
Response Attributes:
Attribute* | Type | Specifies the name of the Company Role. |
---|---|---|
name | String | cell |
isDefault | Boolean | Indicates whether the Company Role is the default role for the company. |
*The attributes mentioned are all attributes in the response. Type and ID are not mentioned.
Sample Response
{
"data": [
{
"type": "company-roles",
"id": "2f0a9d3e-9e69-53eb-8518-284a0db04376",
"attributes": {
"name": "Admin",
"isDefault": true
},
"links": {
"self": "http://glue.mysprykershop.com/company-roles/2f0a9d3e-9e69-53eb-8518-284a0db04376"
}
}
],
"links": {
"self": "http://glue.mysprykershop.com/company-roles/mine"
}
}
Specific Role
To retrieve information on a specific Company Role, send a GET request to the following endpoint:
/company-roles/{{role_id}}
Request sample: GET http://glue.mysprykershop.com/company-roles/**2f0a9d3e-9e69-53eb-8518-284a0db04376**
where 2f0a9d3e-9e69-53eb-8518-284a0db04376 is the ID of the Company Role you need.
Response
The endpoint responds with a RestCompanyRoleResponse that contains information on the requested role.
Response Attributes:
Attribute* | Type | Description |
---|---|---|
name | String | Specifies the name of the Company Role. |
isDefault | Boolean | Indicates whether the Company Role is the default role for the company. |
*The attributes mentioned are all attributes in the response. Type and ID are not mentioned.
Sample Response
{
"data": {
"type": "company-roles",
"id": "2f0a9d3e-9e69-53eb-8518-284a0db04376",
"attributes": {
"name": "Admin",
"isDefault": true
},
"links": {
"self": "http://glue.mysprykershop.com/company-roles/2f0a9d3e-9e69-53eb-8518-284a0db04376"
}
}
}
Fetching Additional Information
You can extend the response with the companies resource relationship in order to obtain information on the company where the role was created.
Request sample: GET http://glue.mysprykershop.com/company-roles/2f0a9d3e-9e69-53eb-8518-284a0db04376?include=companies
The response will include the following additional attributes:
Resource | Attribute* | Type | Description |
---|---|---|---|
companies | name | String | Specifies the Company name. |
companies | isActive | Boolean | Indicates whether the Company is active. |
companies | 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": "company-roles",
"id": "2f0a9d3e-9e69-53eb-8518-284a0db04376",
"attributes": {...},
"links": {...},
"relationships": {
"companies": {
"data": [
{
"type": "companies",
"id": "0818f408-cc84-575d-ad54-92118a0e4273"
}
]
}
}
},
"included": [
{
"type": "companies",
"id": "0818f408-cc84-575d-ad54-92118a0e4273",
"attributes": {
"isActive": true,
"name": "Test Company",
"status": "approved"
},
"links": {
"self": "http://glue.mysprykershop.com/companies/0818f408-cc84-575d-ad54-92118a0e4273"
}
}
]
}
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 role was not found or the user does not have access to it. |
Thank you!
For submitting the form