Functions

List all device functions

get

Retrieves all functions configured for a device. Functions execute in sequence: Decoder → Transform → Rules (parallel) → Storage (parallel). Schedule functions run independently on cron timers.

Function Types:

Type
Purpose
Execution

decoder

Parse raw bytes to JSON

First (one per device)

transformfn

Modify/enrich data with JSONata

Second (one per device)

rule

Trigger actions on conditions

Third (multiple, parallel)

storagefn

Forward to external storage

Fourth (multiple, parallel)

schedule

Poll external APIs on cron

Independent (multiple)

Function Status:

  • Active: Function running successfully

  • Failed: Last execution failed (auto-disabled, email sent)

  • Disabled: Manually disabled by user

Response includes: function_type, status, enabled, last_triggered, debounce_period, template_id

Authorizations
AuthorizationstringRequired

Enter your API key with the Bearer prefix, e.g. "Bearer QB_your_api_key_here"

Path parameters
project_idstringRequired

Project ID (UUID format)

Example: 3e5c0246-c759-48e8-8345-27db13f11ff7
device_idstringRequired

Device ID

Example: 5f8d0d55b54764ca6f3a1234
Responses
200

Functions retrieved successfully - Returns array of all function types for the device

application/json
get
/v2/projects/{project_id}/devices/{device_id}/functions
GET /v2/projects/{project_id}/devices/{device_id}/functions HTTP/1.1
Host: api.qubitro.com
Authorization: YOUR_API_KEY
Accept: */*
{
  "functions": [
    {
      "avatar": "text",
      "brand": "text",
      "conditionType": "text",
      "conditions": [
        {
          "key": "temperature",
          "operator": ">",
          "value": "30"
        }
      ],
      "created": "text",
      "cron_properties": {
        "cron_expression": "text",
        "timezone": "text"
      },
      "debounce_period": 1,
      "description": "text",
      "device_id": "text",
      "enabled": true,
      "from_template": true,
      "function_type": "text",
      "id": "text",
      "interpreter": "text",
      "jsonata": "text",
      "last_triggered": "text",
      "metadata": {
        "ANY_ADDITIONAL_PROPERTY": "anything"
      },
      "model": "text",
      "name": "text",
      "project_id": "text",
      "reason": "text",
      "rule_type": "text",
      "scheduled_type": "text",
      "script": "text",
      "source_type": "text",
      "status": "text",
      "storage_type": "text",
      "template_update": true,
      "transformation_id": "text"
    }
  ],
  "total_count": 1
}

Get function details

get

Retrieves complete configuration for a specific function including script/expression, conditions, metadata, credentials, and execution status.

Required Query Parameter:

  • type: Function type - "decoder", "rule", "storage", "transformation", "scheduled"

Response Includes:

Decoder: script, enabled, status, reason (if failed)

Transform: expression, interpreter (JSONata), enabled

Rule: rule_type, conditions, metadata (webhook URI, headers, body), debounce_period, last_triggered, status

Storage: storagefn_type, metadata (database, collection), cred_meta (encrypted credentials), transform_id, last_triggered

Schedule: schedule_type, cron_data (timezone, cron_spec), metadata (URI, method, headers), last_triggered

Use Cases:

  • View current function configuration

  • Debug function failures (check reason field)

  • Clone function to another device

  • Audit function settings

Authorizations
AuthorizationstringRequired

Enter your API key with the Bearer prefix, e.g. "Bearer QB_your_api_key_here"

Path parameters
project_idstringRequired

Project ID (UUID format)

Example: 3e5c0246-c759-48e8-8345-27db13f11ff7
device_idstringRequired

Device ID

Example: 5f8d0d55b54764ca6f3a1234
function_idstringRequired

Function ID

Example: 5f8d0d55b54764ca6f3a1234
Query parameters
typestring · enumRequired

Function type

Example: rulePossible values:
Responses
200

Function retrieved successfully - Includes complete configuration

application/json
get
/v2/projects/{project_id}/devices/{device_id}/functions/{function_id}
GET /v2/projects/{project_id}/devices/{device_id}/functions/{function_id}?type=decoder HTTP/1.1
Host: api.qubitro.com
Authorization: YOUR_API_KEY
Accept: */*
{
  "avatar": "text",
  "brand": "text",
  "conditionType": "text",
  "conditions": [
    {
      "key": "temperature",
      "operator": ">",
      "value": "30"
    }
  ],
  "created": "text",
  "cron_properties": {
    "cron_expression": "text",
    "timezone": "text"
  },
  "debounce_period": 1,
  "description": "text",
  "device_id": "text",
  "enabled": true,
  "from_template": true,
  "function_type": "text",
  "id": "text",
  "interpreter": "text",
  "jsonata": "text",
  "last_triggered": "text",
  "metadata": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "model": "text",
  "name": "text",
  "project_id": "text",
  "reason": "text",
  "rule_type": "text",
  "scheduled_type": "text",
  "script": "text",
  "source_type": "text",
  "status": "text",
  "storage_type": "text",
  "template_update": true,
  "transformation_id": "text"
}

Update entire function configuration

put

FULL REPLACEMENT: Updates the complete function configuration including script, conditions, metadata, and all settings. Use UpdateConfig for partial updates.

