# Detection & Response API

> Every endpoint Detection & Response serves on your realm's host, by area, with the page that explains each.

Every call here is made on your realm's own host with a realm administrator's session, sent as the
`x-cvyuh-token` cookie; [Call the API](../../develop/api/) shows how to get one. The session's user needs `RealmOwner`
or `RealmViewer` on the realm, or on a realm above it; a session that doesn't administer the realm is answered `403`.
Each call sees only your realm's devices and events.

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

## Common to every area

- **Sensor ids.** A device's sensor is named by its sensor id, which the API calls an `agent`: `agent=<sensor id>` in
  a query, `"agents": ["<sensor id>"]` in a body, `{agent}` in a path. Find it in the sensors list
  (`POST .../agents`, its `id`), or on the device's record in Endpoint Management as `dar.agentId` (see
  [Device records](../../endpoint-management/devices/device-records/)).
- **Ranges.** A range is `from` and `to` in the query, RFC 3339; left out, it's the last day.
- **Pages.** Every `POST` that answers a page takes paging, a sort, free text and a filter as its JSON body
  (`{"page": 1, "pageSize": 20}` at its simplest; up to 100 a page), and answers `data`, `totalPages` and
  `totalCount`. The body's grammar, with an example, is in
  [Security events](../security-log/events/#filter-search-and-sort); each table's `GET .../fields` lists the fields it
  filters on.
- **Errors** answer `{"code", "message"}`: `400` for a request the realm refuses, with the reason; `403` for a session
  that doesn't administer the realm; `404` for a sensor that isn't your realm's; `412` for a stale `revision`; `413` for
  a configuration over 512 KB; `502` when the security log can't answer, which is worth retrying.

## Detection

| Method | Endpoint | What it does | Page |
|---|---|---|---|
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/fim/summary` | Changes to monitored files over a range: by kind, and the paths and devices that change most | [File integrity](../detection/file-integrity/) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/fim/files?agent={agent}` | A page of one device's monitored files | [File integrity](../detection/file-integrity/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/fim/files/scan?agent={agent}` | When one device's last file scan ran | [File integrity](../detection/file-integrity/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/sca/policies?agent={agent}` | One device's hardening policies, with counts and score | [Configuration assessment](../detection/configuration-assessment/) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/sca/checks?agent={agent}&policy={policy}` | A page of one policy's checks | [Configuration assessment](../detection/configuration-assessment/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/mitre/matrix` | The realm's alerts over the ATT&CK matrix; `agent` for one device | [Threat mapping](../detection/threat-mapping/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/mitre/techniques/{technique}` | One ATT&CK technique, such as `T1110` | [Threat mapping](../detection/threat-mapping/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/inventory/summary` | The realm's inventory totals; `agent` for one device | [System inventory](../../endpoint-management/devices/system-inventory/) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/inventory/{kind}` | A page of one kind of inventory, such as `packages` or `ports` | [System inventory](../../endpoint-management/devices/system-inventory/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/inventory/{kind}/fields` | The fields one kind filters on | [System inventory](../../endpoint-management/devices/system-inventory/) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/vulnerabilities` | A page of known vulnerabilities; empty until vulnerability detection arrives | [What's next for detection](../detection/whats-next/#vulnerability-detection) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/vulnerabilities/summary` | Vulnerabilities by severity, and the devices, packages and CVEs most affected; empty for now | [What's next for detection](../detection/whats-next/#vulnerability-detection) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/vulnerabilities/fields` | The fields vulnerabilities filter on | [What's next for detection](../detection/whats-next/#vulnerability-detection) |

## Security log

| Method | Endpoint | What it does | Page |
|---|---|---|---|
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/overview` | The realm's devices by status, and its alerts over the range by level | [Security events](../security-log/events/) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/events` | A page of alerts; `preset` (`fim`, `sca`, `vulnerabilities`, `mitre`) for one slice, `agent` for one device | [Security events](../security-log/events/) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/events/summary` | The range's alerts by level over time, rule group and rule | [Security events](../security-log/events/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/events/fields` | The fields alerts filter on; `preset` for one slice's | [Security events](../security-log/events/) |

An alert carries:

| Field | What it holds |
|---|---|
| `id`, `time` | The alert's id, and when it was raised (RFC 3339) |
| `agent` | The device's sensor: `id`, `name`, `ip` |
| `rule.id`, `rule.description` | The rule that raised it, and what it describes |
| `rule.level` | 0 to 15; see [Alert levels](../security-log/events/#alert-levels) |
| `rule.groups` | The rule's groups, such as `authentication_failed`, `syscheck` or `sca` |
| `rule.firedTimes` | A running count of how often the rule has fired lately, a rough sign of repetition; for exact counts over a range use `POST .../events/summary` |
| `rule.mitre` | ATT&CK technique `ids`, `techniques` and `tactics` |
| `rule.compliance` | Controls by framework: `pciDss`, `gdpr`, `hipaa`, `nist80053`, `tsc` (SOC 2) |
| `file` | For a file change: `path`, `change`, `changedAttributes`, sizes, owner, group, permissions, checksums, and `diff` where reported |
| `location` | Where on the device the event came from, such as a log file's path |
| `decoder` | The kind of log the line was read as, such as `sshd` or `json` |
| `log` | The original log line |
| `data` | The fields read from the event, such as `srcip`, `srcuser` and `dstuser` |

Fields that don't apply to an alert are left out.

## Response

| Method | Endpoint | What it does | Page |
|---|---|---|---|
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/respond` | Send an active response, `blockIp`, `denyHost` or `disableAccount`, for a timeout | [Active response](../response/active-response/) |

It takes `{"agents", "response", "argument", "timeout"}`, `timeout` one of `60`, `900`, `3600` (the default),
`14400`, `43200` or `86400` seconds, and answers `{"done", "failed"}`. Responses run on Linux devices. Cutting a device off is
[Device revocation](../../endpoint-management/revoke-and-remove/revocation/), in the
[Endpoint Management API](../../endpoint-management/api/).

## Sensors

| Method | Endpoint | What it does | Page |
|---|---|---|---|
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents` | A page of the realm's sensors | [Sensor actions](../sensors/sensor-actions/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/summary` | The realm's sensors by status and operating system | [Sensor actions](../sensors/sensor-actions/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/{agent}` | One sensor: its host and its last configuration assessment | [Device view](../security-log/device-view/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/{agent}/configuration/{section}` | One sensor's running configuration: `files`, `logs` or `modules` | [Device view](../security-log/device-view/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/{agent}/stats` | One sensor's own counters | [Device view](../security-log/device-view/) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/restart` | Restart sensors | [Sensor actions](../sensors/sensor-actions/) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/upgrade` | Queue sensors' upgrades; not working yet: the device refuses them | [Sensor actions](../sensors/sensor-actions/#upgrading-a-sensor) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/upgrade/progress` | Where each sensor's upgrade stands: `queued`, `upgrading`, `done`, `failed` or `none` | [Sensor actions](../sensors/sensor-actions/#upgrading-a-sensor) |
| `POST` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/agents/remove` | Remove sensors' registrations; each device must enroll again | [Sensor actions](../sensors/sensor-actions/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group` | The realm's group and its files | [Group configuration](../sensors/group-configuration/) |
| `GET` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration` | The shared configuration: `xml` and its `revision` | [Configuration reference](../sensors/configuration-reference/) |
| `PUT` | `https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/group/configuration` | Write the shared configuration back whole, with the `revision` you read | [Group configuration](../sensors/group-configuration/) |

The actions take `{"agents": [...]}`, 1 to 100 of them, and answer `{"done", "failed"}`.
