# List all coupon codes

Source: https://developers.swell.is/backend-api/coupon-codes/list-all-coupon-codes

Return a list of coupon codes.

## Arguments

- `expand` (string): Expand link fields and child collections by using the expand argument.

  - For example, `expand=account` would return a related customer account if one exists.

  When the field represents a collection, you can specify the query limit.

  - For example, `expand=variants:10` would return up to 10 records of the variants collection.

  See [expanding](https://developers.swell.is/backend-api/querying/expanding) for more details.
- `fields` (string): Returns only the specified fields in the result.

  - For example `fields=name,slug` would return only the fields `name` and `slug` in the response.

  Supports nested object and array fields using dot-notation.

  - For example, `items.product_id`. The product `id` is always returned.
- `include` (object): Include one or more arbitrary queries in the response which are potentially related to the main query.

  See [including](https://developers.swell.is/backend-api/querying/including) for more details.
- `limit` (int): Limit the number of records returned, ranging between `1` and `1000`. Defaults to `15`. Default: `15`.
- `page` (int): The page number of results to return given the specified or default `limit`.
- `search` (string): A text search is performed using the search argument. Searchable fields are defined by the model.

  - For example, `search=red` would return records containing the word "red" anywhere in the defined text fields.

  See [searching](https://developers.swell.is/backend-api/querying/searching) for more details.
- `sort` (string): Expression to sort results by using a format similar to a SQL sort statement.

  - For example, `sort=name asc` would return records sorted by name ascending.

  See [sorting](https://developers.swell.is/backend-api/querying/sorting) for more details.
- `where` (object): An object with criteria to filter the result.

  - For example, `active=true` would return records containing a field `active` with the value `true`.

  It's also possible to use query operators, for example, `$eq`, `$ne`, `$gt`, and more.

  See [querying](https://developers.swell.is/backend-api/querying) for more details.

## Example request

`GET /coupons:codes`

**cURL**

```sh
$ curl https://api.swell.store/coupons:codes\
  -u store-id:secret-key \
  -G
```

**Node**

```javascript
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');

await swell.get('/coupons:codes', {
});
```

**PHP**

```php
<?php $swell = new \Swell\Client('store-id', 'secret-key');

$swell->get('/coupons:codes', [
]);
```

## Example response

```json
{
  "count": 30,
  "results": [
    {
      "code": "FREESKOOMA",
      "parent_id": "62cc86897ad4f100132c953d",
      "use_count": 0,
      "date_created": "2022-07-11T20:22:33.332Z",
      "use_total": 0,
      "date_updated": "2022-07-18T20:42:32.978Z",
      "id": "62cc86897ad4f100132c953e"
    },
    {
      "code": "ARROW2THEKNEE",
      "parent_id": "62a0e2f0473e110013059e9b",
      "use_count": 0,
      "date_created": "2022-06-08T17:57:04.786Z",
      "use_total": 0,
      "id": "62a0e2f0473e110013059e9c"
    },
    {
      "code": "DAGOTHWAVE",
      "parent_id": "62857220dad145001973af16",
      "use_count": 0,
      "date_created": "2022-05-18T22:24:32.130Z",
      "use_total": 0,
      "id": "62857220dad145001973af17"
    },
    {
      "code": "SHIVERINGISLES",
      "parent_id": "628557a32e8aca00180b80d3",
      "use_count": 0,
      "date_created": "2022-05-18T20:31:31.818Z",
      "use_total": 0,
      "date_updated": "2022-05-18T22:23:55.655Z",
      "id": "628557a32e8aca00180b80d4"
    },
    {
      "code": "STOPRIGHTTHERE",
      "parent_id": "6164a07f1f39735b268ebc92",
      "use_count": 5,
      "date_created": "2021-10-11T20:37:19.360Z",
      "use_total": 5,
      "date_updated": "2022-02-07T16:16:08.484Z",
      "id": "6164a07f1f39735b268ebc9b"
    }
  ],
  "page": 1,
  "page_count": 2,
  "limit": 15,
  "pages": {
    "1": {
      "start": 1,
      "end": 15
    },
    "2": {
      "start": 16,
      "end": 30
    }
  }
}
```