Update Scenarios:

  • Decoder: Update JavaScript decoder script, change parsing logic

  • Transform: Update JSONata expression, change field transformations

  • Rule: Update conditions, webhook URL, email templates, debounce period

  • Storage: Update connection strings, database/collection names, credentials

  • Schedule: Update cron schedule, API endpoint, timezone

Required Query Parameter:

  • type: Function type - "decoder", "rule", "storage", "transformation", "scheduled"

Request Body Examples:

Decoder: {"name": "Decoder", "script": "function decoder(input) {...}", "enabled": true}

Rule: {"name": "Alert", "rule_type": "webhook", "conditions": [...], "metadata": {...}, "debounce_period": 5}

Transform: {"name": "Transform", "expression": "$merge([...])", "interpreter": "JSONata"}

Authorizations
AuthorizationstringRequired

Enter your API key with the Bearer prefix, e.g. "Bearer QB_your_api_key_here"

Path parameters
project_idstringRequired

Project ID (UUID format)

Example: 3e5c0246-c759-48e8-8345-27db13f11ff7
device_idstringRequired

Device ID

Example: 5f8d0d55b54764ca6f3a1234
function_idstringRequired

Function ID

Example: 5f8d0d55b54764ca6f3a1234
Query parameters
typestring · enumRequired

Function type

Example: rulePossible values:
Body
objectOptional
Responses
200

Function updated successfully - Full configuration replaced

application/json
put
/v2/projects/{project_id}/devices/{device_id}/functions/{function_id}
PUT /v2/projects/{project_id}/devices/{device_id}/functions/{function_id}?type=decoder HTTP/1.1
Host: api.qubitro.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 2

{}
{
  "action": "delete device",
  "message": "Operation completed successfully",
  "success": true
}

Update specific function configuration fields

put

PARTIAL UPDATE: Updates only specific configuration fields without touching the script or core settings. Use this for quick changes like updating a webhook URL or debounce period.

Supported Function Types:

  • Rule: Update webhook URI, headers, body template, debounce_period

  • Storage: Update database name, collection, connection details

  • Schedule: Update cron schedule, API endpoint, timezone

Not Supported: Decoder and Transform (use Update endpoint instead)

Required Query Parameter:

  • type: Function type - "rule", "storage", "scheduled"

Use Cases:

  • Change webhook URL without modifying conditions

  • Update debounce period without touching rule logic

  • Rotate database credentials

  • Modify cron schedule

Example: Update Rule Webhook URL

{"metadata": {"uri": "https://new-webhook.example.com"}}
Authorizations
AuthorizationstringRequired

Enter your API key with the Bearer prefix, e.g. "Bearer QB_your_api_key_here"

Path parameters
project_idstringRequired

Project ID (UUID format)

Example: 3e5c0246-c759-48e8-8345-27db13f11ff7
device_idstringRequired

Device ID

Example: 5f8d0d55b54764ca6f3a1234
function_idstringRequired

Function ID

Example: 5f8d0d55b54764ca6f3a1234
Query parameters
typestring · enumRequired

Function type

Example: rulePossible values:
Body
objectOptional
Responses
200

Function configuration updated successfully

application/json
put
/v2/projects/{project_id}/devices/{device_id}/functions/{function_id}/config
PUT /v2/projects/{project_id}/devices/{device_id}/functions/{function_id}/config?type=rule HTTP/1.1
Host: api.qubitro.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 2

{}
{
  "action": "delete device",
  "message": "Operation completed successfully",
  "success": true
}

Enable/disable a function

put

QUICK TOGGLE: Enables or disables a function without changing its configuration. Useful for temporary disabling during maintenance or debugging.

Required Query Parameters:

  • type: Function type - "decoder", "rule", "storage", "transformation", "scheduled"

  • enabled: Boolean - true to enable, false to disable

Behavior:

  • Disable: Function stops executing, data flow continues without it

  • Enable: Function resumes execution, applies to new data

  • Status transitions: Active ↔ Disabled

Use Cases:

  • Temporarily disable rule during maintenance

  • Test data pipeline without decoder

  • Pause storage function to external system

  • Quick troubleshooting without losing configuration

Note: Failed functions must be fixed and enabled via this endpoint to resume

Authorizations
AuthorizationstringRequired

Enter your API key with the Bearer prefix, e.g. "Bearer QB_your_api_key_here"

Path parameters
project_idstringRequired

Project ID (UUID format)

Example: 3e5c0246-c759-48e8-8345-27db13f11ff7
device_idstringRequired

Device ID

Example: 5f8d0d55b54764ca6f3a1234
function_idstringRequired

Function ID

Example: 5f8d0d55b54764ca6f3a1234
Query parameters
typestring · enumRequired

Function type

Example: rulePossible values:
enabledbooleanRequired

Enable (true) or disable (false)

Example: true
Responses
200

Function status updated successfully

application/json
put
/v2/projects/{project_id}/devices/{device_id}/functions/{function_id}/enabled
PUT /v2/projects/{project_id}/devices/{device_id}/functions/{function_id}/enabled?type=decoder&enabled=true HTTP/1.1
Host: api.qubitro.com
Authorization: YOUR_API_KEY
Accept: */*
{
  "action": "delete device",
  "message": "Operation completed successfully",
  "success": true
}

Last updated