flespi Plugins API
[Plugins](https://flespi.com/kb/plugins-functionality-extensions-for-flespi-devices) are the key instance in flespi responsible for the transformation of the message received by the device during its registration process. Plugins can transform [device message](https://flespi.com/kb/messages-basic-information-units) into different structure, remove or add new parameters, duplicate it to another device or cancel its registration at all. Plugins are applied in the order defined by their priority. The higher the number in the priority field, the earlier the plugin will apply. Use the validate_message field in the plugin configuration to specify the validation [expression](https://flespi.com/kb/expressions) that should succeed for the plugin to apply. If no validation expression is specified, the plugin will apply to all device messages that are being registered. Currently plugins can only be applied to [flespi devices](https://flespi.com/kb/device-virtual-instance-of-real-tracker). In the future we may enhance plugins functionality to work with other types of flespi items. List of available plugin types you can retrieve with [GET /gw/plugin-types/all](https://flespi.io/docs/#/gw/protocols/get_plugin_types_plugin_types_selector) API call. Configuration within each plugin instance should match the configuration schema defined for corresponding plugin type. To stay current with plugin type updates, subscribe to 'flespi/message/gw/plugin-types/{type-id}/changelog' MQTT topic delivering any changes published in the plugin type [changelog](https://forum.flespi.com/t/changelog). Any device message processed by the plugin is reflected into plugin logs with corresponding device_id and message_timestamp parameters. In the log record event_code parameter defines the result of plugin application: Event code | Description -----|------ 324|group was added to plugin 325|group was removed from plugin 326|geofence was added to plugin 327|geofence was removed from plugin 350|plugin successfully processed device message 351|plugin failed to process device message For event_code=351 you may check field 'reason' for the textual description of the problem (its actual format depends on the actual plugin type) and examine plugin raw traffic that occurred at the same time for more information. A plugin type may add its own parameters to the log record, for example 'ai_credits' with the number of AI credits charged for the message. Whenever you need to troubleshoot plugin operation you can investigate raw traffic between flespi plugin and some server. You can fetch traffic packets via API or just use flespi.io panel for this. On 'Logs' tab there is TRAFFIC button and also from each log record you can navigate to associated raw traffic exchange via context menu command.