# List customers

`GET https://api.anyshop.io/v1/customers`

The people who bought in your API key's mode (a paid order), with the store's customer records in live mode, as the dashboard's Customers lists them: the latest order first, people without an order last.

- Part of the [API reference](https://docs.anyshop.io/reference.md), [Customers](https://docs.anyshop.io/reference.md#customers).
- Scope: `customers:read`.

## Query parameters

- `limit` (integer): How many to return: 1 to 100, default 20. 1 to 100.
- `starting_after` (string): The last ID of the previous page; the next page starts after it. Up to 256 characters.
- `email` (string): Only the customer with this email address (trimmed and lowercased). Up to 254 characters.
- `marketing` (enum): true: only those who agreed to marketing emails; false: only those who did not. Values: `true`, `false`.

## Returns

A list of **customer** objects, newest first: `{ "object": "list", "data", "has_more" }`.

## Errors

| Status | error.type | When |
| --- | --- | --- |
| 400 | `invalid_request` | The request is not valid; `error.param` names the field |
| 401 | `authentication` | No API key, or it is not valid |
| 403 | `permission` | The key does not have the scope this needs, or the store is suspended (store_suspended) |
| 404 | `not_found` | Not found in the key's store and mode |
| 409 | `conflict` | Conflicts with the object's state (type conflict), or an Idempotency-Key reused for another request (type idempotency, code idempotency_key_reused) |
| 429 | `rate_limited` | Too many requests; see Retry-After |

## Example

curl:

```bash
curl https://api.anyshop.io/v1/customers \
  -H "Authorization: Bearer $ANYSHOP_API_KEY"
```

Node:

```js
const response = await fetch("https://api.anyshop.io/v1/customers", {
  headers: {
    Authorization: `Bearer ${process.env.ANYSHOP_API_KEY}`,
  },
});
const answer = await response.json();
```

Python:

```python
import os
import requests

response = requests.get(
    "https://api.anyshop.io/v1/customers",
    headers={
        "Authorization": f"Bearer {os.environ['ANYSHOP_API_KEY']}",
    },
)
answer = response.json()
```

Answer (200):

```json
{
  "object": "list",
  "data": [
    {
      "object": "customer",
      "id": "cus_01m3rx2b4d6f8h0k2m4p6r8t0v",
      "livemode": true,
      "email": "mara@example.com",
      "name": "Mara Lind",
      "orders": 3,
      "spent": {
        "amount": 5997,
        "currency": "USD"
      },
      "refunds": 0,
      "first_order_at": "2026-10-02T14:21:07.000Z",
      "last_order_at": "2026-10-02T14:21:07.000Z",
      "country": "SE",
      "payment_methods": [
        "stripe"
      ],
      "licenses": 1,
      "marketing_consent": {
        "given": true,
        "at": "2026-10-02T14:21:07.000Z",
        "source": "api"
      }
    }
  ],
  "has_more": false
}
```

Answer (400):

```json
{
  "error": {
    "type": "invalid_request",
    "code": "invalid_query",
    "message": "The request is not valid; `error.param` names the field",
    "param": null
  }
}
```

Answer (409):

```json
{
  "error": {
    "type": "conflict",
    "code": "conflict",
    "message": "Conflicts with the object's state (type conflict), or an Idempotency-Key reused for another request (type idempotency, code idempotency_key_reused)",
    "param": null
  }
}
```

The IDs and keys in these examples are made up. Every schema is in the OpenAPI document, https://api.anyshop.io/v1/openapi.json.
