# Konsole: dataguard

Quelle: https://docs.neode.sk/de/development/api-reference/console-dataguard/
Zuletzt geändert: 2026-12-03

> 7 Operationen. Data guard policies and the events devices report.

Diese Routen liegen auf der Konsole, Port 3375. Sie nehmen ein API-Token als `Authorization: Bearer ndt_...`; siehe [API-Tokens](https://docs.neode.sk/de/command-line/api-tokens.md). Die Beschreibungen stehen auf Englisch, wie in der OpenAPI-Beschreibung.

Data guard policies and the events devices report.

## GET /api/dataguard/events

List the events devices reported, newest first.

Events of every device, not only those the account may see. Errors other than the sign-in and permission checks are {"error": "..."}.

Needs `audit.view`. `neodesk dataguard events` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `device_id` | query | string |  |
| `event_source` | query | string |  |
| `event_type` | query | string |  |
| `limit` | query | integer | default `500`, at least 1, at most 500 |
| `from` | query | string | Only events from this time on: a date or a date and time, with or without a zone (none is UTC) |
| `to` | query | string | Only events before this time; a date alone takes in that whole day |

**200**: Done (`application/json`)

An array of object; each item:

| Field | Type | What it is |
|---|---|---|
| `[].id` | integer |  |
| `[].device_id` | string |  |
| `[].event_source` | string |  |
| `[].event_type` | string |  |
| `[].policy_id` | integer or null |  |
| `[].policy_name` | string or null |  |
| `[].action` | string |  |
| `[].details` |  | What the device reported about the event, as JSON |
| `[].created_at` | string (date-time) |  |

| Error | When |
|---|---|
| 400 | limit, from or to is not valid |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/dataguard/policies

List data guard policies.

Errors other than the sign-in and permission checks are {"error": "..."}.

Needs `device.view`. `neodesk dataguard list` calls it.

**200**: Done (`application/json`)

Array of [DataGuardPolicy](https://docs.neode.sk/de/development/api-reference/schemas.md#dataguardpolicy).

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## POST /api/dataguard/policies

Make a data guard policy.

null for a text takes its default. Errors other than the sign-in and permission checks are {"error": "..."}.

Needs `server.config`. `neodesk dataguard create` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `name` | string | yes |  |
| `description` | string or null |  |  |
| `policy_type` | string or null |  | What the policy watches, such as usb or file |
| `action` | string or null |  | log or block (default log) |
| `scope` | string or null |  | Empty or all for every device, else device IDs separated by commas |
| `enabled` | boolean or integer, one of `true`, `false`, `1`, `0` |  | Without it a new policy is on |
| `rules` | array of object |  |  |
| `rules[].action` | string |  |  |
| `rules[].filter` | string |  |  |
| `rules[].rule_type` | string |  |  |

**201**: Made (`application/json`)

[DataGuardPolicy](https://docs.neode.sk/de/development/api-reference/schemas.md#dataguardpolicy).

| Error | When |
|---|---|
| 400 | A field is not valid (Policy name is required, rules must be an array, Invalid &lt;field>) |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |

## GET /api/dataguard/policies/{id}

Show one data guard policy.

Errors other than the sign-in and permission checks are {"error": "..."}.

Needs `device.view`. `neodesk dataguard get` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The policy ID |

**200**: Done (`application/json`)

[DataGuardPolicy](https://docs.neode.sk/de/development/api-reference/schemas.md#dataguardpolicy).

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 404 | Policy not found |

## PATCH /api/dataguard/policies/{id}

Change a data guard policy.

Writes every field the body has; a body without any answers the policy as it is. Only scope may be null here. Errors other than the sign-in and permission checks are {"error": "..."}.

Needs `server.config`. `neodesk dataguard update` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The policy ID |

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `name` | string |  |
| `description` | string |  |
| `policy_type` | string |  |
| `action` | string | log or block |
| `scope` | string or null | Empty or all for every device, else device IDs separated by commas |
| `enabled` | boolean or integer, one of `true`, `false`, `1`, `0` |  |
| `rules` | array of object |  |
| `rules[].action` | string |  |
| `rules[].filter` | string |  |
| `rules[].rule_type` | string |  |

**200**: Done (`application/json`)

[DataGuardPolicy](https://docs.neode.sk/de/development/api-reference/schemas.md#dataguardpolicy).

| Error | When |
|---|---|
| 400 | A field is not valid |
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 404 | Policy not found |

## DELETE /api/dataguard/policies/{id}

Delete a data guard policy.

Errors other than the sign-in and permission checks are {"error": "..."}.

Needs `server.config`. `neodesk dataguard delete` calls it. It cannot be undone.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | string | yes | The policy ID |

**200**: Done (`application/json`)

| Field | Type | Required |
|---|---|---|
| `ok` | `true` | yes |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
| 404 | Policy not found |

## GET /api/dataguard/stats

Count the events devices reported, by action, source and policy.

Counts the events of every device. Errors other than the sign-in and permission checks are {"error": "..."}.

Needs `audit.view`. `neodesk dataguard stats` calls it.

**200**: Done (`application/json`)

| Field | Type | What it is |
|---|---|---|
| `total` | integer |  |
| `blocked` | integer |  |
| `logged` | integer |  |
| `usb_events` | integer |  |
| `file_events` | integer |  |
| `by_policy` | object | Events per policy ID |

| Error | When |
|---|---|
| 401 | No session or API token, or one that is not valid (code session_required or token_invalid) |
| 403 | The account or the token may not do this, or a write from a browser came without a good CSRF token |
