# Get the favourites list

URL: https://docs.sparklayer.io/developers/api/customers/get-the-favourites-list
Operation: `GET /api/v2/customers/{lookupBy}/{identifier}/favourites-list` (operationId `getCustomerFavouritesList`)
OpenAPI spec: https://docs.sparklayer.io/openapi/customers.yaml

Returns the customer's favourites list for the section, creating it with empty contents if it does not exist yet. The first section to ask for it takes over the customer's section-less list.

`GET /api/v2/customers/{lookupBy}/{identifier}/favourites-list`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl "https://app.sparklayer.io/api/v2/customers/platform/7843024560291/favourites-list" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID"
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `lookupBy` | "sparklayer" \| "platform" \| "email" | Yes | What `identifier` is: `sparklayer` (the customer's SparkLayer ID), `platform` (their ID on your eCommerce platform) or `email` (their email address). Example: `platform` |
| `identifier` | string | Yes | The customer's ID or email address, of the kind set by `lookupBy`. SparkLayer IDs are UUIDs; legacy `cu_` IDs work too, except for shopping lists and favourites. Email lookups are exact and case-sensitive: URL-encode the address, with `+` as `%2B`. Example: `7843024560291` |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `section_id` | string (uuid) | | Scope to an active company section the customer belongs to or administers; any other section returns 400. Omit for merchants that do not use company sections. |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Length: min 1. Example: `jones-climbing` |

### Responses

#### 200: Successful response

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string (uuid) | | |
| `created_at` | string | | Created Date |
| `updated_at` | string | | Updated Date |
| `contents` | object[] | Yes | |
| `contents[].sku` | string | Yes | Length: max 256. |
| `company` | object \| null | | Company sections are opt-in; omit this, or send null, for merchants that do not use them. Otherwise `section_id` is required. Set when the list is created and not changed afterwards. |
| `company.id` | string (uuid) \| null | | |
| `company.section_id` | string (uuid) | Yes | |
| `company.section_name` | string \| null | | Length: max 128. |

```json
{
  "id": "6502579c-90b9-4fc1-8e78-083cb84702d8",
  "created_at": "2003-05-20T08:20:00Z",
  "updated_at": "2003-05-21T08:20:00Z",
  "contents": [
    {
      "sku": "TEST"
    }
  ],
  "company": {
    "id": "3f2b8c1e-5d4a-4e6f-9b7c-1a2d3e4f5a6b",
    "section_id": "3f2b8c1e-5d4a-4e6f-9b7c-1a2d3e4f5a6b",
    "section_name": "<section_name>"
  }
}
```

#### 400: The request is invalid.

`application/problem+json`: the standard error body (below).

#### 404: Not found.

`application/problem+json`: the standard error body (below).

#### Other statuses: An error. The body describes the problem: see [Errors](https://docs.sparklayer.io/developers/errors.md).

`application/problem+json`: the standard error body (below).

### Error body

Error responses with a body use this RFC 7807 problem details object. See [Errors](https://docs.sparklayer.io/developers/errors.md) for every status code and which errors to retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | integer | | HTTP Status code returned from API |
| `title` | string | | Machine-readable error code |
| `type` | string | | |
| `errors` | object[] | | |
| `errors[].code` | string | | A machine-readable error message |
| `errors[].property` | string | | The offending property, with the full path |
| `errors[].field` | string | | The offending property, stripped of the path |
| `errors[].message` | string | | A human-readable summary of the error |

```json
{
  "detail": "Data Validation Failed",
  "status": 400,
  "title": "invalid-api-request-contents",
  "type": "https://hub.sparklayer.io/tech-docs",
  "errors": [
    {
      "code": "unique-constraint-violation",
      "property": "purchase_identifiers.sparklayer",
      "field": "sparklayer",
      "message": "Each stock level must have a unique stock location and sku combination"
    }
  ]
}
```
