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
get
/v2/projects/{project_id}/devices/{device_id}/functions

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
get
/v2/projects/{project_id}/devices/{device_id}/functions/{function_id}

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
put
/v2/projects/{project_id}/devices/{device_id}/functions/{function_id}

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
put
/v2/projects/{project_id}/devices/{device_id}/functions/{function_id}/config

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
put
/v2/projects/{project_id}/devices/{device_id}/functions/{function_id}/enabled

Last updated