MailerLite
E-commerce API

E-commerce Orders API

Create, update, and complete orders so MailerLite can trigger purchase and abandoned-cart automations.

Get orders

If you want to get orders for the given shop, send this GET request

GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders

Get a list of orders for the given shop.

Request parameters

ParameterTypeRequiredLimitations
shop_idintegeryesMust provide valid shop id
limitintegernoDefaults to 100
pageintegernoDefaults to 1
filter[attributed]booleannoAllowed values: true, false, 1, 0. Returns only orders with (true) or without (false) an attribution.
filter[email_id]integernoReturns only orders attributed to the given email. See Revenue attribution.

To get the orders attributed to one campaign or automation email, send

GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders?filter[email_id]=31986843064993540

Response

{
  "data": [
    {
      "id": "31986843064993537",
      "shop": {
        "id": "31986843064993537",
        "name": "shop name",
        "url": "https://shop-url.com",
        "currency": "USD",
        "enabled": true,
        "enable_popups": false,
        "group": {
          "id": "1",
          "name": "dummy group",
          "total": 20,
          "open_rate": {
            "float": 0,
            "string": "0%"
          },
          "click_rate": {
            "float": 0,
            "string": "0%"
          },
          "created_at": "2021-08-06 10:17:45"
        },
        "created_at": "2021-09-01 14:03:50",
        "updated_at": "2021-09-01 14:03:50"
      },
      "customer": {
        "id": "319868430643456756",
        "email": "customer@email.com",
        "accepts_marketing": true,
        "subscriber": {
          "id": "31986843064993537",
          "email": "customer@email.com",
          "status": "active",
          "source": "api",
          "sent": 0,
          "opens_count": 0,
          "clicks_count": 0,
          "open_rate": 0,
          "click_rate": 0,
          "ip_address": null,
          "subscribed_at": "2021-09-01 14:03:50",
          "unsubscribed_at": null,
          "created_at": "2021-09-01 14:03:50",
          "updated_at": "2021-09-01 14:03:50",
          "fields": {
            "city": null,
            "company": null,
            "country": null,
            "last_name": "Testerson",
            "name": "Dummy",
            "phone": null,
            "state": null,
            "z_i_p": null
          },
          "groups": [],
          "opted_in_at": null,
          "optin_ip": null
        }
      },
      "cart": {
        "id": "12564435675647",
        "resource_id": null,
        "checkout_url": "https://url-to-cart-checkout.com",
        "cart_total": 1234.99,
        "items": [
          {
            "id": "45676855678345",
            "product": {
              "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,
              "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"
                }
              ]
            },
            "variant": "product variant",
            "quantity": 1,
            "price": 123.4
          }
        ]
      },
      "total": 123.4,
      "status": "complete",
      "attribution": {
        "email_id": "31986843064993540",
        "type": "campaign"
      },
      "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/orders?page=1",
    "last": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders?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/orders?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": null,
        "label": "Next »",
        "active": false
      }
    ],
    "path": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders",
    "per_page": 100,
    "to": 1,
    "total": 1
  }
}

Error

If a filter has an invalid value, for example filter[attributed]=maybe or a non-numeric filter[email_id]:

Response Code: 422 Unprocessable Entity

Revenue attribution

Every order response includes an attribution field. It tells you which campaign or automation email earned the order.

{
  "attribution": {
    "email_id": "31986843064993540",
    "type": "campaign"
  }
}
FieldTypeDescription
email_idstringThe ID of the email the customer clicked before ordering.
typestringcampaign or automation.

attribution is null when the order is not attributed to any email.

MailerLite calculates the attribution when an order is marked complete, so the create or update response for a completed order already includes it. Attribution requires e-commerce campaign tracking to be set up in your shop.

An order is never attributed if:

  • its status is pending
  • it was created with without_automations: true
  • its customer has no subscriber

If the attributed campaign is later deleted, the order keeps its attribution.

The attribution is read-only. MailerLite ignores email_id if you send it when you create or update an order.

Create/update order

You can create or update an order for the given shop.

If you want to create an order for the given shop, send this POST request

POST https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders

If you want to update an order for the given shop, send this PUT request

PUT https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders/:order_id

Request body

