# Group configuration

> One configuration that every security sensor in the realm shares, read and edited through the API, and pushed to each device.

Every sensor in your realm runs one shared configuration on top of its own defaults: which extra folders to watch,
which extra logs to read, and how often assessments and tamper checks run. Change it once, and every device in the
realm picks it up within a minute or two.

## Before you begin

- **Who:** an administrator of the realm, in a group holding `RealmOwner` on the realm or a realm above it (see
  [Delegated administration](../../../platform/realms/delegated-administration/)). Detection & Response doesn't yet
  tell `RealmViewer` apart from `RealmOwner`: a viewer can change this configuration too, so give `RealmViewer` only
  to people you'd trust to.
- **Where:** the API.
- **First:** the settings you can use are in the [Configuration reference](../configuration-reference/).

## How it works

The configuration is one text, in XML. When you save it, each device receives it over its own connection, checks it
arrived whole, applies it and restarts its sensor. A device that's offline receives it when it reconnects.

Every write names the `revision` it was read at, an opaque value the read gives you, so a change made over someone
else's is refused rather than silently lost.

## Set it up

Through the API ([Call the API](../../../develop/api/)), read the configuration:

```sh
curl https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

```json
{ "revision": "<revision>", "xml": "<agent_config>…</agent_config>" }
```

Write the whole text back, with the `revision` you read:

```sh
curl -X PUT https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H "Content-Type: application/json" \
  -d '{"xml": "<the whole configuration>", "revision": "<revision>"}'
```

The answer is the new `revision`. `GET https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group` lists the group's files,
each with its checksum. [Watch another folder on your devices](../../guides/watch-another-folder/) makes a change start
to finish.

## What happens when it fails

| Answer | Why | What to do |
|---|---|---|
| `400`, "can't run commands" | The text would run a command on a device | Remove it; see [what is refused](../configuration-reference/#what-is-refused) |
| `400`, with a reason and line | A setting or value the sensor doesn't take, or text that isn't well formed | Fix the line named |
| `412` | The configuration changed since you read it | Read it again, redo your change, write it with the new `revision` |
| `413` | The text is over 512 KB | Remove what you don't need |

Nothing reaches any device until a write succeeds.

## Limits and defaults

| Limit | Value |
|---|---|
| Configurations per realm | One, shared by every device in the realm |
| Size | 512 KB |
| Time to reach a connected device | Usually within two minutes |
| A new realm's configuration | Empty: devices run their defaults |

## Good to know

- **Whole text, every time.** A write replaces the configuration. Add your change to what you read.
- **No commands on your devices.** Nothing in the configuration can run a command on a device.
- **What one device runs.** See one device's running configuration in its [device view](../../security-log/device-view/).

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| A device doesn't show the change | It's offline, or hasn't reloaded yet | Check its status is `active`, wait two minutes, then restart its sensor ([Sensor actions](../sensor-actions/)) |
| Every write answers `412` | Another administrator, or a script, keeps writing | Read and write back in one step, as the guide's `jq` does |

## Audit record

None yet. Configuration writes aren't recorded in the realm's audit trail; keep the text you replaced, so you can put
it back and know what changed.

## Related

- [Configuration reference](../configuration-reference/): every setting, and what's refused.
- [File integrity](../../detection/file-integrity/), [Configuration assessment](../../detection/configuration-assessment/),
  [Log collection](../../detection/log-collection/): what the configuration sets.
- [Sensor actions](../sensor-actions/): restart sensors after a change.
