> ## 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.

# ChirpStack v4

> Client-mode REST API connector for a curated ChirpStack v4 slice via chirpstack-rest-api: list/get devices, enqueue/get downlink queue, and get application

Technical Preview

## Overview

A client-mode connector for a **curated cloud-IoT** slice of [ChirpStack v4](https://www.chirpstack.io/docs/chirpstack/api/rest.html) covering Hugo catalog #118 connector events. ChirpStack v4 does **not** ship a built-in REST API — use [chirpstack-rest-api](https://github.com/chirpstack/chirpstack-rest-api) (gRPC gateway), typically on port **8090**.

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| GET devices by application | `GET /api/devices?applicationId=` | DeviceService.List |
| POST device queue (downlink) | `POST /api/devices/{devEui}/queue` | DeviceService.Enqueue |
| (get device) | `GET /api/devices/{devEui}` | DeviceService.Get |
| (get queue) | `GET /api/devices/{devEui}/queue` | DeviceService.GetQueue |
| (get application) | `GET /api/applications/{applicationId}` | ApplicationService.Get |
| HTTP integration `event=up` | inbound webhook | **Companion Server connector** — not in this client template |

Default `BASE_ADDRESS` is `https://localhost:8090` (no trailing slash; substitute `https://{host}:8090`). Topics use `cloud-iot/chirpstack-v4/<object>/<verb>`.

See the base guide: [REST API Connectors](/latest/lot-language/routes/rest-api-routes).

> [!NOTE]
>
> **Auth header:** Pass the full `Authorization` value via MQTT JSON field `authorization` as `Bearer {api_token}` (ChirpStack API key / JWT). Prefer Hub secrets (`CHIRPSTACK_AUTH`). Never commit real credentials. Some deployments also accept `Grpc-Metadata-Authorization: Bearer …`. See the [REST API notes](https://www.chirpstack.io/docs/chirpstack/api/rest.html) and [API reference](https://www.chirpstack.io/docs/chirpstack/api/api.html).

> [!NOTE]
>
> This template has not been verified against a live authenticated ChirpStack instance. Status remains blocked until an authenticated live smoke succeeds (prefer GET devices by `applicationId` → 200 and POST device queue → 2xx).

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — ChirpStack v4 curated slice
# Auth: Authorization via {value.json.authorization} (Bearer API token)
# BASE_ADDRESS: https://localhost:8090  → substitute host / TLS

DEFINE ROUTE ChirpStackV4RestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://localhost:8090"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT ListDevices
        WITH SOURCE_TOPIC "cloud-iot/chirpstack-v4/device/list"
        WITH DESTINATION_TOPIC "cloud-iot/chirpstack-v4/device/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/devices?applicationId={value.json.applicationId}&limit={value.json.limit}&offset={value.json.offset}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetDevice
        WITH SOURCE_TOPIC "cloud-iot/chirpstack-v4/device/get"
        WITH DESTINATION_TOPIC "cloud-iot/chirpstack-v4/device/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/devices/{value.json.devEui}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT EnqueueDeviceQueue
        WITH SOURCE_TOPIC "cloud-iot/chirpstack-v4/device/queue/enqueue"
        WITH DESTINATION_TOPIC "cloud-iot/chirpstack-v4/device/queue/enqueue/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/devices/{value.json.devEui}/queue"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{payload}"
    ADD EVENT GetDeviceQueue
        WITH SOURCE_TOPIC "cloud-iot/chirpstack-v4/device/queue/get"
        WITH DESTINATION_TOPIC "cloud-iot/chirpstack-v4/device/queue/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/devices/{value.json.devEui}/queue"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetApplication
        WITH SOURCE_TOPIC "cloud-iot/chirpstack-v4/application/get"
        WITH DESTINATION_TOPIC "cloud-iot/chirpstack-v4/application/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/applications/{value.json.applicationId}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
```

## MQTT topics

| Action | Source topic | Response topic |
| - | - | - |
| ListDevices | `cloud-iot/chirpstack-v4/device/list` | `…/device/list/response` |
| GetDevice | `cloud-iot/chirpstack-v4/device/get` | `…/device/get/response` |
| EnqueueDeviceQueue | `cloud-iot/chirpstack-v4/device/queue/enqueue` | `…/device/queue/enqueue/response` |
| GetDeviceQueue | `cloud-iot/chirpstack-v4/device/queue/get` | `…/device/queue/get/response` |
| GetApplication | `cloud-iot/chirpstack-v4/application/get` | `…/application/get/response` |

## References

* [ChirpStack REST API](https://www.chirpstack.io/docs/chirpstack/api/rest.html)
* [ChirpStack API / protobuf reference](https://www.chirpstack.io/docs/chirpstack/api/api.html)
* [chirpstack-rest-api (GitHub)](https://github.com/chirpstack/chirpstack-rest-api)
* [HTTP integration](https://www.chirpstack.io/docs/chirpstack/integrations/http.html)


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