# Stores

> Address stores by your own store code and keep them in sync.

Source: https://developers.loyx.se/guides/stores/

Every sale happens in a store. LoyX knows the brand's stores, and each store can carry **your own code** for it: `external_store_id`. Use that code everywhere and you never have to keep LoyX's ids.

## Find a store by your code

```
GET /v1/stores/external/{external_store_id}
```

Returns the store, or `404 store_not_found`. The same path takes `PATCH` (change some fields) and `DELETE` (remove the store; it is kept for history, not erased).

## List stores

```
GET /v1/stores?limit=50&offset=0
```

Filter with `status` and `type`. Use it during setup to let the user pick the store a till belongs to.

## Create a store

```
POST /v1/stores
```

```json
{
  "external_store_id": "store12",
  "name": "Example Store Central",
  "timezone": "Europe/Stockholm",
  "type": "physical",
  "address": {
    "street1": "Exempelgatan 1",
    "postal_code": "111 22",
    "city": "Stockholm",
    "country": "SE"
  },
  "geo": { "latitude": 59.3326, "longitude": 18.0649 }
}
```

- `external_store_id`, `name` and `timezone` are required.
- Physical and pop-up stores need an address and a location. Online and warehouse stores do not.
- A second store with the same `external_store_id` answers `409`. Read the existing one instead.

Most brands set their stores up in the LoyX Portal. Create stores through the API only when your system is the brand's source of truth for them.

## On a sale

Put your code on the sale as `external.external_store_id`. LoyX maps it to the store. See [Record a sale](/guides/record-sale/).

The exact fields for each call are in the [API reference](/api/).
