MailerLite
E-commerce API

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/variants

Request parameters

ParameterTypeRequiredLimitations
shop_idintegeryesMust provide valid shop id
product_idintegeryesMust 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/variants

Request body

ParameterTypeRequiredLimitations
*.namestringyesThe variant's name
*.attributesobjectyesThe variant's attributes, e.g. {"color": "Black"}
*.price_typestringnoEither fixed or increment
*.pricefloatnoThe variant's price. Required when price_type is provided
*.resource_idstringnoThe variant's id in your shop. Used to update an existing variant
*.image_urlstringnoThe 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_id

Request body

ParameterTypeRequiredLimitations
namestringyesThe variant's name
attributesobjectyesThe variant's attributes, e.g. {"color": "Black"}
price_typestringnoEither fixed or increment
pricefloatnoThe variant's price. Required when price_type is provided
resource_idstringnoThe variant's id in your shop
image_urlstringnoThe 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 OK

Error

If the shop, product or variant cannot be found:

Response Code: 404 Not Found

Delete 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_id

Request parameters

ParameterTypeRequiredLimitations
shop_idintegeryesMust provide valid shop id
product_idintegeryesMust provide valid product id
variant_idintegeryesMust provide valid variant id

Response

Returns the product with its remaining variants, in the same format as Create product variants.

Response Code: 200 OK

Error

If the shop, product or variant cannot be found:

Response Code: 404 Not Found

On this page