# Create Configuration

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

Creates a named configuration on a key and returns it.

## Example request

**curl**

```bash
curl -X POST 'https://api.addresszen.com/v1/keys/ak_test/configs?user_token=uk_secret' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "woocommerce",
    "payload": "{\"removeOrganisation\": false}"
  }'
```

**JavaScript**

```javascript
import { createZenClient, createConfig } from '@addresszen/sdk';

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

const { data } = await createConfig({
  client,
  path: { key: 'ak_test' },
  body: {
    name: 'woocommerce',
    payload: '{"removeOrganisation": false}',
  },
});
```

**Python**

```python
# pip install addresszen
import json

from addresszen import AddressZen

with AddressZen("ak_test") as client:
    result = client.create_config(
        "ak_test",
        user_token="uk_secret",
        name="woocommerce",
        payload=json.dumps({"removeOrganisation": False}),
    )
```

**Ruby**

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

uri = URI("https://api.addresszen.com/v1/keys/ak_test/configs?user_token=uk_secret")
body = {
  name: "woocommerce",
  payload: '{"removeOrganisation": false}',
}
response = Net::HTTP.post(uri, body.to_json, "Content-Type" => "application/json")
result = JSON.parse(response.body)["result"]
```

**PHP**

```php
<?php
$ch = curl_init("https://api.addresszen.com/v1/keys/ak_test/configs?user_token=uk_secret");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
  CURLOPT_POSTFIELDS => json_encode([
    "name" => "woocommerce",
    "payload" => '{"removeOrganisation": false}',
  ]),
  CURLOPT_RETURNTRANSFER => true,
]);
$result = json_decode(curl_exec($ch), true)["result"];
```

## Example body

```json
{
  "name": "woocommerce",
  "payload": "{\n  \"removeOrganisation\": false\n}\n"
}
```

## Example response

**200 OK**

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

## 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://addresszen.com/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`

## Request body

The request body must contain a JSON object with:

* `body` ConfigNewParam

  Required configuration object parameters

  * `name` string required

    A unique name to identify the configuration payload

    Example: `woocommerce`

  * `payload` string required

    A serialized payload of up to `65536` characters

    Example: `{ "removeOrganisation": false }`

## Response

Returns the created configuration object with timestamps and assigned name.

* `result` Config

  | 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.
