# Console: device-fields

Source: https://docs.neode.sk/development/api-reference/console-device-fields/
Last updated: 2026-12-03

> 14 operations. Fields admins define for devices (customer, contract, warranty date) and their values.

These routes are on the console, port 3375. They take an API token as `Authorization: Bearer ndt_...`; see [API tokens](https://docs.neode.sk/command-line/api-tokens.md).

Fields admins define for devices (customer, contract, warranty date) and their values.

## GET /api/device-fields

List the device fields the account sees: the server's, then each organization's.

Restricted fields only with device.fields_restricted (a manager sees their definitions, never values); an organization's fields only for its members and the server-level roles.

Needs `device.view`. `neodesk device-fields list` calls it.

**200**: The fields and what the account may do (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.fields` | array of [DeviceField](https://docs.neode.sk/development/api-reference/schemas.md#devicefield) | yes |
| `data.can_edit` | boolean |  |
| `data.can_manage_server` | boolean |  |
| `data.managed_orgs` | array of string |  |
| `data.sees_restricted` | boolean |  |
| `data.limits` | object |  |
| `data.types` | array of string |  |

| 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 |
| 500 | Something failed on the server (the text of errors.server_error) |

## POST /api/device-fields

Add a device field for the whole server or one organization.

At most 50 fields for the server and 50 per organization. Server fields need a server-level role; an organization's owners and admins add its fields. Writes device_field_created to the audit log.

Needs `device.fields_edit`. `neodesk device-fields add` calls it.

Request body, `application/json`:

[DeviceFieldInput](https://docs.neode.sk/development/api-reference/schemas.md#devicefieldinput).

**201**: The new field (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.field` | [DeviceField](https://docs.neode.sk/development/api-reference/schemas.md#devicefield) | yes |

| Error | When |
|---|---|
| 400 | The body or a value doesn't fit; code device_field_&lt;reason>, such as device_field_value_misfit, device_field_unknown_field (also for a field the account doesn't see), device_field_required |
| 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 |
| 409 | The key is taken (device_field_key_taken) or the scope has 50 fields (device_field_too_many_fields) |
| 500 | Something failed on the server (the text of errors.server_error) |

## PUT /api/device-fields/order

Put the server's or an organization's device fields in a new order.

ids must name every field of the scope once. Writes device_fields_reordered to the audit log.

Needs `device.fields_edit`. `neodesk device-fields order` calls it.

Request body, `application/json`:

| Field | Type | Required |
|---|---|---|
| `org_id` | string |  |
| `ids` | array of integer | yes |

**200**: The field list, as GET /api/device-fields (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |

| Error | When |
|---|---|
| 400 | The body or a value doesn't fit; code device_field_&lt;reason>, such as device_field_value_misfit, device_field_unknown_field (also for a field the account doesn't see), device_field_required |
| 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 |
| 500 | Something failed on the server (the text of errors.server_error) |

## GET /api/device-fields/values

List device field values of a selection of devices, or of the devices a filter keeps.

Only devices and fields the account sees. A filter by a field the account doesn't see is refused like one by a key that doesn't exist. Numbers and dates compare as numbers and dates.

Needs `device.view`. `neodesk device-fields values` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `device` | query | array of string | A device ID; repeat for more (left out: every device the account sees) |
| `f` | query | array of string | A condition key:operator:value (eq, contains, min, max) or key:empty, key:notempty; repeat to combine |

**200**: The values by device (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.keys` | array of string |  |
| `data.devices` | array of object |  |
| `data.devices[].device_id` | string |  |
| `data.devices[].values` | object |  |
| `data.total` | integer |  |

| Error | When |
|---|---|
| 400 | The body or a value doesn't fit; code device_field_&lt;reason>, such as device_field_value_misfit, device_field_unknown_field (also for a field the account doesn't see), device_field_required |
| 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 | A named device doesn't exist or the account doesn't see it (device_field_device_not_found) |
| 500 | Something failed on the server (the text of errors.server_error) |

## POST /api/device-fields/bulk

Set or clear one field on many devices.

Every device must be one the account sees. Devices outside the field's organization are skipped and listed. One audit entry per changed value.

Needs `device.fields_edit`. `neodesk device-fields bulk` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `devices` | array of string | yes | at most 10000 items |
| `key` | string | yes |  |
| `value` | [DeviceFieldValue](https://docs.neode.sk/development/api-reference/schemas.md#devicefieldvalue) |  |  |
| `clear` | boolean |  |  |

**200**: What changed (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.key` | string |  |
| `data.changed` | integer |  |
| `data.unchanged` | integer |  |
| `data.skipped` | array of string |  |

| Error | When |
|---|---|
| 400 | The body or a value doesn't fit; code device_field_&lt;reason>, such as device_field_value_misfit, device_field_unknown_field (also for a field the account doesn't see), device_field_required |
| 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 | A device doesn't exist or the account doesn't see it (device_field_device_not_found) |
| 500 | Something failed on the server (the text of errors.server_error) |

## GET /api/device-fields/{id}

Show one device field, with how many devices have a value of it (for a manager).

value_count only for accounts that manage the field.

Needs `device.view`. `neodesk device-fields show` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | integer | yes | The field ID |

**200**: The field (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.field` | [DeviceField](https://docs.neode.sk/development/api-reference/schemas.md#devicefield) | 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 | No such field, or one the account doesn't see (device_field_not_found) |
| 500 | Something failed on the server (the text of errors.server_error) |

## PATCH /api/device-fields/{id}

Change a device field.

A new type, one value instead of several, or a value taken off a choice list must fit every stored value; otherwise nothing changes. A renamed choice is renamed on every device. Writes device_field_changed to the audit log.

Needs `device.fields_edit`. `neodesk device-fields change` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | integer | yes | The field ID |

Request body, `application/json`:

[DeviceFieldInput](https://docs.neode.sk/development/api-reference/schemas.md#devicefieldinput).

**200**: The changed field and how many values were converted (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.field` | [DeviceField](https://docs.neode.sk/development/api-reference/schemas.md#devicefield) |  |
| `data.converted` | integer |  |

| Error | When |
|---|---|
| 400 | The body or a value doesn't fit; code device_field_&lt;reason>, such as device_field_value_misfit, device_field_unknown_field (also for a field the account doesn't see), device_field_required |
| 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 | No such field (device_field_not_found) |
| 409 | Stored values don't fit the change (device_field_type_misfit, with count) |
| 500 | Something failed on the server (the text of errors.server_error) |

## DELETE /api/device-fields/{id}

Delete a device field and every device's value of it.

When devices have a value it needs confirm=true. Writes device_field_deleted to the audit log with the number of values.

Needs `device.fields_edit`. `neodesk device-fields delete` calls it.

| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
| `id` | path | integer | yes | The field ID |
| `confirm` | query | string, one of `true` |  | true deletes the values too |

**200**: What was deleted (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.deleted` | integer |  |
| `data.values` | integer |  |

| 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 | No such field (device_field_not_found) |
| 409 | Devices have a value and confirm=true is missing (device_field_has_values, with count) |
| 500 | Something failed on the server (the text of errors.server_error) |

## GET /api/devices/{id}/fields

Show a device's fields and values.

The fields the account sees that apply to the device.

Needs `device.view`. `neodesk device-fields get` calls it.

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

**200**: The device's fields (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.device_id` | string | yes |
| `data.fields` | array of [DeviceField](https://docs.neode.sk/development/api-reference/schemas.md#devicefield) and object | yes |
| `data.changed` | integer |  |

| 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 | No such device, or one the account doesn't see (device_field_device_not_found) |
| 500 | Something failed on the server (the text of errors.server_error) |

## PUT /api/devices/{id}/fields

Set or clear a device's field values.

Every value is checked first; one that doesn't fit changes nothing. A required field can't be cleared. One audit entry per changed value (a restricted field's without the values).

Needs `device.fields_edit`. `neodesk device-fields set` 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 |
|---|---|---|---|
| `values` | object | yes | key to value; null or "" clears |

**200**: The device's fields after the change (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.device_id` | string | yes |
| `data.fields` | array of [DeviceField](https://docs.neode.sk/development/api-reference/schemas.md#devicefield) and object | yes |
| `data.changed` | integer |  |

| Error | When |
|---|---|
| 400 | The body or a value doesn't fit; code device_field_&lt;reason>, such as device_field_value_misfit, device_field_unknown_field (also for a field the account doesn't see), device_field_required |
| 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 | No such device (device_field_device_not_found) |
| 500 | Something failed on the server (the text of errors.server_error) |

## GET /api/device-fields/tag-conversion

Show which tags name:value could become device fields, with the devices and values.

Tags of the devices the account sees, grouped by name in any letter case. Needs a server-level role with device.fields_edit.

Needs `device.fields_edit`. `neodesk device-fields tags` calls it.

**200**: The tag groups (`application/json`)

| Field | Type | Required | What it is |
|---|---|---|---|
| `success` | `true` | yes |  |
| `data` | object | yes |  |
| `data.groups` | array of [DeviceFieldTagGroup](https://docs.neode.sk/development/api-reference/schemas.md#devicefieldtaggroup) | yes |  |
| `data.field_count` | integer |  | How many fields the server has of its own |
| `data.max_fields` | integer |  |  |
| `data.max_text` | integer |  |  |

| 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 |
| 500 | Something failed on the server (the text of errors.server_error) |

## POST /api/device-fields/tag-conversion

Turn tags name:value into device fields and set each device's value from its tag.

Creates a text field of the whole server per chosen name, with key and label as given or as proposed, and sets each device's value. Everything is checked first; a refusal changes nothing. The tags stay as they are. Writes device_field_created per field and device_field_value_changed per value to the audit log. Needs a server-level role with device.fields_edit.

Needs `device.fields_edit`. `neodesk device-fields from-tags` calls it.

Request body, `application/json`:

| Field | Type | Required | What it is |
|---|---|---|---|
| `fields` | array of object | yes |  |
| `fields[].name` | string | yes | The tag name |
| `fields[].key` | string |  | Left out: the proposed one |
| `fields[].label` | string |  | Left out: the proposed one |

**200**: The new fields and how many values were set (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | object | yes |
| `data.fields` | array of [DeviceField](https://docs.neode.sk/development/api-reference/schemas.md#devicefield) | yes |
| `data.values` | integer | yes |

| Error | When |
|---|---|
| 400 | No names (device_field_bad_body), a name no device has (device_field_tag_not_found) or a key that isn't one (device_field_bad_key) |
| 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 |
| 409 | A device has two values of a name or one too long (device_field_tag_conflict, with count), a key is taken (device_field_key_taken) or the server would have more than 50 fields (device_field_too_many_fields) |
| 500 | Something failed on the server (the text of errors.server_error) |

## GET /api/device-fields/export

Export device field values as CSV: id, then one column per field key (use --output).

Every device the account sees (kept to those a filter keeps) and the fields it sees, with the values set on each device; a field's default is not written. A UTF-8 byte order mark, CRLF line ends. A text a spreadsheet would read as a formula gets a single quote in front; the import takes it off again.

Needs `device.view`. `neodesk device-fields export` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `f` | query | array of string | A condition key:operator:value (eq, contains, min, max) or key:empty, key:notempty; repeat to combine |
| `keys` | query | array of string | The fields to export, keys separated by commas or repeated (left out: every field the account sees) |
| `sep` | query | string, one of `comma`, `semicolon` | The separator (left out: comma) |

**200**: The file device-fields-&lt;YYYY-MM-DD>.csv (`text/csv`)

String (binary).

| Error | When |
|---|---|
| 400 | A key or filter names no field the account sees (device_field_unknown_field), a filter is not valid (device_field_bad_filter), or the separator is unknown (device_field_bad_separator) |
| 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 |
| 500 | Something failed on the server (the text of errors.server_error) |

## POST /api/device-fields/import

Import device field values from a CSV file; try it with dry_run first.

The file: id (or device_id), then one column per field key; a comma, a semicolon or a tab between cells; at most 2 MB and 10,000 lines. An empty cell leaves the value as it is, a cell with just - clears it, a choice field's several values are separated by ;. A dry run changes nothing and answers the plan. The import works the plan out again and sets what it lists, in one transaction: it refuses columns that are no field the account sees (device_field_unknown_field, the same for a field it may not see), lines with problems unless skip_bad_rows=true, and a plan_id that doesn't match (409 device_field_import_changed). One audit entry per changed value (a restricted field's without the values).

Needs `device.fields_edit`. `neodesk device-fields import` calls it.

| Parameter | In | Type | What it is |
|---|---|---|---|
| `dry_run` | query | string, one of `true` | true changes nothing and answers the plan |
| `skip_bad_rows` | query | string, one of `true` | true imports the lines without problems and leaves the others out |
| `plan_id` | query | string | The dry run's plan_id: the import refuses when its plan comes out different |

Request body, `multipart/form-data`:

| Field | Type | Required |
|---|---|---|
| `file` | string (binary) | yes |
| `dry_run` | string, one of `true` |  |
| `skip_bad_rows` | string, one of `true` |  |
| `plan_id` | string |  |

Request body, `text/csv`:

String.

Request body, `application/json`:

| Field | Type | Required |
|---|---|---|
| `csv` | string | yes |
| `dry_run` | boolean |  |
| `skip_bad_rows` | boolean |  |
| `plan_id` | string |  |

**200**: The plan; after an import with what it changed (`application/json`)

| Field | Type | Required |
|---|---|---|
| `success` | `true` | yes |
| `data` | [DeviceFieldImportPlan](https://docs.neode.sk/development/api-reference/schemas.md#devicefieldimportplan) | yes |

| Error | When |
|---|---|
| 400 | The file can't be read (device_field_import_bad_csv with the line as count, device_field_import_no_id, device_field_import_empty, device_field_import_column_twice, device_field_import_too_many_rows, device_field_import_not_utf8, device_field_import_no_file), names a column that is no field the account sees (device_field_unknown_field), or has lines with problems (device_field_import_has_problems, with count) |
| 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 |
| 409 | The plan came out different from plan_id (device_field_import_changed) |
| 413 | The file is larger than 2 MB (device_field_import_too_large) |
| 500 | Something failed on the server (the text of errors.server_error) |