ParameterTypeRequiredLimitations
customerarrayyesThe customer information. Check the respective ecommerce customer api documentation.
cartarrayyesThe order cart. Check the respective ecommerce cart api documentation.
statusstringnoThe order's status. Allowed values: pending, complete. Defaults to pending.
total_pricefloatnoThe order's total price. Defaults to 0.
{
    "customer": {
        "email": "customer@email.com",
        "create_subscriber": true,
        "accepts_marketing": true,
        "name": "Dummy",
        "last_name": "Testerson"
    },
    "cart": {
        "items": [
            {
                "ecommerce_product_id": "1236545467567",
                "variant": "product variant",
                "quantity": 1,
                "price": 123.40
            }
        ]
    },
    "status": "pending",
    "total_price": 123.40
}

Notes:

The customer will be created if a customer with the same email doesn't already exist in the platform.

You can send the customer's name and last_name (strings, max 255 characters) in the customer object. They are saved to the subscriber's Name and Last name fields, so they only take effect when the customer has a subscriber. A non-empty value overwrites the subscriber's current value. An empty or null value leaves it unchanged. See Create/update customer.

You cannot update the cart or the customer of an order through the PUT endpoint. You'll have to use the respective Customer and Cart endpoints instead.

You cannot set the order's attribution. MailerLite ignores email_id in the request body and calculates the attribution itself. See Revenue attribution.

Response

If the order was created:

Response Code: 201 Created
{
  "data": {
    "id": "31986843064993537",
    "shop": {
      "id": "31986843064993537",
      "name": "shop name",
      "url": "https://shop-url.com",
      "currency": "USD",
      "enabled": true,
      "enable_popups": false,
      "group": {
        "id": "1",
        "name": "dummy group",
        "total": 20,
        "open_rate": {
          "float": 0,
          "string": "0%"
        },
        "click_rate": {
          "float": 0,
          "string": "0%"
        },
        "created_at": "2021-08-06 10:17:45"
      },
      "created_at": "2021-09-01 14:03:50",
      "updated_at": "2021-09-01 14:03:50"
    },
    "customer": {
      "id": "319868430643456756",
      "email": "customer@email.com",
      "accepts_marketing": true,
      "subscriber": {
        "id": "31986843064993537",
        "email": "customer@email.com",
        "status": "active",
        "source": "api",
        "sent": 0,
        "opens_count": 0,
        "clicks_count": 0,
        "open_rate": 0,
        "click_rate": 0,
        "ip_address": null,
        "subscribed_at": "2021-09-01 14:03:50",
        "unsubscribed_at": null,
        "created_at": "2021-09-01 14:03:50",
        "updated_at": "2021-09-01 14:03:50",
        "fields": {
          "city": null,
          "company": null,
          "country": null,
          "last_name": "Testerson",
          "name": "Dummy",
          "phone": null,
          "state": null,
          "z_i_p": null
        },
        "groups": [],
        "opted_in_at": null,
        "optin_ip": null
      }
    },
    "cart": {
      "id": "12564435675647",
      "resource_id": null,
      "checkout_url": "https://url-to-cart-checkout.com",
      "cart_total": 1234.99,
      "items": [
        {
          "id": "45676855678345",
          "product": {
            "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,
            "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"
              }
            ]
          },
          "variant": "product variant",
          "quantity": 1,
          "price": 123.4
        }
      ]
    },
    "total": 123.4,
    "status": "pending",
    "attribution": null,
    "created_at": "2021-09-01 14:03:50",
    "updated_at": "2021-09-01 14:03:50"
  }
}

Error

Response Code: 422 Unprocessable Entity

The error response will contain information about the invalid data.

{
  "message": "The given data was invalid.",
  "errors": {
    "customer": ["The customer must be provided."]
  }
}

Fetch an order

If you want to fetch an order for the given shop, send this GET request

GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders/:order_id

Request parameters

ParameterTypeRequiredLimitations
order_idintegeryesMust provide valid order id
shop_idintegeryesMust provide valid shop id
GET https://connect.mailerlite.com/api/ecommerce/shops/31986843064993537/orders/319868430643456756

Response

If the shop and the order exist:

