# Konsole: device-files

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

> 6 Operationen. Files on a device with a NeoDesk agent.

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.

Files on a device with a NeoDesk agent.

## POST /api/devices/{id}/files/browse

List a folder on a device.

Asks the NeoDesk agent over its connection. Needs the file transfer client feature. When the agent is offline, the route answers the snapshot the server keeps, or 202 with a collection queued for when it comes back (only for an account with agent.files).

Needs `agent.files`. `neodesk device-files list` calls it.

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

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `path` | string | The folder; empty for the top level; at most 4096 characters |
| `show_hidden` | boolean | default `false` |

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

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

**202**: The agent is offline; a collection is queued (`application/json`)

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

| 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 | There is no such item, or the account does not see it |
| 502 | The agent answered with an error |
| 503 | The agent is not connected (agent_offline) |
| 504 | The agent did not answer in time (agent_timeout) |

## POST /api/devices/{id}/files/delete

Delete a file or folder on a device.

Asks the NeoDesk agent over its connection. Needs the file transfer client feature. Written to the audit log.

Needs `agent.files`. `neodesk device-files delete` calls it. It cannot be undone.

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

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `path` | string | yes | at most 4096 characters |
| `recursive` | boolean |  | true to delete a folder with what it holds; default `false` |

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

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

| Error | When |
|---|---|
| 400 | The request 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 | There is no such item, or the account does not see it |
| 502 | The agent answered with an error |
| 503 | The agent is not connected (agent_offline) |
| 504 | The agent did not answer in time (agent_timeout) |

## POST /api/devices/{id}/files/mkdir

Make a folder on a device.

Asks the NeoDesk agent over its connection. Needs the file transfer client feature. Written to the audit log.

Needs `agent.files`. `neodesk device-files mkdir` calls it.

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

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `path` | string | yes | at most 4096 characters |
| `recursive` | boolean |  | Make the missing folders above it too; default `true` |

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

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

| Error | When |
|---|---|
| 400 | The request 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 | There is no such item, or the account does not see it |
| 502 | The agent answered with an error |
| 503 | The agent is not connected (agent_offline) |
| 504 | The agent did not answer in time (agent_timeout) |

## POST /api/devices/{id}/files/read

Read a file on a device (up to 1 MB per call).

Asks the NeoDesk agent over its connection. Needs the file transfer client feature. When the agent is offline, a read is queued and the route answers 202.

Needs `agent.files`. `neodesk device-files read` calls it.

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

Request body, `application/json`:

| Field | Type | What it is |
|---|---|---|
| `path` | string | at most 4096 characters |
| `offset` | integer | Where to start, in bytes; default `0`, at least 0 |
| `length` | integer | How many bytes; default `65536`, at least 0, at most 1048576 |

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

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

**202**: The agent is offline; a collection is queued (`application/json`)

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

| 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 | There is no such item, or the account does not see it |
| 502 | The agent answered with an error |
| 503 | The agent is not connected (agent_offline) |
| 504 | The agent did not answer in time (agent_timeout) |

## POST /api/devices/{id}/files/rename

Rename or move a file on a device.

Asks the NeoDesk agent over its connection. Needs the file transfer client feature. Written to the audit log.

Needs `agent.files`. `neodesk device-files rename` calls it.

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

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `from` | string | yes | at most 4096 characters |
| `to` | string | yes | at most 4096 characters |

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

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

| Error | When |
|---|---|
| 400 | The request 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 | There is no such item, or the account does not see it |
| 502 | The agent answered with an error |
| 503 | The agent is not connected (agent_offline) |
| 504 | The agent did not answer in time (agent_timeout) |

## POST /api/devices/{id}/files/write

Write a file on a device.

Asks the NeoDesk agent over its connection. Needs the file transfer client feature. Written to the audit log.

Needs `agent.files`. `neodesk device-files write` calls it.

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

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `path` | string | yes | at most 4096 characters |
| `data` | string |  | The content |
| `mode` | string, one of `overwrite`, `append`, `create` |  | default `"overwrite"` |

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

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

| Error | When |
|---|---|
| 400 | The request 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 | There is no such item, or the account does not see it |
| 413 | data is longer than 22 Mi characters |
| 502 | The agent answered with an error |
| 503 | The agent is not connected (agent_offline) |
| 504 | The agent did not answer in time (agent_timeout) |
