E-commerce Customers API

Get customers

If you want to get a list of customers for the given shop, send this GET request

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

Request parameters

ParameterTypeRequiredLimitations
shop_idintegeryesMust provide valid shop id
limitintegernoDefaults to 100
pageintegernoDefaults to 1

Response

{
  "data": [
    {
      "id": "31986843064993537",
      "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
      },
      "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/customers?page=1",
    "last": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/customers?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/customers?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": null,
        "label": "Next »",
        "active": false
      }
    ],
    "path": "https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/customers",
    "per_page": 100,
    "to": 1,
    "total": 1
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

Notes:

The subscriber field will be null if no subscriber exists for the customer.

Create/update customer

You can create or update a customer for the given shop.

If you want to create a customer, send this POST request

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

If you want to update the customer, send this PUT request

PUT https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/customers/:customer_id
1

Request body

ParameterTypeRequiredLimitations
emailstringyesCustomer's email address
accepts_marketingbooleannoTrue if the customer accepts marketing emails, false otherwise
total_spentfloatnoThe total amount the customer has spent in the shop.
create_subscriberbooleannoIf set, a subscriber will be created for the customer.
{
    "email": "Customer name",
    "accepts_marketing": true,
    "total_spent": 1234.99
    "create_subscriber": true,
}
1
2
3
4
5
6

Response

If the customer was created:

Response Code: 201 Created
1
{
  "data": {
    "id": "31986843064993537",
    "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
    },
    "created_at": "2021-09-01 14:03:50",
    "updated_at": "2021-09-01 14:03:50"
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

Notes:

The subscriber field will be null if no subscriber exists for the customer.

If a subscriber exists with the same email as the customer, the customer will be associated with that subscriber.

Doing a PUT request with create_subscriber set to false on a customer that has a subscriber associated, has no effect.

Doing a PUT request with create_subscriber set to true on a customer that doesn't have a subscriber, creates the subscriber.

Error

Response Code: 422 Unprocessable Entity
1

The error response will contain information about the invalid data.

{
  "message": "The given data was invalid.",
  "errors": {
    "email": ["The email must be provided."]
  }
}
1
2
3
4
5
6

Fetch a customer

If you want to fetch a customer for the given shop, send this GET request

GET https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/customers/:customer_id
1

Request parameters

ParameterTypeRequiredLimitations
customer_idintegeryesMust provide valid customer id
shop_idintegeryesMust provide valid shop id
GET https://connect.mailerlite.com/api/ecommerce/shops/31986843064993537/customers/319868430643456756
1

Response

If the shop and the customer exist:

Response Code: 200 OK
1
{
  "data": {
    "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
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

Notes:

The subscriber field will be null if no subscriber exists for the customer.

Error

If the customer or shop cannot be found:

Response Code: 404 Not Found
1

Fetch total customers count

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

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

Request parameters

ParameterTypeRequiredLimitations
shop_idintegeryesMust provide valid shop id
limitintegeryesValue must be 0

Response

Response Code: 200 OK
1
{
  "total": 123
}
1
2
3

Delete a customer

If you want to delete a customer for the given shop, send this DELETE request

DELETE https://connect.mailerlite.com/api/ecommerce/shops/:shop_id/customers/:customer_id
1

Request parameters

ParameterTypeRequiredLimitations
customer_idintegeryesMust provide valid customer id
shop_idintegeryesMust provide valid shop id

Response

Response code: 200 OK
1
{
  "data": {
    "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
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

Notes:

The subscriber field will be null if no subscriber exists for the customer.

If a subscriber is associated with the customer, the subscriber will not be deleted or affected.

Error

Response code: 404 Not Found
1
Last Updated: