Skip to main content

REST API Overview

The REST_API connector enables HTTP communication in both directions:
  • Client Mode - Make HTTP requests to external APIs triggered by MQTT messages
  • Server Mode - Expose HTTP endpoints that accept data and publish it to MQTT topics
REST API connectors are ideal for integrating with web services, webhooks, cloud APIs, and creating HTTP-to-MQTT bridges.

Basic Syntax


How REST API Connectors Work

A REST API connector bridges the HTTP and MQTT worlds. It contains events that define what happens when data flows through—either from MQTT to HTTP (client mode) or from HTTP to MQTT (server mode).

REST API Configuration

REST_API_CONFIG Parameters

string
required
Base URL for HTTP requests (e.g., https://api.example.com).
boolean
Enable HTTP client functionality. Default: false.
integer
Request timeout in seconds. Default: 30.
string
Default content type. Default: application/json.
boolean
Enable HTTP server functionality. Default: false.
integer
HTTP server port. Default: 8080.
string
Basic authentication username.
string
Basic authentication password.
boolean
Enable SSL/TLS. Default: false.
boolean
Ignore certificate validation errors. Default: false.
boolean
Enable CORS headers. Default: false.
string
Allowed CORS origins. Default: * (all).

Client Mode

Use client mode when your broker needs to call external APIs. An MQTT message triggers the HTTP request, and the response is published back to MQTT.

Event Configuration

string
MQTT topic that triggers the HTTP request.
string
MQTT topic to publish HTTP response.
string
HTTP method: GET, POST, PUT, DELETE, PATCH.
string
API endpoint path (supports placeholders).
string
Request body for POST/PUT (supports placeholders).

Placeholder Support

Use placeholders in endpoints and bodies to insert dynamic values from the MQTT message: A placeholder in ENDPOINT stays on the connector’s BASE_ADDRESS. A value that points at another host, such as /evil.example/x or https://evil.example/x, is refused, and the reply topic gets a RequestRejected error. An ENDPOINT you write as a full URL still uses that URL.

Client Examples

Fetch data from an external API when an MQTT message arrives:
When a message like {"city": "London", "apikey": "abc123"} arrives at weather/request, the connector calls the API and publishes the weather data to weather/response.

Server Mode

Use server mode when external systems need to send data to your broker via HTTP. The broker exposes an HTTP endpoint that accepts requests and publishes the data to MQTT topics.
Common use case: Your web application, mobile app, or third-party service needs to push data into the MQTT broker without implementing an MQTT client.

Why Use Server Mode?

Server Event Configuration

string
The HTTP path to expose (e.g., /api/sensors).
string
HTTP method to accept: GET, POST, PUT, DELETE.
string
MQTT topic where incoming HTTP data is published.

Server Examples

Expose an endpoint for devices to submit readings via HTTP:
Usage: Send sensor data with a simple HTTP POST:
The data is published to sensors/from/http and available to all MQTT subscribers.

Combined Client and Server

A single connector can operate in both modes—accepting HTTP requests AND calling external APIs:

Complete Examples

Full API for a web dashboard to read sensor data and send commands:

Troubleshooting

  • Verify BASE_ADDRESS is correct
  • Check firewall allows outbound connections
  • Increase REQUEST_TIMEOUT if API is slow
  • Verify network connectivity
  • Ensure USE_SSL matches the API requirements
  • For self-signed certificates, set IGNORE_CERT_ERRORS (not recommended for production)
  • Verify certificate chain is complete
  • Verify USERNAME and PASSWORD are correct
  • Check Authorization header format
  • Ensure API key is valid and not expired
  • Enable CORS on the server: WITH ENABLE_CORS "true"
  • Configure specific allowed origins
  • Check browser console for specific CORS error messages
  • Verify DESTINATION_TOPIC is configured
  • Check MQTT broker connectivity
  • Monitor broker logs for errors

Best Practices

Always use SSL/TLS for external API connections:
Configure timeouts based on expected API response times:
Subscribe to response topics to monitor API call results and handle failures in your Actions.
When exposing HTTP server endpoints:
  • Use authentication where needed
  • Limit CORS origins to specific domains
  • Consider rate limiting at the network level
Configure different base URLs for development and production environments.

REST API app templates

Ready-made client connectors (public test APIs, weather, Slack, GitHub, and planned enterprise systems such as SAP HANA and Salesforce) are listed in the REST API Apps catalog. Each app page shows the LoT connector definition, the event table, and how auth is passed.
That catalog does not include competitor brokers (HiveMQ, EMQX, ThingWorx) or OEM device connectors.

Discover templates and REST API apps: -listTemplates and -connectorCode

The broker ships every REST API app on this catalog as a template, keyed by its app code. Two broker commands, published to $SYS/Coreflux/Command, expose them (defined in Commands/Commands.cs): An app with one connector is keyed by its folder name, upper-cased with every non-alphanumeric run turned into _ (sap-s4hana-cloud becomes SAP_S4HANA_CLOUD). An app with several connectors keys each one by its connector name without the RestApi suffix (GeminiApiRestApi becomes GEMINI_API). The catalog lists every app code. Each card has this shape (from RouteHandler.BuildTemplatePayload):
  • status is beta for every app today: the broker accepts no other value. The docs call this technical preview.
  • license is community when a Community broker can deploy the template, otherwise licensed. minimumTier is Community, Growth or Enterprise, actionSlots is the number of actions the connector registers, and availableOnThisBroker says whether the current license can deploy it.
  • requiredSecrets lists the broker secrets the template reads (GET SECRET or {secret.NAME}). Create them before you deploy.
  • connector is true and baseType is REST_API for every REST API app. For built-in connector templates connector is false and baseType equals type. The field keeps the name connector for compatibility; it marks a REST API app.
  • An app code is not a connector type: deploy the template with WITH TYPE REST_API, not WITH TYPE AIRTABLE.
  • template is the deployable connector code only. The ADD METADATA block is split off into metadata, because -addConnector rejects it.
  • #Name,type,description,regex,required# markers are Hub placeholders (for example #RouteName# and #BaseUrl#). Replace them with real values before you deploy with -addConnector (-addRoute remains a supported alias).

Next Steps

Streaming Connectors

Stream MQTT messages through Kafka.

Connector Examples

See complete connector configuration examples.
Last modified on October 25, 2026