# flespi Devices API

**Canonical:** https://apis.io/apis/flespi/flespi-devices-api/  
**Provider:** flespi — https://apis.io/providers/flespi/  
**Base URL:** https://flespi.io/gw  
**Documentation:** https://flespi.io/docs/#/gw

flespi Devices API is one of 11 APIs that [flespi](https://apis.io/providers/flespi/) publishes on the [APIs.io](https://apis.io/) network, described by a machine-readable OpenAPI specification. Tagged areas include Devices. The published artifact set on APIs.io includes an OpenAPI specification.

[Registered device](https://flespi.com/kb/device-virtual-instance-of-real-tracker) represents an IoT or telematics tracking equipment capable of sending messages to the [channel](https://flespi.com/kb/channel-entry-point-to-gateway). Each registered device has a dedicated storage for accumulated messages and media files. You can [control](https://flespi.com/kb/how-to-manage-device-storage) the size and duration of this storage with 'messages_ttl', 'messages_rotate', 'media_ttl', 'media_rotate' fields in device properties. Extra functionality for devices is available by activating special [plugins](https://flespi.com/kb/plugins-functionality-extensions-for-flespi-devices) for each device. Plugins are usually used to modify device message parameters during the registration - enrich them with your own parameters, remove some parameters, inject parameters from third party services like geocoders or even reject and cancel further message registration into device by some condition. ###### Device messages and telemetry To access device messages storage via REST API you use [GET /gw/devices/{dev-selector}/messages](https://flespi.io/docs/#/gw/devices/get_devices_dev_selector_messages) call with filtering parameters specified to retrieve only those messages that you need. The messages in device messages storage are sorted by the 'timestamp' parameter sent by hardware device (usually this is the value of RTC clock for the moment when telemetry was gathered). 'server.timestamp' parameter in messages indicates the time the message was received by flespi channel. Sometimes device can send messages with 'timestamp' beyond storage duration configured by 'messages_ttl' and you may never see such messages in device storage. In such cases you may look into channel's messages buffer where messages are sorted by the reception time (server.timestamp parameter) with **GET /gw/channels/{ch-selector}** API call. It is possible to receive device messages in realtime using [MQTT](https://flespi.com/kb/how-to-consume-telematics-hub-messages-via-mqtt) by subscribing to 'flespi/message/gw/devices/{device_id}' topic. To run reports over device messages or to extract pre-processed data from them in your format and based on your algorithms you can use [flespi reports engine](https://flespi.com/kb/analytics-reports-and-events-engine). [Device telemetry](https://flespi.com/kb/add-missing-parameters-from-telemetry) is a special cache of last know values of parameters sent by device within its messages. If you do not need full message in JSON acessing device telemetry is more lightweight method. You can access it via REST API with [GET /gw/devices/{dev-selector}/telemetry/{telemetry-selector}](https://flespi.io/docs/#/gw/devices/get_devices_dev_selector_telemetry_telemetry_selector) or subscribe to real-time parameters updates via MQTT with **flespi/state/gw/devices/{device_id}/telemetry/+** topic with retain data. ###### Device configuration & connectivity When configuring the device the most important attributes are device type and configuration which should uniquely identify the device in your flespi account. **Device type** corresponds to the device model. You must have at least one channel your account to be able to receive data from the device that works over the same protocol as the given device type. If you have several channels working over the same protocol, you can connect the device to any of them. There is no specific hard link between device and channel and you move devices between your channels just by reconfiguring them to another channel's uri. flespi will automatically recognize and parse device data connected to any channel in your account. To start receiving data from that device in flespi it is enough to create channel of the same protocol that selected device type operates. Device type defines the schema of the device configuration. Device configuration is a JSON object with fields. Each configuration field relates to a specific device feature. The device configuration cannot be set when device type is not set. Device type may define some of the fields listed below. Field | Type | Description -------------|--------|------------ ident | string | Unique device identifier, e.g. IMEI, serial number, etc. Used to identify incoming channel messages and store it into device's storage phone | string | Device phone number or SIM card ICCID serial number used to receive SMS messages or send commands over SMS password | string | Device password used to authenticate incoming connections to the channel sms_login | string | Device login used to authenticate SMS commands sent to the device sms_password | string | Device password used to authenticate SMS commands sent to the device The mentioned configuration fields may have additional format/pattern restrictions in each device type, but their names and types will always be the same for all device types. Some device types may define their own configuration fields. Absence of a field in the device type configuration means absence of a specific feature in the device. For example, absence of the "sms_password" field means that device does not use password to authenticate SMS commands sending through the platform. The "ident" configuration field is used to identify device connected to the channel. Usually in vehicle telematics it is either IMEI, serial number or special custom number value configured by user. From the moment device is connected to the appropriate channel and identified by ident, all its messages received by the channel will be automatically delivered to the device storage and available via REST API as messages. The **ident** and **protocol_id** pair of fields is used to uniquely identify the connected device within user account, so you can't create several devices with the same ident and protocol ID values. However this restriction applies only within a group of related flespi accounts (starting from account with owner_id=0 and below). There are no restrictions to use devices with same idents if theyr are located in different flespi accounts. The **password** configuration field is used when device connected to the channel and sent **both** ident and password. One of the folowing scenarios is possible: * If there is no flespi device with compatible device type and ident, the channel will accept incoming connection and start receiving messages from the connected device but they will be stored only in the channel buffer. * If the appropriate flespi device is found by ident but no password configuration field is set or it differs from the value sent by the connected device, the incoming connection will be rejected and a corresponding record will be saved in the device log. * If the appropriate flespi device is found by ident and its password configuration field matches the password received from the connected device, the channel will accept incoming connection and start receiving messages into the channel buffer and to the device storage. The **phone** configuration field can be used to configure device via SMS. Each flespi user has a certain number of free SMS that can be used for device configuration. See [modems](https://flespi.com/kb/modem-instance-to-send-sms) for more information. The phone configuration field should be unique among all devices. The **sms_password** configuration field is used to authenticate SMS commands sent to hardware. ###### Device troubleshooting If **blocked** attribute is not zero, the device messages buffer is full and blocked for new messages. Usually this is because used space for device messages exceeded the [account limitations](https://flespi.com/kb/how-to-control-account-limitations). To unblock the device messages buffer, set lower 'messages_ttl' attribute for auto-cleanup by time or 'messages_rotate' atribute for auto-cleanup by size. Device can be manually disabled. Established connections from the disabled device will be closed, and new connections will be rejected. Disabled devices do not limit access to their storage. If the channel protocol has a "shared_connection" feature, disabled devices will be skipped when the channel authenticates and registers the message for those devices. In other words, messages will be registered to the channel buffer only, skipping disabled devices. Blocked device status prevents new message registration into that device. If messages are registered through a channel whose protocol has a "shared_connection" feature, it aborts the bulk message registration pipeline, possibly preventing message registration to other devices in the received batch. To allow the channel to work in this case, devices have to be unblocked or disabled. In the second case, the channel, whose protocol has a "shared_connection" feature, will skip new message registration to the disabled device, even if that device is blocked. Whenever you need to troubleshoot device operation you can investigate raw traffic between flespi channel and hardware device. You can fetch traffic packets via API or just use flespi.io panel for this. On 'Logs & Messages' tab there is TRAFFIC button and also from each log record or message you can navigate to associated raw traffic exchange via context menu command. When new traffic is received from the connected device by the channel, the platform will put the current timestamp into the **last_active** field in the device. **connected** field is valid only for connection-oriented protocols such as TCP. For UDP, HTTP and many other type of protocol transports you'd better rely on **last_active** field to understand if device is alive. ###### Device settings Device [settings](https://flespi.com/kb/commands-and-settings) are defined by the device type. The device settings in the flespi platform display the last "cached" value for various parameters defining the behavior of the device. flespi offers a [Setbox](https://flespi.com/tools/setbox) tool as an interface to see and change device configuration remotely. Each setting can be read or sent to the device. The flespi platform will try to read the current value of all settings missing it, and to send pending settings values to the device if such pending values are set. There are REST API methods to clear the current setting value (DELETE), to set the pending setting value (PUT), to delete the pending setting value and abort new value sending (DELETE with pending=true) to the device. Each setting contains the **status** parameter indicating the source of the current setting value (if available) and the flespi platform intention to read the new current value or apply the pending setting value. The status parameter contains a bitmask with two fields. 4 lower bits of the **status** parameter indicate the source of the current setting value. Possible values: Value | Title | Description ------|------------|------------ 0x01 | read | The current setting value was read from device 0x02 | unreadable | The setting marked as unreadable if it fails to receive current setting value from the device after some attempts 0x03 | applied | The pending setting value was sent to the device and became a new current value After marking the setting as unreadable the flespi platform will stop trying to read its current value. The unreadable status can be cleared using the DELETE request. After such a request the setting will change to "reading" status (see below). 4 higher bits of the **status** parameter indicate the flespi platform intention to read or apply the new setting value. Possible values (mutually exclusive): Value | Title | Description ------|----------|------------ 0x10 | reading | The flespi platform will try to read the current setting value from the device when the connection from it is available 0x20 | applying | The flespi platform will try to apply the pending setting value to the device when the connection from it is available Each setting contains the **mode** parameter that is a bitmask of available actions. Bit 1 says that the setting value may be requested (get, read) from the device, bit 2 says that the setting value can be sent (set, applied) to the device. Each setting contains the **commands** parameter which acts as a mapping for the setting actions (get or set) to the device-level command names. ###### Device logs All device modification operations are recorded to the common [logs subsystem](https://flespi.io/docs/#/platform/logs) with the following possible event codes: Event code | Description -----|------ 1|device was created via REST API 2|device was updated via REST API 3|device was deleted via REST API 4|device was removed from account (moved to account) 5|device was restored from recycle bin via REST API 20|device was blocked, see [customer](https://flespi.io/docs/#/platform/customer) for more information 21|device was unblocked, see [customer](https://flespi.io/docs/#/platform/customer) for more information 22|device media storage was blocked 23|device media storage was unblocked 24|device media file was uploaded 25|device media file was updated 26|device media file was deleted 27|device media file expired by ttl or was rotated by size 28|device media file was accessed via external link, the corresponding logs are published in the [Platform logs](https://flespi.io/docs/#/platform/logs) 300|device connected 301|device disconnected 302|received SMS from device 303|sent SMS to device 304|device data processing error 305|device data processing warning 306|device secondary connection opened 307|device secondary connection closed 308|mediastream from device started 309|mediastream uploading stopped 340|tacho communication 310|received a new setting value from the device 311|REST API (PUT) request: the system accepted the new setting value 312|device confirmed the acceptance of the new setting value 313|device rejected the new setting value 314|REST API (DELETE) request: sending of the new setting value was canceled by the user 315|REST API (DELETE) request: current setting value was cleared from the system by the user 316|the system marked the setting as unreadable due to exceeded retries limit 317|the command to request or change the setting has been sent 318|the command to request or change the setting has been expired 320|plugin was activated, see [plugins](https://flespi.io/docs/#/gw/plugins) for more information 321|plugin was updated, see [plugins](https://flespi.io/docs/#/gw/plugins) for more information 322|plugin was deactivated, see [plugins](https://flespi.io/docs/#/gw/plugins) for more information 323|plugin processing error 328|geofence was linked to the device 329|geofence was unlinked from the device 330|device command added to the queue 331|device command removed from the queue 332|device command processed 333|device command expired 334|device command sent 340|tacho communication event (authentication, file upload, etc) 801|device was added to group 802|device was removed from group For event_code=20, the log record contains the block_code, which is the reason of device blocking. When blocked due to exceeded storage size (block_code=4), which is the size of message buffer, the device stops receiving new messages. It will be automatically unblocked when the size of the buffer goes below the specified limits. For device connection event (event_code=300), you may expect the following additional parameters in the log record, same as [channels connection](https://flespi.io/docs/#/gw/channels): Field name | Meaning ----------------------|-------- source |connected device address transport |connected device transport: tcp, udp, http etc. ident |connected device identification string (once per connection only) protocol_modified |modification timestamp of the channel protocol serving the connection If device is disconnected (event_code=301), you may expect the following additional parameters in the log record, almost same as [channels connection](https://flespi.io/docs/#/gw/channels): Field name | Meaning ----------------------|-------- close_code |code, specifying the reason of connection close operation error_text |optional, specifies additional error textual information source |connected device address transport |connected device transport: tcp, udp, http etc. ident |connected device identification string (optional, last value only) protocol_modified |modification timestamp of the channel protocol serving the connection duration |connection duration in seconds msgs |quantity of messages received recv |quantity of bytes received send |quantity of bytes sent Possible "close_code" values: Code | Event -----|------ 2|connection closed by tracking device 3|connection successfully processed and closed 4|received data violates channel's protocol 5|internal error 6|data parsing error (see log details) 7|connection closed due to server restart 8|protocol implementation updated 9|channel parameters changed 10|connection closed upon user's request 11|failed to establish connection 12|Current connection closed because of ident collision: device has opened another connection to the channel without closing the first one. It may happen because of device firmware bug or due to an unstable connectivity provider. In general, this happens to plenty of devices and usually can be ignored. 13|device is blocked 14|authentication failed 15|device associated with the connection was created, changed or deleted 16|channel rejected connection due to IP addresses match blacklist or mismatch whitelist 17|connection is closed by inactivity timeout 18|unsupported protocol part 19|protocol mismatch 20|processing was cancelled 21|channel is blocked 22|device media is blocked 23|device is disabled For device setting events processed by the channel protocol (event_code=310, 312, 313 and 317), the log record contains the protocol_modified parameter, which is the modification timestamp of the channel protocol that processed the setting. It is absent when no protocol was involved, e.g. when the setting is rejected because its command has run out of attempts. For event_code=1,2,3 that are recorded when you create, update or delete the device using REST API each record contains the following standard fields: Field name | Description --------|---------- http_data | original request parameters supplied by the caller; applicable for POST, PUT and PATCH operations new | item's data with default fields after operation; applicable for POST, PUT and PATCH operations old | item's data with default fields prior to operation; applicable for DELETE, PUT and PATCH operations token_id | token ID used to authorize the HTTP request host | IP address from which HTTP request was received For event_code=314 that is recorded when the device setting was modified either by reading the new value from the device or by user request, each record contains the following additional fields: Field name | Description --------|---------- device_id | ID of device name | name of setting that is being modified current | object with the current setting value, according to the setting data schema For event_code=315 that is recorded when the device setting failed for any reason, each record contains the following additional fields: Field name | Description --------|---------- device_id | ID of device name | name of setting that is rejected properties | setting value rejected by device error_text | optional, additional error information For event_code=316 that occurs when the system stops requesting the current setting value from the device due to exceeded retries limit and marked the setting as unreadable, each record contains the following additional fields: Field name | Description --------|---------- device_id | ID of device name | name of setting that is marked as unreadable For event_code=340 (tacho communication) there will be additional property "tacho_code" with values from the following table: Code | Event -----|------ 1|Authentication started 2|Authentication finished 3|Authentication error 4|File uploading started 5|File uploading completed 6|The tachograph has confirmed the request. The data is being prepared for upload to the server. This may take up to 10 minutes. 7|The tracker already has an authentication task, but has not started yet 8|Tachograph specific error 9|Tachograph specific status 10|Uploading file info If SMS was sent or received from device (event_code=302 or event_code=303), you may expect the following additional parameters in the log record: Field name | Meaning ----------------------|-------- address | SMS phone number type | hex or text text | textual SMS contents (for text messages only) hex | hex representation of binary SMS contents (for binary messages only)

## Operations (41)

| Method | Path | Summary |
|---|---|---|
| GET | `/channel-protocols/{channel-protocols.selector}/device-types/{devtypes.selector}` | Get available device types withing selected channel protocols |
| POST | `/devices` | Create new device |
| DELETE | `/devices/{dev-selector}` | Delete selected devices |
| GET | `/devices/{dev-selector}` | Fetch available devices |
| PATCH | `/devices/{dev-selector}` | Modify fields inside device configuration |
| PUT | `/devices/{dev-selector}` | Modify device properties |
| POST | `/devices/{dev-selector}/calculate` | Split devices messages into intervals (run reports) |
| PUT | `/devices/{dev-selector}/cid` | Move device between subaccounts |
| POST | `/devices/{dev-selector}/commands` | Send command to the connected device in real-time |
| POST | `/devices/{dev-selector}/commands-queue` | Schedule command execution |
| DELETE | `/devices/{dev-selector}/commands-queue/{devices.commands-queue.selector}` | Remove command from queue |
| GET | `/devices/{dev-selector}/commands-queue/{devices.commands-queue.selector}` | Retrieve list of queued commands |
| GET | `/devices/{dev-selector}/commands-result` | Get executed or expired commands |
| GET | `/devices/{dev-selector}/commands-result/{command-id-selector}` | Get executed or expired command by its ID |
| DELETE | `/devices/{dev-selector}/connections/{conn-selector}` | Close TCP connections |
| GET | `/devices/{dev-selector}/connections/{conn-selector}` | List active TCP connections |
| DELETE | `/devices/{dev-selector}/geofences/{dev-geofences-selector}` | Unassign geofences from device |
| GET | `/devices/{dev-selector}/geofences/{dev-geofences-selector}` | Retrieve geofences in device |
| POST | `/devices/{dev-selector}/geofences/{dev-geofences-selector}` | Assign geofences to device |
| GET | `/devices/{dev-selector}/logs` | Retrieve device logs |
| GET | `/devices/{dev-selector}/logs/calculate` | Calculate intervals from device logs |
| POST | `/devices/{dev-selector}/logs/calculate` | Calculate intervals from device logs |
| DELETE | `/devices/{dev-selector}/media` | Delete media files |
| GET | `/devices/{dev-selector}/media` | List device media files |
| POST | `/devices/{dev-selector}/media` | Upload media file to device |
| PUT | `/devices/{dev-selector}/media` | Attach own data to media file |
| GET | `/devices/{dev-selector}/messages` | Retrieve messages stored by the device |
| POST | `/devices/{dev-selector}/messages` | Register messages into device |
| GET | `/devices/{dev-selector}/messages/calculate` | Split devices messages into intervals (run reports) |
| GET | `/devices/{dev-selector}/packets` | Retrieve raw device traffic |
| DELETE | `/devices/{dev-selector}/settings/{sett-selector}` | Re-read setting value from the device or cancel setting update request |
| GET | `/devices/{dev-selector}/settings/{sett-selector}` | Retrieve device settings |
| PUT | `/devices/{dev-selector}/settings/{sett-selector}` | Request device to apply new setting value |
| GET | `/devices/{dev-selector}/sms` | Generate SMS message text for the command |
| POST | `/devices/{dev-selector}/sms` | Send SMS command to the device in real-time |
| DELETE | `/devices/{dev-selector}/telemetry/{telemetry-selector}` | Delete device telemetry fields |
| GET | `/devices/{dev-selector}/telemetry/{telemetry-selector}` | Retrieve device telemetry |
| DELETE | `/streams/{stream.selector}/devices/{stream.devices.selector}` | Unsubscribe stream from devices |
| GET | `/streams/{stream.selector}/devices/{stream.devices.selector}` | List devices to which stream is subscribed |
| POST | `/streams/{stream.selector}/devices/{stream.devices.selector}` | Subscribe stream to device messages |
| PUT | `/streams/{stream.selector}/devices/{stream.devices.selector}` | Modify device data for stream |

## Machine-readable artifacts (1)

- **OpenAPI** — https://artifacts.apis.io/flespi/openapi/flespi-devices-api-openapi.yml

## Other flespi APIs (10)

- [flespi Assets API](https://apis.io/apis/flespi/flespi-assets-api/)
- [flespi Calculators API](https://apis.io/apis/flespi/flespi-calculators-api/)
- [flespi Changelog API](https://apis.io/apis/flespi/flespi-changelog-api/)
- [flespi Channels API](https://apis.io/apis/flespi/flespi-channels-api/)
- [flespi Geofences API](https://apis.io/apis/flespi/flespi-geofences-api/)
- [flespi Groups API](https://apis.io/apis/flespi/flespi-groups-api/)
- [flespi Modems API](https://apis.io/apis/flespi/flespi-modems-api/)
- [flespi Plugins API](https://apis.io/apis/flespi/flespi-plugins-api/)
- [flespi Protocols API](https://apis.io/apis/flespi/flespi-protocols-api/)
- [flespi Streams API](https://apis.io/apis/flespi/flespi-streams-api/)

## Tags

Devices

## Use this from code or an agent

- **REST, no key:** `GET https://apis.io/api/v1/providers/flespi` returns the provider's full profile as JSON.
- **MCP:** `https://apis.io/mcp` (Streamable HTTP) — search the catalog, read any provider, compare providers, check agent readiness.
- **Free API key** for catalog-wide search, ratings and comparisons: sign in with GitHub, Google or LinkedIn at https://apis.io/developer/account/ (plans: https://apis.io/developer/plans/).

---

Profiled by [API Evangelist](https://apievangelist.com) and published on [APIs.io](https://apis.io/apis/flespi/flespi-devices-api/). The API's provider profile, Kin Score and agent-readiness rating are at https://apis.io/providers/flespi/.
