E-commerce Product Variants API
Create, list, update, and delete the variants of an e-commerce product.
Get product variants
If you want to get the variants of the given product, send this GET request
GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products/:product_id/variantsRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| shop_id | integer | yes | Must provide valid shop id |
| product_id | integer | yes | Must provide valid product id |
Response
Response Code: 200 OK{
"data": [
{
"id": "31986843543567900",
"name": "Black / Medium",
"attributes": {
"color": "Black",
"size": "Medium"
},
"price": 123.4,
"price_type": "fixed",
"resource_id": "variant-123",
"image_url": "https://shop-url.com/product-black.jpg"
}
]
}Create product variants
If you want to create variants for the given product, send this POST request with an array of variants
POST https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products/:product_id/variantsRequest body
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| *.name | string | yes | The variant's name |
| *.attributes | object | yes | The variant's attributes, e.g. {"color": "Black"} |
| *.price_type | string | no | Either fixed or increment |
| *.price | float | no | The variant's price. Required when price_type is provided |
| *.resource_id | string | no | The variant's id in your shop. Used to update an existing variant |
| *.image_url | string | no | The variant's image url |
[
{
"name": "Black / Medium",
"attributes": {
"color": "Black",
"size": "Medium"
},
"price": 123.4,
"price_type": "fixed",
"resource_id": "variant-123",
"image_url": "https://shop-url.com/product-black.jpg"
}
]When any variant in the request has a resource_id, existing variants of the product whose resource_id is not in the request are deleted.
Response
Returns the product with its variants.
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": [],
"variants": [
{
"id": "31986843543567900",
"name": "Black / Medium",
"attributes": {
"color": "Black",
"size": "Medium"
},
"price": 123.4,
"price_type": "fixed",
"resource_id": "variant-123",
"image_url": "https://shop-url.com/product-black.jpg"
}
]
}
}Error
Response Code: 422 Unprocessable Entity{
"message": "The 0.name field is required.",
"errors": {
"0.name": ["The 0.name field is required."]
}
}Update a product variant
If you want to update a variant of the given product, send this PUT request
PUT https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products/:product_id/variants/:variant_idRequest body
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| name | string | yes | The variant's name |
| attributes | object | yes | The variant's attributes, e.g. {"color": "Black"} |
| price_type | string | no | Either fixed or increment |
| price | float | no | The variant's price. Required when price_type is provided |
| resource_id | string | no | The variant's id in your shop |
| image_url | string | no | The variant's image url |
{
"name": "Black / Large",
"attributes": {
"color": "Black",
"size": "Large"
}
}Response
Returns the product with its variants, in the same format as Create product variants.
Response Code: 200 OKError
If the shop, product or variant cannot be found:
Response Code: 404 Not FoundDelete a product variant
If you want to delete a variant of the given product, send this DELETE request
DELETE https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/products/:product_id/variants/:variant_idRequest parameters
| Parameter | Type | Required | Limitations |
|---|---|---|---|
| shop_id | integer | yes | Must provide valid shop id |
| product_id | integer | yes | Must provide valid product id |
| variant_id | integer | yes | Must provide valid variant id |
Response
Returns the product with its remaining variants, in the same format as Create product variants.
Response Code: 200 OKError
If the shop, product or variant cannot be found:
Response Code: 404 Not Found