E-commerce API
E-commerce Categories API
Sync product categories from your shop into MailerLite for use in e-commerce blocks and segments.
Get categories
If you want to get all categories of the given shop_id, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categoriesRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| shop_id | integer | yes | Must provide valid shop id |
| limit | integer | no | Defaults to 100 |
| page | integer | no | Defaults to 1 |
Response
{
"data": [
{
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}
],
"links": {
"first": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categories?page=1",
"last": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categories?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categories?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"path": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categories",
"per_page": 100,
"to": 1,
"total": 1
}
}Create/update category
You can create or update the category of the given shop.
If you want to create the category, send this POST request
POST https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categoriesIf you want to update the category, send this PUT request
PUT https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categories/:category_idRequest body
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| name | string | yes | The category's name |
| exclude_from_automations | boolean | no | If true this category will not trigger any automations. Defaults to false |
{
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}Response
If the category was created:
Response Code: 201 Created{
"data": {
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}
}Error
Response Code: 422 Unprocessable EntityThe error response will contain information about the invalid data.
{
"message": "The given data was invalid.",
"errors": {
"name": ["The name must be provided."]
}
}Fetch a category
If you want to fetch a category for a given shop, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categories/:category_idRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| category_id | integer | yes | Must provide valid category id |
| shop_id | integer | yes | Must provide valid shop id |
GET https://connect.mailerlite.com/api/ecommerce/shops/31986843064993537/categories/319868430643456756Response
If the shop and the category exist:
Response Code: 200 OK{
"data": {
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}
}Error
If the category or shop cannot be found:
Response Code: 404 Not FoundFetch total categories count
If you want to fetch the count of all categories, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categories?limit=0Request parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| shop_id | integer | yes | Must provide valid shop id |
| limit | integer | yes | Value must be 0 |
Response
Response Code: 200 OK{
"total": 123
}Delete a category
If you want to delete a category for the given shop, send this DELETE request
DELETE https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/categories/:category_idRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| category_id | integer | yes | Must provide valid category id |
| shop_id | integer | yes | Must provide valid shop id |
Response
Response code: 200 OK{
"id": "1234566457534276",
"name": "Category 1",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}Error
Response code: 404 Not Found