Skip to content
Stand with Ukraine flag

REST API

ThingsBoard provides a REST API for managing platform entities, integrations, device provisioning, and building custom applications. The API is available on every ThingsBoard instance and documented interactively via Swagger UI.

All examples on this page use $TB_URL for the ThingsBoard base URL (e.g. https://thingsboard.cloud) and $AUTH for the authorization header value (e.g. ApiKey YOUR_KEY).

Swagger UI lets you browse all available REST API endpoints, inspect request and response schemas, and test API calls directly in your browser.

Access it at:

http://localhost:8080/swagger-ui.html

If you are already logged into the ThingsBoard UI, Swagger UI authenticates automatically using your session.

Pass the API key in the X-Authorization header:

X-Authorization: ApiKey YOUR_API_KEY_VALUE

Example request:

Terminal window
curl -X GET -H 'X-Authorization: ApiKey YOUR_API_KEY_VALUE' \
'$TB_URL/api/auth/user'

API keys are long-lived, require no login, and can be revoked through the ThingsBoard UI.

Obtain an access token by sending credentials to the login endpoint:

Terminal window
curl -X POST -H 'Content-Type: application/json' \
-d '{"username":"[email protected]", "password":"tenant"}' \
'$TB_URL/api/auth/login'

Response:

{"token":"YOUR_JWT_TOKEN", "refreshToken":"YOUR_JWT_REFRESH_TOKEN"}

Use the token in subsequent requests:

X-Authorization: Bearer YOUR_JWT_TOKEN

Access tokens are valid for 2.5 hours; refresh tokens for 1 week.

ThingsBoard provides language-specific client libraries that simplify REST API usage:

Most API calls require an entity ID (UUID). You can find it in the ThingsBoard UI (it appears in the URL when you open an entity), or fetch it via REST.

List devices — returns paginated devices with their IDs:

Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/tenant/devices?pageSize=10&page=0'

Response (abbreviated):

{
"data": [
{
"id": {"entityType": "DEVICE", "id": "784f394c-42b6-435a-983c-b7beff2784f9"},
"name": "Thermostat A1",
"type": "thermostat"
}
],
"totalElements": 3
}

Use the id value (784f394c-...) in the {deviceId} placeholder in all subsequent examples. The same pattern applies to other entity types — use /api/tenant/assets, /api/customers, etc.

The Attributes API lets you create, read, and delete attributes on any entity. Attributes are organized into scopes:

ScopeDescriptionWritable via REST
SERVER_SCOPESet by server-side applicationsYes
SHARED_SCOPESet by server, readable by devicesYes
CLIENT_SCOPEReported by devicesNo (device-only)

Create or update attributes in a given scope. The request body is a JSON object with key-value pairs.

Terminal window
curl -X POST -H 'Content-Type: application/json' \
-H 'X-Authorization: $AUTH' \
-d '{"firmware":"1.2.3", "batchSize":100}' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/attributes/SERVER_SCOPE'

Works for any entity type — replace DEVICE/{deviceId} with ASSET/{assetId}, etc.

All scopes — returns attributes from every scope merged together:

Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/values/attributes'

Specific scope with optional key filter:

Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/values/attributes/SERVER_SCOPE?keys=firmware,batchSize'

Response:

[
{"lastUpdateTs": 1709912345000, "key": "firmware", "value": "1.2.3"},
{"lastUpdateTs": 1709912345000, "key": "batchSize", "value": 100}
]
Terminal window
# All scopes
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/keys/attributes'
# Specific scope
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/keys/attributes/SERVER_SCOPE'

Response: ["firmware", "batchSize"]

Terminal window
curl -X DELETE -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/SERVER_SCOPE?keys=firmware,batchSize'

The Time Series API lets you save, query, and delete time series data for any entity.

Simple format — the server assigns the current timestamp:

Terminal window
curl -X POST -H 'Content-Type: application/json' \
-H 'X-Authorization: $AUTH' \
-d '{"temperature": 22.5, "humidity": 58}' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/timeseries/ANY'

With explicit timestamp (milliseconds since epoch):

Terminal window
curl -X POST -H 'Content-Type: application/json' \
-H 'X-Authorization: $AUTH' \
-d '{"ts": 1709912345000, "values": {"temperature": 22.5, "humidity": 58}}' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/timeseries/ANY'

Multiple data points with different timestamps:

Terminal window
curl -X POST -H 'Content-Type: application/json' \
-H 'X-Authorization: $AUTH' \
-d '[
{"ts": 1709912340000, "values": {"temperature": 22.3}},
{"ts": 1709912345000, "values": {"temperature": 22.5}}
]' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/timeseries/ANY'

