# Advanced Configuration

Configure advanced group behaviors for specialized SIM deployments.

In general, Group configuration through the User Console is sufficient for most use cases. However, in some cases you may want to configure groups programmatically using the Soracom API, or with the Soracom CLI in order to store configuration parameters in separate files.

As Group configuration options on the User Console are separated by **namespace** (Air, Beam, Funnel, Funk, Harvest, etc.), advanced configuration through the API or CLI is also separated into corresponding namespaces. When configuring multiple namespaces, each configuration must be made separately.

## Configuration Structure

When a Group is created, it receives a configuration that looks something like this:

```json
{
  "operatorId": "OP0012345678",
  "groupId": "abcdef00-0000-0000-0000-000012345678",
  "tags": {
    "name": "my-group"
  },
  "configuration": {
    "SoracomAir": {
      "binaryParserEnabled": false,
      "dnsServers": [],
      "useCustomDns": false,
      "useVpg": false,
      // ... additional Soracom Air configuration
    },
    "SoracomHarvest": {
      "enabled": false
    },
    // ... additional namespaces
  }
}
```

Each namespace (in this example, `SoracomAir` and `SoracomHarvest`) is an object that contains several key-value pairs which define the configuration settings of that namespace for the group.

## Available Namespaces

Details of each namespace and possible values are described in the Advanced Configuration page of their respective corresponding service:

- `SoracomAir` namespace:

  - [Air for Cellular: Custom DNS](https://docs.soracom.io/en/services/air/custom-dns)
  - [Air for Cellular: Metadata Service](https://docs.soracom.io/en/services/air/metadata-service)
  - [Air for Cellular: Virtual Private Gateway](https://docs.soracom.io/en/services/air/vpg)
  - [Air: Binary Parser](https://docs.soracom.io/en/services/binary-parser)

- `SoracomBeam` namespace:

  - [HTTP Entry Point](https://docs.soracom.io/en/services/beam/http)
  - [Website Entry Point](https://docs.soracom.io/en/services/beam/website)
  - [MQTT Entry Point](https://docs.soracom.io/en/services/beam/mqtt)
  - [TCP → TCP/TCPS Entry Point](https://docs.soracom.io/en/services/beam/tcp-tcp)
  - [TCP → HTTP/HTTPS Entry Point](https://docs.soracom.io/en/services/beam/tcp-http)
  - [UDP → HTTP/HTTPS Entry Point](https://docs.soracom.io/en/services/beam/udp-http)
  - [SMS → HTTP/HTTPS Entry Point](https://docs.soracom.io/en/services/beam/sms-http)
  - [USSD → HTTP/HTTPS Entry Point](https://docs.soracom.io/en/services/beam/ussd-http)
  - Sigfox → HTTP/HTTPS Entry Point (see [Beam Configuration](https://docs.soracom.io/en/services/beam/configuration#air-for-sigfox-and-air-for-lora))
  - LoRa → HTTP/HTTPS Entry Point (see [Beam Configuration](https://docs.soracom.io/en/services/beam/configuration#air-for-sigfox-and-air-for-lora))
  - [Inventory → HTTP/HTTPS Entry Point](https://docs.soracom.io/en/services/inventory/resource-observation)

- `SoracomEndorse` namespace:
  - [Endorse Configuration](https://docs.soracom.io/en/services/endorse/configuration)

- `SoracomFunk` namespace:
  - [Funk Configuration](https://docs.soracom.io/en/services/funk/configuration)

- `SoracomFunnel` namespace:

  - [TCP Entry Point](https://docs.soracom.io/en/services/funnel/tcp)
  - [UDP Entry Point](https://docs.soracom.io/en/services/funnel/udp)
  - [HTTP Entry Point](https://docs.soracom.io/en/services/funnel/http)
  - SMS Entry Point (see [Funnel Configuration](https://docs.soracom.io/en/services/funnel/configuration))
  - USSD Entry Point (see [Funnel Configuration](https://docs.soracom.io/en/services/funnel/configuration))

- `SoracomHarvest` namespace:
  - [Harvest Data Configuration](https://docs.soracom.io/en/services/harvest/configuration)

- `SoracomHarvestFiles` namespace:
  - [Harvest Files Configuration](https://docs.soracom.io/en/services/harvest/configuration)

- `SoracomKrypton` namespace:
  - [Krypton Configuration](https://docs.soracom.io/en/services/krypton/configuration)

- `SoracomOrbit` namespace:
  - [Orbit Configuration](https://docs.soracom.io/en/services/orbit/configuration)

## Programmatic Usage

Advanced configuration allows you to modify those key-value pairs using the Soracom API or Soracom CLI. However, rather than specifying the _entire_ object, each key-value pair is passed in separately in an array, and in turn updated individually, so as not to affect other key-value pairs.

For example, in the sample above, to set and enable Custom DNS, we only need to modify the `dnsServers` and `useCustomDns` keys within the **SoracomAir** namespace. We can serialize the relevant **key**s and **value**s into an array of objects, like so:

```json
[
  {
    "key": "dnsServers",
    "value": [
      "8.8.8.8",
      "8.8.4.4"
    ]
  },
  {
    "key": "useCustomDns",
    "value": true
  }
]
```

Then we just pass this data into the **SoracomAir** namespace using the Soracom API or Soracom CLI, and our group configuration will be updated accordingly.

### Soracom API

To access the Soracom API, first use the [**auth**](https://docs.soracom.io/en/api#!/Auth/auth) API to obtain an API Key and Token. Refer to the [**API Usage Guide**](https://docs.soracom.io/en/developers/soracom-api) for instructions on how to use the API Key and Token in API requests.

Then, use the [putConfigurationParameters](https://docs.soracom.io/en/api#!/Group/putConfigurationParameters) API with the `SoracomAir` namespace to update the group configuration:

**Global**

```bash
curl -X PUT \
  -H 'X-Soracom-API-Key: <MY-API-KEY>' \
  -H 'X-Soracom-Token: <MY-TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '[
        {
          "key": "useCustomDns",
          "value": true
        },
        {
          "key": "dnsServers",
          "value": [
            "8.8.8.8",
            "8.8.4.4"
          ]
        }
      ]' \
  https://g.api.soracom.io/v1/groups/<GROUP-ID>/configuration/SoracomAir
```

**Japan**

```bash
curl -X PUT \
  -H 'X-Soracom-API-Key: <MY-API-KEY>' \
  -H 'X-Soracom-Token: <MY-TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '[
        {
          "key": "useCustomDns",
          "value": true
        },
        {
          "key": "dnsServers",
          "value": [
            "8.8.8.8",
            "8.8.4.4"
          ]
        }
      ]' \
  https://jp.api.soracom.io/v1/groups/<GROUP-ID>/configuration/SoracomAir
```

### Soracom CLI

To use the Soracom CLI, you must first configure it to authenticate with your account information, authorization key, or SAM user credentials.

Then, run the following command while specifying the `SoracomAir` namespace to update the group configuration:

**Global**

```bash
soracom groups put-config --group-id '<GROUP-ID>' --namespace 'SoracomAir' \
  --body '[ {"key":"dnsServers","value":["8.8.8.8","8.8.4.4"]}, {"key":"useCustomDns","value":true} ]' --coverage-type g
```

**Japan**

```bash
soracom groups put-config --group-id '<GROUP-ID>' --namespace 'SoracomAir' \
  --body '[ {"key":"dnsServers","value":["8.8.8.8","8.8.4.4"]}, {"key":"useCustomDns","value":true} ]' --coverage-type jp
```
