The Products Catalog View for Customers vs Managers
stoplight-id: qzsqur4765trd
internal: true
Our Products endpoints are designed to serve both our Store Managers and our Customers. Depending on who is accessing the data, we return a slightly different structure of the product
object. This document explains these differences and shows examples of how the responses differ.
Access
When making a request to the Products endpoints, namely /products
and /product
, the headers of the request determine who is making the request and what type of response they will receive:
- Managers need to provide the
Authorization
andAccess-Token
(previouslyX-Manager-Token
) headers, and theRole
header should be set toManager
. - Customers don't need an authorization token, and the
Role
header should be set toCustomer
.
The headers in a Manager's request might look something like this:
GET /products HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9
X-Manager-Token: 123abc456def
Role: Manager
A Customer's request might look like this:
GET /products HTTP/1.1
Role: Customer
Response Structure
The structure of the response differs depending on whether a Manager or a Customer made the request.
Manager
When a Manager makes a request, the name
field and the value
field in the attributes
array are objects containing "ar" (Arabic) and "en" (English) strings. This gives the Manager the ability to see product names and attributes in both languages.
A typical Manager's response might include:
{
"name": {
"ar": "الاسم",
"en": "name"
},
"attributes": [
{
"value": {
"ar": "القيمة",
"en": "value"
}
}
],
"created_at": "2023-05-01T12:34:56Z",
"updated_at": "2023-05-02T12:34:56Z"
}
The Manager's response also includes created_at
and updated_at
fields, providing timestamps for when the product was created and last updated.
Customer
When a Customer makes a request, the name
field and the value
field in the attributes
array are simple strings, and there are no created_at
or updated_at
fields. This presents a simpler view of the product data.
A typical Customer's response might include:
{
"name": "name",
"attributes": [
{
"value": "value"
}
]
}
This flexible structure allows us to provide a more robust data set for our Managers while keeping the interface simple and streamlined for our Customers. Please refer to this guide when working with our Products API.