> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Node Red Admin

> Client-mode REST API connectors for Node-RED and FlowFuse: read and deploy Node-RED flows through the Admin API, start and stop flows, read context, manage node modules, send MQTT data to your own HTTP In endpoints, and manage FlowFuse teams, applications, hosted instances, snapshots and devices from MQTT

Technical Preview

## Overview

Client-mode REST API connectors for Node-RED and FlowFuse: read and deploy Node-RED flows through the Admin API, start and stop flows, read context, manage node modules, send MQTT data to your own HTTP In endpoints, and manage FlowFuse teams, applications, hosted instances, snapshots and devices from MQTT.

This is one of the templates in the Node-RED (Admin API, HTTP In nodes) and FlowFuse REST API app (`node-red-and-flowfuse`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

## Auth

Auth headers used by the template: `Authorization: Bearer {value.json.token}`.

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Node Red Admin connector | no |
| `BaseUrl` | string | Node Red Admin base URL without trailing slash (e.g. http\://YOUR\_NODE\_RED\_HOST:1880) | yes |

`BASE_ADDRESS` default: `http://YOUR_NODE_RED_HOST:1880`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `GetAuthScheme` | GET | `/auth/login` | `historian/node-red/auth-scheme/get` | `historian/node-red/auth-scheme/get/response` | none |
| `CreateToken` | POST | `/auth/token` | `historian/node-red/token/create` | `historian/node-red/token/create/response` | `body` |
| `RevokeToken` | POST | `/auth/revoke` | `historian/node-red/token/delete` | `historian/node-red/token/delete/response` | `body`, `token` |
| `GetSettings` | GET | `/settings` | `historian/node-red/settings/get` | `historian/node-red/settings/get/response` | `token` |
| `GetDiagnostics` | GET | `/diagnostics` | `historian/node-red/diagnostics/get` | `historian/node-red/diagnostics/get/response` | `token` |
| `GetFlows` | GET | `/flows` | `historian/node-red/flows/get` | `historian/node-red/flows/get/response` | `token` |
| `DeployFlows` | POST | `/flows` | `historian/node-red/flows/deploy` | `historian/node-red/flows/deploy/response` | `body`, `deploymentType`, `token` |
| `ReloadFlows` | POST | `/flows` | `historian/node-red/flows/reload` | `historian/node-red/flows/reload/response` | `token` |
| `GetFlowsState` | GET | `/flows/state` | `historian/node-red/flows-state/get` | `historian/node-red/flows-state/get/response` | `token` |
| `SetFlowsState` | POST | `/flows/state` | `historian/node-red/flows-state/update` | `historian/node-red/flows-state/update/response` | `body`, `token` |
| `AddFlow` | POST | `/flow` | `historian/node-red/flow/create` | `historian/node-red/flow/create/response` | `body`, `token` |
| `GetFlow` | GET | `/flow/{value.json.id}` | `historian/node-red/flow/get` | `historian/node-red/flow/get/response` | `id`, `token` |
| `UpdateFlow` | PUT | `/flow/{value.json.id}` | `historian/node-red/flow/update` | `historian/node-red/flow/update/response` | `body`, `id`, `token` |
| `DeleteFlow` | DELETE | `/flow/{value.json.id}` | `historian/node-red/flow/delete` | `historian/node-red/flow/delete/response` | `id`, `token` |
| `ListNodes` | GET | `/nodes` | `historian/node-red/node/list` | `historian/node-red/node/list/response` | `token` |
| `GetNodeModule` | GET | `/nodes/{value.json.module}` | `historian/node-red/node-module/get` | `historian/node-red/node-module/get/response` | `module`, `token` |
| `InstallNodeModule` | POST | `/nodes` | `historian/node-red/node-module/create` | `historian/node-red/node-module/create/response` | `body`, `token` |
| `SetNodeModuleState` | PUT | `/nodes/{value.json.module}` | `historian/node-red/node-module/update` | `historian/node-red/node-module/update/response` | `body`, `module`, `token` |
| `RemoveNodeModule` | DELETE | `/nodes/{value.json.module}` | `historian/node-red/node-module/delete` | `historian/node-red/node-module/delete/response` | `module`, `token` |
| `GetContext` | GET | `/context/{value.json.path}` | `historian/node-red/context/get` | `historian/node-red/context/get/response` | `path`, `token` |
| `DeleteContext` | DELETE | `/context/{value.json.path}` | `historian/node-red/context/delete` | `historian/node-red/context/delete/response` | `path`, `token` |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode NODE_RED_ADMIN"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE NodeRedAdmin WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "http://YOUR_NODE_RED_HOST:1880"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "false"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT GetAuthScheme
        WITH SOURCE_TOPIC "historian/node-red/auth-scheme/get"
        WITH DESTINATION_TOPIC "historian/node-red/auth-scheme/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/auth/login"
        WITH HEADERS
            ADD "Accept" "application/json"
    ADD EVENT CreateToken
        WITH SOURCE_TOPIC "historian/node-red/token/create"
        WITH DESTINATION_TOPIC "historian/node-red/token/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/auth/token"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT RevokeToken
        WITH SOURCE_TOPIC "historian/node-red/token/delete"
        WITH DESTINATION_TOPIC "historian/node-red/token/delete/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/auth/revoke"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
        WITH BODY "{value.json.body}"
    ADD EVENT GetSettings
        WITH SOURCE_TOPIC "historian/node-red/settings/get"
        WITH DESTINATION_TOPIC "historian/node-red/settings/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/settings"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT GetDiagnostics
        WITH SOURCE_TOPIC "historian/node-red/diagnostics/get"
        WITH DESTINATION_TOPIC "historian/node-red/diagnostics/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/diagnostics"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT GetFlows
        WITH SOURCE_TOPIC "historian/node-red/flows/get"
        WITH DESTINATION_TOPIC "historian/node-red/flows/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/flows"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "Node-RED-API-Version" "v2"
    ADD EVENT DeployFlows
        WITH SOURCE_TOPIC "historian/node-red/flows/deploy"
        WITH DESTINATION_TOPIC "historian/node-red/flows/deploy/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/flows"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "Node-RED-API-Version" "v2"
            ADD "Node-RED-Deployment-Type" "{value.json.deploymentType}"
        WITH BODY "{value.json.body}"
    ADD EVENT ReloadFlows
        WITH SOURCE_TOPIC "historian/node-red/flows/reload"
        WITH DESTINATION_TOPIC "historian/node-red/flows/reload/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/flows"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "Node-RED-API-Version" "v2"
            ADD "Node-RED-Deployment-Type" "reload"
        WITH BODY "{}"
    ADD EVENT GetFlowsState
        WITH SOURCE_TOPIC "historian/node-red/flows-state/get"
        WITH DESTINATION_TOPIC "historian/node-red/flows-state/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/flows/state"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT SetFlowsState
        WITH SOURCE_TOPIC "historian/node-red/flows-state/update"
        WITH DESTINATION_TOPIC "historian/node-red/flows-state/update/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/flows/state"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
        WITH BODY "{value.json.body}"
    ADD EVENT AddFlow
        WITH SOURCE_TOPIC "historian/node-red/flow/create"
        WITH DESTINATION_TOPIC "historian/node-red/flow/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/flow"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
        WITH BODY "{value.json.body}"
    ADD EVENT GetFlow
        WITH SOURCE_TOPIC "historian/node-red/flow/get"
        WITH DESTINATION_TOPIC "historian/node-red/flow/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/flow/{value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT UpdateFlow
        WITH SOURCE_TOPIC "historian/node-red/flow/update"
        WITH DESTINATION_TOPIC "historian/node-red/flow/update/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/flow/{value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
        WITH BODY "{value.json.body}"
    ADD EVENT DeleteFlow
        WITH SOURCE_TOPIC "historian/node-red/flow/delete"
        WITH DESTINATION_TOPIC "historian/node-red/flow/delete/response"
        WITH METHOD "DELETE"
        WITH ENDPOINT "/flow/{value.json.id}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT ListNodes
        WITH SOURCE_TOPIC "historian/node-red/node/list"
        WITH DESTINATION_TOPIC "historian/node-red/node/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/nodes"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT GetNodeModule
        WITH SOURCE_TOPIC "historian/node-red/node-module/get"
        WITH DESTINATION_TOPIC "historian/node-red/node-module/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/nodes/{value.json.module}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT InstallNodeModule
        WITH SOURCE_TOPIC "historian/node-red/node-module/create"
        WITH DESTINATION_TOPIC "historian/node-red/node-module/create/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/nodes"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
        WITH BODY "{value.json.body}"
    ADD EVENT SetNodeModuleState
        WITH SOURCE_TOPIC "historian/node-red/node-module/update"
        WITH DESTINATION_TOPIC "historian/node-red/node-module/update/response"
        WITH METHOD "PUT"
        WITH ENDPOINT "/nodes/{value.json.module}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
        WITH BODY "{value.json.body}"
    ADD EVENT RemoveNodeModule
        WITH SOURCE_TOPIC "historian/node-red/node-module/delete"
        WITH DESTINATION_TOPIC "historian/node-red/node-module/delete/response"
        WITH METHOD "DELETE"
        WITH ENDPOINT "/nodes/{value.json.module}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT GetContext
        WITH SOURCE_TOPIC "historian/node-red/context/get"
        WITH DESTINATION_TOPIC "historian/node-red/context/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/context/{value.json.path}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT DeleteContext
        WITH SOURCE_TOPIC "historian/node-red/context/delete"
        WITH DESTINATION_TOPIC "historian/node-red/context/delete/response"
        WITH METHOD "DELETE"
        WITH ENDPOINT "/context/{value.json.path}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "Bearer {value.json.token}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

## Usage example

Call `GetAuthScheme` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'historian/node-red/auth-scheme/get/response' &
mosquitto_pub -t 'historian/node-red/auth-scheme/get' -m '{}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.