With TTL — data expires after the specified number of seconds:

Terminal window
curl -X POST -H 'Content-Type: application/json' \
-H 'X-Authorization: $AUTH' \
-d '{"temperature": 22.5}' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/timeseries/ANY/86400'

Returns the most recent value for each requested key:

Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/values/timeseries?keys=temperature,humidity'

Response:

{
"temperature": [{"ts": 1709912345000, "value": "22.5"}],
"humidity": [{"ts": 1709912345000, "value": "58"}]
}

Returns historical data points within a time window. Supports aggregation.

Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/values/timeseries?keys=temperature&startTs=1709900000000&endTs=1709999999999&limit=100&agg=NONE&orderBy=ASC'

Parameters:

ParameterRequiredDescription
keysYesComma-separated telemetry key names
startTsYesStart of time range (ms since epoch)
endTsYesEnd of time range (ms since epoch)
limitNoMax data points per key (default 100)
aggNoAggregation: NONE, AVG, MIN, MAX, SUM, COUNT
intervalNoAggregation interval in ms (required when agg is not NONE)
orderByNoASC or DESC (default DESC)

Aggregated example — hourly averages:

Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/values/timeseries?keys=temperature&startTs=1709900000000&endTs=1709999999999&agg=AVG&interval=3600000'
Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/keys/timeseries'

Response: ["temperature", "humidity", "speed"]

Terminal window
curl -X DELETE -H 'X-Authorization: $AUTH' \
'$TB_URL/api/plugins/telemetry/DEVICE/{deviceId}/timeseries/delete?keys=temperature&deleteAllDataForKeys=true'

Parameters:

ParameterDescription
keysComma-separated key names to delete
deleteAllDataForKeystrue to delete all data; false to use time range
startTs / endTsTime range (required when deleteAllDataForKeys=false)
deleteLatesttrue to also delete the latest value (default false)
rewriteLatestIfDeletedtrue to recalculate latest from remaining data

The RPC API lets server-side applications send commands to devices. The device must be online (or persistent RPC must be used).

Sends a command without waiting for a response from the device:

Terminal window
curl -X POST -H 'Content-Type: application/json' \
-H 'X-Authorization: $AUTH' \
-d '{"method": "setGpio", "params": {"pin": 4, "value": 1}}' \
'$TB_URL/api/rpc/oneway/{deviceId}'

Returns HTTP 200 with empty body on success.

Sends a command and waits for the device to respond:

Terminal window
curl -X POST -H 'Content-Type: application/json' \
-H 'X-Authorization: $AUTH' \
-d '{"method": "getState", "params": {}}' \
'$TB_URL/api/rpc/twoway/{deviceId}'

Returns the device response as JSON. If the device does not respond within the timeout, returns HTTP 504.

Request body:

FieldRequiredDescription
methodYesRPC method name — the device must handle this method
paramsYesParameters passed to the device (any JSON)
timeoutNoTimeout in ms (default: 10000)
persistentNotrue to store the RPC and deliver when the device connects
retriesNoNumber of retries for persistent RPC
additionalInfoNoArbitrary metadata stored with persistent RPC

When "persistent": true, the platform stores the RPC request and delivers it when the device comes online.

Query persistent RPCs for a device:

Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/rpc/persistent/device/{deviceId}?pageSize=10&page=0&rpcStatus=QUEUED&sortProperty=createdTime&sortOrder=ASC'

Get a specific RPC by ID:

Terminal window
curl -H 'X-Authorization: $AUTH' \
'$TB_URL/api/rpc/persistent/{rpcId}'

Delete a persistent RPC:

Terminal window
curl -X DELETE -H 'X-Authorization: $AUTH' \
'$TB_URL/api/rpc/persistent/{rpcId}'

The table below lists all REST API controller groups available in Swagger UI. Each controller groups related endpoints.

