# Update Configuration

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

Replaces a configuration's payload and returns the updated configuration. The name is fixed at creation.

## Example request

**curl**

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

**JavaScript**

```javascript
const response = await fetch('https://api.addresszen.com/v1/keys/ak_test/configs/woocommerce?user_token=uk_secret', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    payload: '{"removeOrganisation": true}',
  }),
});

const { result } = await response.json();
```

**Python**

```python
import requests

response = requests.post(
    "https://api.addresszen.com/v1/keys/ak_test/configs/woocommerce",
    params={"user_token": "uk_secret"},
    json={
        "payload": "{\"removeOrganisation\": true}",
    },
)
result = response.json()["result"]
```

**Ruby**

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

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

## Example body

```json
{
  "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 to retrieve. Begins `ak_`.

  Example: `ak_test`

* `config` string

  **Configuration Name**

  User-provided configuration object name.

  Example: `checkout-form`

## Query parameters

* `user_token` string optional

  **Private User Token**

  A secret key used for sensitive operations on your account and API Keys.

  Your user token can be retrieved and managed from your [accounts page](https://addresszen.com/account).

  Typically begins `uk_...`

  Example: `uk_B59ScW1p1HHouf1VqclEPZUx`

## Request body

The request body must contain a JSON object with:

* `body` ConfigUpdateParam

  Config object update parameters

  * `payload` string optional

    A serialized payload of up to `65536` characters

    Example: `{ "removeOrganisation": false }`

## Response

Returns the updated configuration object with refreshed timestamps.

* `result` Config

  | Field       | Type   | Description                                                                                  |
  | ----------- | ------ | -------------------------------------------------------------------------------------------- |
  | `updatedAt` | string | Timestamp for when the config was created. Example: `2016-01-21T17:14:49.971Z`               |
  | `createdAt` | string | Timestamp for when the config was updated. 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.
