E-commerce API
E-commerce Products API
Sync products from your shop into MailerLite so they can be added to campaigns and product blocks.
Get products
If you want to get products for the given shop, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/productsRequest 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": "31986843543567834",
"name": "Product name",
"price": 123.4,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"short_description": "Product's short description.",
"description": "Product's longer description.",
"categories": [
{
"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"
},
{
"id": "1234566457534278",
"name": "Category 2",
"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/products?page=1",
"last": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products?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/products?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "Next »",
"active": false
}
],
"path": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products",
"per_page": 100,
"to": 1,
"total": 1
}
}Create/update product
You can create or update a product for the given shop.
To create a product for the given shop, send this POST request
POST https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/productsTo update a product for the given shop, send this PUT request
PUT https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products/:product_idRequest body
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| name | string | yes | The product's name |
| price | float | no | The product's price in the shop's currency. Defaults to 0. |
| exclude_from_automations | boolean | no | If true this product will not trigger any automations. Defaults to false |
| url | string | no | The products url. |
| image | string | no | The products main image url. |
| short_description | string | no | The product's short description. Max 255 characters. HTML tags are automatically removed |
| description | string | no | The product's description. HTML tags are automatically removed. |
{
"name": "Product name",
"price": 123.40,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"short_description": "Product's short description.",
"description": "Product's longer description."
}Response
If the product was created:
Response Code: 201 Created{
"data": {
"id": "31986843543567834",
"name": "Product name",
"price": 123.4,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"short_description": "Product's short description.",
"description": "Product's longer description.",
"categories": []
}
}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 product
If you want to fetch a product for the given shop, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products/:product_idRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| product_id | integer | yes | Must provide valid product id |
| shop_id | integer | yes | Must provide valid shop id |
GET https://connect.mailerlite.com/api/ecommerce/shops/31986843064993537/products/319868430643456756Response
If the shop and the product exist:
Response Code: 200 OK{
"data": {
"id": "31986843543567834",
"name": "Product name",
"price": 123.4,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"short_description": "Product's short description.",
"description": "Product's longer description.",
"categories": [
{
"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"
},
{
"id": "1234566457534278",
"name": "Category 2",
"exclude_from_automations": false,
"created_at": "2021-09-01 14:03:50",
"updated_at": "2021-09-01 14:03:50"
}
]
}
}Error
If the product or shop cannot be found:
Response Code: 404 Not FoundFetch total products count
If you want to fetch the total products count for the given shop, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products?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 product
If you want to delete a product for the given shop, send this DELETE request
DELETE https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products/:product_idRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| product_id | integer | yes | Must provide valid product id |
| shop_id | integer | yes | Must provide valid shop id |
Response
Response code: 200 OK{
"data": {
"id": "31986843543567834",
"name": "Product name",
"price": 123.4,
"url": "https://shop-url.com/product-name",
"image": "https://shop-url.com/product-image.jpg",
"exclude_from_automations": false,
"short_description": "Product's short description.",
"description": "Product's longer description.",
"categories": []
}
}Error
Response code: 404 Not Found