ControllerDescription
device-controllerCRUD operations on devices, assign to customers/tenants, search
asset-controllerCRUD operations on assets, assign to customers, search
entity-view-controllerCreate and manage entity views (filtered projections of devices/assets)
entity-relation-controllerCreate, query, and delete relations between entities
customer-controllerCreate and manage customers, assign sub-entities
user-controllerManage users, settings, activation links
dashboard-controllerCRUD operations on dashboards, assign to customers, import/export
device-profile-controllerManage device profiles (transport, alarm rules, provisioning)
asset-profile-controllerManage asset profiles
ControllerDescription
telemetry-controllerSave/read/delete attributes and time series for any entity
entity-query-controllerQuery entities with filters, pagination, and data aggregation — see Entity Data Query API
ControllerDescription
alarm-controllerCreate, acknowledge, clear, assign, and query alarms
alarm-query-controllerQuery alarms with entity filters, severity, status, and time range — see Alarm Query API
alarm-comment-controllerAdd, update, and delete comments on alarms
ControllerDescription
rpc-v-2-controllerSend one-way/two-way RPC to devices, manage persistent RPCs
rpc-v-1-controllerDeprecated — use rpc-v-2-controller
ControllerDescription
rule-chain-controllerCRUD for rule chains, import/export, set root chain
rule-engine-controllerPush messages to the rule engine for a specific entity
ControllerDescription
admin-controllerSystem settings (mail, SMS, general), updates check
tenant-controllerManage tenants
tenant-profile-controllerManage tenant profiles (rate limits, quotas)
auth-controllerPassword reset, change password, user activation
login-endpointLogin (JWT), token refresh
queue-controllerManage processing queues
queue-stats-controllerView queue statistics
audit-log-controllerQuery audit logs (by user, entity, or tenant)
usage-info-controllerGet tenant API usage info
ControllerDescription
api-key-controllerCreate, enable/disable, and delete API keys
two-factor-auth-controller2FA verification (send/check codes, login with 2FA)
two-factor-auth-config-controllerConfigure 2FA providers and account settings
o-auth-2-controllerManage OAuth2 clients and login settings
domain-controllerManage custom domains and OAuth2 client assignments
secret-controllerStore and manage secrets (passwords, tokens)
ControllerDescription
notification-controllerSend notifications, mark as read, get notification feed
notification-rule-controllerManage notification rules (triggers)
notification-target-controllerManage notification targets (recipients)
notification-template-controllerManage notification templates
ControllerDescription
device-connectivity-controllerGet connectivity commands and download certificates
lwm-2m-controllerLwM2M bootstrap security info
ControllerDescription
ota-package-controllerUpload and manage firmware/software OTA packages
tb-resource-controllerUpload and manage platform resources (images, files, LwM2M models)
image-controllerUpload, update, and serve images
ControllerDescription
widgets-bundle-controllerManage widget bundles
widget-type-controllerManage individual widget types
ui-settings-controllerGet UI configuration (help base URL)
ControllerDescription
entities-version-control-controllerSave/load entity versions, compare, list branches
solution-controllerInstall and manage solution templates
ControllerDescription
edge-controllerManage edge instances, assign entities to edges
edge-event-controllerQuery edge sync events
ControllerDescriptionPE only
integration-controllerManage platform integrationsYes
converter-controllerManage uplink/downlink convertersYes
converter-library-controllerBrowse converter library by vendor/modelYes
ControllerDescriptionPE only
entity-group-controllerCreate and manage entity groups, share with usersYes
group-permission-controllerManage group-level permissionsYes
role-controllerManage roles (generic, group)Yes
ControllerDescriptionPE only
scheduler-event-controllerCreate and manage scheduled eventsYes
report-controllerGenerate and download dashboard reportsYes
report-template-controllerManage report templatesYes
dashboard-report-controllerDownload dashboard reports (legacy)Yes
ControllerDescriptionPE only
white-labeling-controllerCustomize branding (logo, colors, login page)Yes
custom-menu-controllerManage custom menu itemsYes
custom-translation-controllerManage custom UI translationsYes
ControllerDescription
calculated-field-controllerCreate and manage calculated fields, test expressions
ControllerDescription
mobile-app-controllerManage mobile app configurations
mobile-app-bundle-controllerManage mobile app bundles
qr-code-settings-controllerManage QR code and mobile app settings
ControllerDescriptionPE only
ai-model-controllerManage AI model configurationsYes
ai-chat-controllerAI chat sessionsYes
ControllerDescription
component-descriptor-controllerBrowse available rule node components
blob-entity-controllerUpload and download binary entities
event-controllerQuery rule engine events (errors, debug, lifecycle)
owner-controllerChange entity ownership (tenant ↔ customer)
self-registration-controllerManage self-registration settings
  • Entity Data Query API — advanced entity search with filters, used by entity-query-controller and WebSocket ENTITY_DATA
  • Alarm Query API — alarm search with severity, status, and time filters, used by alarm-query-controller and WebSocket ALARM_DATA
  • WebSocket API — real-time subscriptions for telemetry, alarms, and notifications
  • APIs & SDKs — all available APIs and client libraries