HTTP Integration
HTTP Integration converts existing protocols and payload formats to ThingsBoard message format. Common deployment scenarios:
- Stream device or asset data from an external system, IoT platform, or connectivity provider back-end.
- Stream data from a custom cloud application.
- Connect an existing device with a custom HTTP-based protocol to ThingsBoard.
ThingsBoard integration setup
Section titled “ThingsBoard integration setup”Create an uplink converter
Section titled “Create an uplink converter”The uplink converter decodes the incoming HTTP request body and maps it to the ThingsBoard data model. The decoder receives:
payload— raw bytes of the HTTP request bodymetadata— HTTP request headers (asHeader:{name}keys, e.g.Header:content-type) andintegrationName
It must return deviceName, deviceType, attributes, and telemetry. Both are flat key-value maps — nested objects are not supported. For the full decoder API, see Uplink data converter.
The decoder function used in this tutorial:
/** Decoder **/
// Decode JSON bodyvar data = decodeToJson(payload);
var deviceName = data.deviceName;var deviceType = data.deviceType;
// Result object with device attributes/telemetry datavar result = { deviceName: deviceName, deviceType: deviceType, attributes: { model: data.model, serialNumber: data.param2, // renamed: param2 → serialNumber }, telemetry: { temperature: data.temperature }};
/** Helper functions 'decodeToString' and 'decodeToJson' are already built-in **/
return result;/** Decoder **/
// Decode JSON bodyvar data = decodeToJson(payload);
var deviceName = data.deviceName;var deviceType = data.deviceType;
// Result object with device attributes/telemetry datavar result = { deviceName: deviceName, deviceType: deviceType, attributes: { model: data.model, serialNumber: data.param2, // renamed: param2 → serialNumber }, telemetry: { temperature: data.temperature }};
/** Helper functions **/
function decodeToString(payload) { return String.fromCharCode.apply(String, payload);}function decodeToJson(payload) { var str = decodeToString(payload); var data = JSON.parse(str); return data;}
return result;The decoder expects a flat JSON body and maps its fields to ThingsBoard:
| JSON field | Output field | Type | Notes |
|---|---|---|---|
deviceName | deviceName | — | Device identifier; auto-creates the device on first uplink |
deviceType | deviceType | — | Device profile name |
model | model | attribute | |
param2 | serialNumber | attribute | Field is renamed in the output |
temperature | temperature | telemetry |
For request body {"deviceName":"Thermometer A","deviceType":"thermostat","model":"N001","param2":"SN-12345","temperature":25.0} the decoder produces:
{ "deviceName": "Thermometer A", "deviceType": "thermostat", "attributes": { "model": "N001", "serialNumber": "SN-12345" }, "telemetry": { "temperature": 25.0 }}To adapt this converter to your device:
- Device name from a different field — replace
data.deviceNamewith the field that carries the device identifier in your payload. - Hardcoded device type — replace
data.deviceTypewith a string literal (e.g.'thermostat') if all devices share the same profile. - Rename a field — use
outputName: data.sourceFieldto store the value under a different key in ThingsBoard (as shown withserialNumber: data.param2). - Different telemetry or attribute fields — add, remove, or rename entries in the
telemetryandattributesblocks. - Non-JSON payload — replace
decodeToJson(payload)withdecodeToString(payload)and parse the string manually.
Import the uplink converter:
- Download the uplink converter file:
- Go to Integrations center ⇾ Data converters.
- Click + Add data converter ⇾ Import converter.
- Drag and drop the downloaded JSON file into the Import converter window.
- Click Import.
Create the integration
Section titled “Create the integration”- Go to Integrations center ⇾ Integrations and click + Add integration.
- Basic settings:
- Set Integration type to HTTP.
- Enable integration and Allow create devices or assets are on by default.
- Click Next.
- Uplink data converter:
- Select existing — choose a previously created
HTTP Uplink Converterfrom the list. - Click Next.
- Select existing — choose a previously created
- Downlink data converter:
- Click Skip — the downlink converter is only required for RPC and can be added later.
- Connection:
- Copy the HTTP endpoint URL — you will use it to send uplink messages.
- In Advanced settings enable Replace response status from ‘No-Content’ to ‘OK’.
- Click Add to complete the integration setup.
Connection settings
Section titled “Connection settings”Base URL
The base address of the ThingsBoard server, used to construct the HTTP endpoint URL.
Example: https://thingsboard.cloud
HTTP endpoint URL
Auto-generated endpoint for this integration. External systems must send HTTP POST requests to this URL.
Format: {baseUrl}/api/v1/integrations/http/{integrationId}
The integrationId is a UUID assigned at creation time, visible in the Connection step of the wizard.
Enable security (Headers filter)
When enabled, ThingsBoard validates each incoming request against a list of required HTTP header name/value pairs. Requests missing any configured header are rejected.
| Field | Description |
|---|---|
| Header | Name of the required HTTP header (e.g. Authorization, X-API-Key) |
| Secret | Required value for that header (e.g. Bearer my-token) |
Multiple header filters can be added. All configured headers must be present in every request.
Execute remotely
When enabled, ThingsBoard generates an Integration key and Integration secret. These credentials allow the integration to run as a separate process outside the ThingsBoard cluster — useful when the integration must reach services not accessible from the ThingsBoard server (e.g., in a DMZ or on-premises environment).
Advanced settings
| Parameter | Default | Description |
|---|---|---|
| Replace response status from “No-Content” to “OK” | off | When off, the integration returns 204 No Content after processing the uplink. When on, returns 200 OK. Enable this for devices or systems that require a 200 status. Note: when a downlink is queued, the integration always returns 200 OK with the downlink payload regardless of this setting |
Metadata
Optional key–value pairs attached to the integration. These values are injected into every message processed by the integration and are accessible in converter scripts as integrationMetadata.
Send an uplink message
Section titled “Send an uplink message”Send a test message by running the command below, replacing $YOUR_HTTP_ENDPOINT_URL with the HTTP endpoint URL copied during setup.
curl -v -X POST -d '{"deviceName":"Thermometer A","deviceType":"thermostat","temperature":33,"model":"N001"}' $YOUR_HTTP_ENDPOINT_URL -H "Content-Type:application/json"Go to Entities ⇾ Devices — device Thermometer A is provisioned automatically by the integration. Click it and open the Latest Telemetry tab to confirm temperature = 33.
Go to Integrations center ⇾ Integrations, click HTTP integration, and open the Events tab. You should see one event with status “OK”:
To inspect converter processing, go to Integrations center ⇾ Data converters, click Uplink data converter for HTTP integration, and open its Events tab:
- In shows the raw payload passed to the converter
- Out shows the decoded result (deviceName, deviceType, attributes, telemetry)
- Metadata contains the HTTP request headers and integration name
Use Dashboards to visualize the received data. ThingsBoard provides Solution Templates with pre-built dashboards for common use cases.
Restrict access with a header filter
Section titled “Restrict access with a header filter”Require a specific HTTP header on every incoming request — requests without it are rejected.
- Open the HTTP integration, click Toggle edit mode (pencil icon, top right).
- Enable the Enable security (Headers filter) toggle, enter a header name (e.g.
test-header) and value (e.g.secret), click Add, then click Apply changes.
Once configured, add the required header to every uplink request with -H "$HEADER:$VALUE".
Run the command below, replacing $YOUR_HTTP_ENDPOINT_URL, $HEADER, and $VALUE with your values:
curl -v -X POST -d '{"deviceName":"Thermometer A","deviceType":"thermostat","temperature":33,"model":"N001"}' $YOUR_HTTP_ENDPOINT_URL -H "Content-Type:application/json" -H "$HEADER:$VALUE"Configure downlink
Section titled “Configure downlink”The downlink converter (encoder) transforms a Rule Engine message into the HTTP response body returned to the device. For the full encoder function reference, see Downlink data converter.
HTTP downlinks are not pushed — they are delivered as the response body to the device’s next uplink request. When a downlink is queued, the integration returns 200 OK with the encoded payload instead of 204 No Content.
The encoder function receives msg, metadata, and msgType, and must return an object with:
contentType—JSON,TEXT, orBINARY(BINARYexpects a Base64-encoded string)data— the response body stringmetadata— optional key-value pairs
Add a downlink converter
Section titled “Add a downlink converter”- Go to Integrations center ⇾ Integrations and open the HTTP Integration.
- Click Toggle edit mode.
- In the Downlink data converter field, click Create new.
- In the Add data converter dialog, enter a name, and write or paste the encoder script.
/** Encoder **/
var result = { contentType: "JSON", // JSON, TEXT, or BINARY (base64) data: JSON.stringify(msg), // encode the full message as the response body metadata: {}};
return result;/** Encoder **/
var result = { contentType: "JSON", // JSON, TEXT, or BINARY (base64) data: JSON.stringify(msg), // encode the full message as the response body metadata: {}};
return result;- Click Add, then click Apply changes.
Configure the Root Rule Chain
Section titled “Configure the Root Rule Chain”To send downlinks through the integration, modify the Root Rule Chain:
- Go to Rule chains and open the Root Rule Chain.
- Find the integration downlink node in the node library panel on the left. Drag it onto the canvas.
- In the node configuration dialog, enter a name (e.g. “Downlink to HTTP”) and select your HTTP integration. Click Add.
- Connect the message type switch node to the new integration downlink node using the Attributes Updated link type to trigger downlinks on shared attribute updates, and optionally also using the Post attributes link type to forward attribute post messages as downlinks. Apply changes.
Test the downlink
Section titled “Test the downlink”When a shared attribute is created or updated, the Rule Engine routes the event to the integration, which queues the encoded payload as the response to the device’s next uplink.
- Go to Devices, select your device, and navigate to the Attributes tab.
- Select Shared attributes, click + to add a new attribute.
- Set the key (e.g.
powerState) and value (e.g.on). - Click Add.
Send the uplink message again. ThingsBoard returns the downlink payload in the HTTP response:
The sent and received data can be viewed in the downlink converter’s Events tab — the In block shows the input data, the Out block shows the encoded message sent to the device, and Metadata shows the request headers: