Manage your product categories
Learn how to create, update and manage your product categories
After accessing the eCommerce platform you can start defining the categories that your products will be associated to. Note that this should ideally be the first object type you import into your account.
Create a category
To create a category, go to the eCommerce > Create/Update a category in the API reference. Below you find an example of body parameters which can be used to create or update a category.
cURL Request
curl --request POST \
--url https://api.brevo.com/v3/categories \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"id": "CAT123",
"name": "Electronics",
"url": "http://mydomain.com/category/electronics"
"updateEnabled": false
}
The cURL request shows us what parameters will be used to create a category. Below, you can see some default values mentioned for each parameter.
Body parameters
Attribute | Type | Description | Value |
---|---|---|---|
id | String | Unique Category ID as saved in the shop | CAT23 |
name | String | Category name | Electronics |
url | String | URL to the category | http://mydomain.com/category/electronics |
updateEnabled | Boolean | Facilitates to update the existing category in the same request. It can be true or false. | false |
Update a category
You can update a category by changing the boolean value to true in the updateEnabled
attribute when you are creating the category.
{
"updateEnabled": true
}
Attribute | Datatype | Description | Value |
---|---|---|---|
updateEnabled | Boolean | Facilitates to update the existing category in the same request. It can be true or false. | true |
You can then change the name and url of the category and then run it to update the respective category.
Response codes
Response code | Message | Description |
---|---|---|
201 | Category Created | If the request succeeds, you will receive the response code 201 for creating a category with the id of the category as message in the response. |
204 | Category updated | For updating a category successfully, you will receive a response code of 204 with no message in response which shows that category has been updated. |
401 | Unauthorized response | - Your api-key may not be correct- You have not activated the access to the API. See this article for info. - The format for name and url may not be correct |
Retrieving all categories
You can retrieve the categories you added by calling the eCommerce > Return all your categories API endpoint in the API reference. Below you can see the attributes used for returning all your categories.
cURL Request
curl --request GET \
--url 'https://api.brevo.com/v3/categories?limit=20&offset=0&sort=desc&ids=CAT123&ids=CAT234' \
--header 'accept: application/json'
The parameters to retrieve all categories are as following:
Attribute | Datatype | Description | Value |
---|---|---|---|
limit | int64 | Number of category items per page | 50 |
offset | int64 | Index of the first item in the page | 0 |
sort | String | Sort the results in the ascending/descending order of record creation. | desc |
ids | Array of strings | Filter by category ids | CAT123 |
Retrieving a category details
You can get a category's details by entering the id for the category in the get a category details endpoint.
curl --request GET \
--url https://api.brevo.com/v3/categories/CAT123 \
--header 'accept: application/json' \
--header 'api-key: '
There is only one attribute for this endpoint mentioned below:
Attribute | Datatype | Description | Value |
---|---|---|---|
id | String | Category ID | CAT123 |
Creating categories in a batch
You can use this to send your product categories in batches so you don't have to add every category individually. Below you can find a cURL request for creating categories in a batch.
curl --request POST \
--url https://api.brevo.com/v3/categories/batch \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"updateEnabled": true
}
We can use the cURL request to call the batch endpoint for categories. Note the boolean attribute updateEnabled
is included to enable or disable updates for all the categories being imported.
Attribute | Datatype | Description | Value |
---|---|---|---|
categories | Array of objects | Array of category objects | id, name, url |
updateEnabled | Boolean | Facilitate to update the existing categories in the same request | false |
Categories is an array of objects. It has further sub-attributes.
Attribute | Datatype | Description | Value |
---|---|---|---|
id | String | Unique Category ID as saved in the shop. | CAT123 |
name | String | Mandatory in case of creation. Name of the Category, as displayed in the shop. | Electronics |
url | String | URL to the category. | http://mydomain.com/category/electronics |
JSON Payload
{"categories":[{
"id": "CAT123",
"name": "Example Category 1",
"url": "http://shop.com/category/example1"
},
{
"id": "CAT234",
"name": "Example Category 2",
"url": "http://shop.com/category/example2"
},
{
"id": "CAT345",
"name": "Example Category 3",
"url": "http://shop.com/category/example3"
}
],
"updateEnabled": true
}
Good practices for importing category batches
- You can create up to 100 categories per call . The sub-attributes for categories are same as the attributes in create a category above.
- Be sure to add the proper category url to the JSON payload.
- All the attributes have the data type as string.
Updated 10 months ago