Skip to content
Stand with Ukraine flag

REST Call Reply

Use this node to send the current message data as an HTTP response to an incoming REST API request submitted to the rule engine — for example, completing a synchronous REST call that triggered rule chain processing by returning a computed result back to the caller.

  • Service Id — metadata key that holds the service identifier. Default: serviceId.
  • Request Id — metadata key that holds the request UUID. Default: requestUUID.

To trigger this flow, submit a message to the rule engine via one of these REST endpoints:

EndpointOriginator
POST /api/rule-engine/The authenticated user
POST /api/rule-engine/{entityType}/{entityId}The specified entity
POST /api/rule-engine/{entityType}/{entityId}/{timeout}The specified entity, custom timeout (ms)
POST /api/rule-engine/{entityType}/{entityId}/{queueName}/{timeout}The specified entity, custom queue and timeout

ThingsBoard automatically injects serviceId and requestUUID into the message metadata. These values must be preserved throughout the processing chain. If they are overwritten or removed, the reply cannot be routed and the original REST call will time out.

  1. Extract serviceId from message metadata using the configured key. If missing, route via Failure.
  2. Extract requestId from message metadata using the configured key. If missing or not a valid UUID, route via Failure.
  3. Verify that message data is not empty. If empty, route via Failure.
  4. Send the message data as the HTTP response body to the originating REST API call.
  5. Route the original message via Success.
ConnectionCondition
SuccessReply sent successfully. Outgoing message is unchanged.
FailureMissing serviceId, missing or invalid requestId, empty message data, or unexpected error.

Example 1 — Reply with processing result

Section titled “Example 1 — Reply with processing result”

Originator: DEVICE | Metadata (injected by ThingsBoard):

{
"serviceId": "monolith",
"requestUUID": "a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6"
}

Data (prepared by earlier rule nodes):

{
"status": "completed",
"fileName": "sensor_data_2024_10_02.csv",
"recordsProcessed": 1250
}
{
"serviceIdMetaDataAttribute": "serviceId",
"requestIdMetaDataAttribute": "requestUUID"
}

Result: message data returned as HTTP response to the waiting REST caller. Routes via Success.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TbSendRestApiCallReplyNodeConfiguration",
"type": "object",
"required": ["serviceIdMetaDataAttribute", "requestIdMetaDataAttribute"],
"additionalProperties": false,
"properties": {
"serviceIdMetaDataAttribute": {
"type": "string",
"description": "Metadata key for the service identifier."
},
"requestIdMetaDataAttribute": {
"type": "string",
"description": "Metadata key for the request UUID."
}
}
}