# List Configurations

**GET** `/v1/keys/{key}/configs`

Returns every configuration stored against a key, oldest first.

## Example request

**URL**

```http
https://api.ideal-postcodes.co.uk/v1/keys/ak_test/configs?user_token=uk_secret
```

**curl**

```bash
curl -G 'https://api.ideal-postcodes.co.uk/v1/keys/ak_test/configs' \
  -d 'user_token=uk_secret'
```

**JavaScript**

```javascript
import { createIdpcClient, listConfigs } from '@ideal-postcodes/sdk';

const client = createIdpcClient({ apiKey: 'ak_test', userToken: 'uk_secret' });

const { data } = await listConfigs({
  client,
  path: { key: 'ak_test' },
});
```

**Python**

```python
# pip install ideal-postcodes
from ideal_postcodes import IdealPostcodes

with IdealPostcodes("ak_test") as client:
    result = client.list_configs("ak_test", user_token="uk_secret")
```

**Ruby**

```ruby
require "net/http"
require "json"

uri = URI("https://api.ideal-postcodes.co.uk/v1/keys/ak_test/configs")
uri.query = URI.encode_www_form(user_token: "uk_secret")
result = JSON.parse(Net::HTTP.get(uri))["result"]
```

**PHP**

```php
<?php
// composer require ideal-postcodes/sdk
use IdealPostcodes\IdealPostcodes;

$client = IdealPostcodes::client('ak_test', 'uk_secret');
$result = $client->listConfigs('ak_test')->result;
```

## Example response

**200 OK**

```json
{
  "result": {
    "configs": [
      {
        "updatedAt": "2016-01-21T17:14:49.971Z",
        "createdAt": "2016-01-21T17:14:49.971Z",
        "name": "woocommerce",
        "payload": "{\n  \"removeOrganisation\": false\n}\n"
      }
    ]
  },
  "message": "Success",
  "code": 2000
}
```

## Path parameters

* `key` string

  **API Key**

  The API Key. Begins `ak_`.

  Example: `ak_test`

## Query parameters

* `user_token` string optional

  **Management Key**

  A secret key used to manage your account and API Keys. It was previously called the user token.

  Your management key can be retrieved and managed from your [accounts page](https://account.ideal-postcodes.co.uk/account).

  Typically begins `uk_`. Prefer sending it in the `Authorization` header as `Bearer uk_...` instead of this query parameter. The `Authorization: user_token="uk_..."` header also works.

  Example: `uk_B59ScW1p1HHouf1VqclEPZUx`

## Response

`result` contains a `configs` array of configuration objects. Each config has a unique name, timestamps and the serialised payload.

* `result` object

  List of configurations

  * `configs` object\[]

    | Field       | Type   | Description                                                                                  |
    | ----------- | ------ | -------------------------------------------------------------------------------------------- |
    | `updatedAt` | string | Timestamp for when the config was last updated. Example: `2016-01-21T17:14:49.971Z`          |
    | `createdAt` | string | Timestamp for when the config was created. Example: `2016-01-21T17:14:49.971Z`               |
    | `name`      | string | A unique name to identify the configuration payload. Example: `woocommerce`                  |
    | `payload`   | string | A serialised payload of up to `65536` characters. Example: `{ "removeOrganisation": false }` |

The `result` sits inside the standard `{ result, code, message }` envelope, see the [API reference](/docs/api/api-reference.md) for the wrapper format.