Response Code: 200 OK
{
  "data": {
    "id": "31986843064993537",
    "shop": {
      "id": "31986843064993537",
      "name": "shop name",
      "url": "https://shop-url.com",
      "currency": "USD",
      "enabled": true,
      "enable_popups": false,
      "group": {
        "id": "1",
        "name": "dummy group",
        "total": 20,
        "open_rate": {
          "float": 0,
          "string": "0%"
        },
        "click_rate": {
          "float": 0,
          "string": "0%"
        },
        "created_at": "2021-08-06 10:17:45"
      },
      "created_at": "2021-09-01 14:03:50",
      "updated_at": "2021-09-01 14:03:50"
    },
    "customer": {
      "id": "319868430643456756",
      "email": "customer@email.com",
      "accepts_marketing": true,
      "subscriber": {
        "id": "31986843064993537",
        "email": "customer@email.com",
        "status": "active",
        "source": "api",
        "sent": 0,
        "opens_count": 0,
        "clicks_count": 0,
        "open_rate": 0,
        "click_rate": 0,
        "ip_address": null,
        "subscribed_at": "2021-09-01 14:03:50",
        "unsubscribed_at": null,
        "created_at": "2021-09-01 14:03:50",
        "updated_at": "2021-09-01 14:03:50",
        "fields": {
          "city": null,
          "company": null,
          "country": null,
          "last_name": "Testerson",
          "name": "Dummy",
          "phone": null,
          "state": null,
          "z_i_p": null
        },
        "groups": [],
        "opted_in_at": null,
        "optin_ip": null
      }
    },
    "cart": {
      "id": "12564435675647",
      "resource_id": null,
      "checkout_url": "https://url-to-cart-checkout.com",
      "cart_total": 1234.99,
      "items": [
        {
          "id": "45676855678345",
          "product": {
            "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,
            "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"
              }
            ]
          },
          "variant": "product variant",
          "quantity": 1,
          "price": 123.4
        }
      ]
    },
    "total": 123.4,
    "status": "complete",
    "attribution": {
      "email_id": "31986843064993540",
      "type": "campaign"
    },
    "created_at": "2021-09-01 14:03:50",
    "updated_at": "2021-09-01 14:03:50"
  }
}

Error

If the order or shop cannot be found:

Response Code: 404 Not Found

Fetch total orders count

If you want to fetch total orders count for the given shop, send this GET request

GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders?limit=0

Request parameters

ParameterTypeRequiredLimitations
shop_idintegeryesMust provide valid shop id
limitintegeryesValue must be 0

Response

Response Code: 200 OK
{
  "total": 123
}

Delete an order

If you want to delete an order, send this DELETE request

   DELETE https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/orders/:order_id

Request parameters

ParameterTypeRequiredLimitations
order_idintegeryesMust provide valid order id
shop_idintegeryesMust provide valid shop id

Response

Response code: 200 OK
{
  "data": {
    "id": "31986843064993537",
    "shop": {
      "id": "31986843064993537",
      "name": "shop name",
      "url": "https://shop-url.com",
      "currency": "USD",
      "enabled": true,
      "enable_popups": false,
      "group": {
        "id": "1",
        "name": "dummy group",
        "total": 20,
        "open_rate": {
          "float": 0,
          "string": "0%"
        },
        "click_rate": {
          "float": 0,
          "string": "0%"
        },
        "created_at": "2021-08-06 10:17:45"
      },
      "created_at": "2021-09-01 14:03:50",
      "updated_at": "2021-09-01 14:03:50"
    },
    "customer": {
      "id": "319868430643456756",
      "email": "customer@email.com",
      "accepts_marketing": true,
      "subscriber": {
        "id": "31986843064993537",
        "email": "customer@email.com",
        "status": "active",
        "source": "api",
        "sent": 0,
        "opens_count": 0,
        "clicks_count": 0,
        "open_rate": 0,
        "click_rate": 0,
        "ip_address": null,
        "subscribed_at": "2021-09-01 14:03:50",
        "unsubscribed_at": null,
        "created_at": "2021-09-01 14:03:50",
        "updated_at": "2021-09-01 14:03:50",
        "fields": {
          "city": null,
          "company": null,
          "country": null,
          "last_name": "Testerson",
          "name": "Dummy",
          "phone": null,
          "state": null,
          "z_i_p": null
        },
        "groups": [],
        "opted_in_at": null,
        "optin_ip": null
      }
    },
    "cart": {
      "id": "12564435675647",
      "resource_id": null,
      "checkout_url": "https://url-to-cart-checkout.com",
      "cart_total": 1234.99,
      "items": [
        {
          "id": "45676855678345",
          "product": {
            "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,
            "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"
              }
            ]
          },
          "variant": "product variant",
          "quantity": 1,
          "price": 123.4
        }
      ]
    },
    "total": 123.4,
    "status": "pending",
    "attribution": null,
    "created_at": "2021-09-01 14:03:50",
    "updated_at": "2021-09-01 14:03:50"
  }
}

Notes:

Deleting an order will also delete the associated cart and cart items.

Error

Response code: 404 Not Found

On this page