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

# The Things Stack

> Client-mode REST API connector for a curated The Things Stack (TTN/TTI) slice: Identity Server application/device GET, Application Server webhook and AS downlink push, and Storage Integration uplink_message

Technical Preview

## Overview

A client-mode connector for a **curated cloud-IoT** slice of [The Things Stack](https://www.thethingsindustries.com/docs/api/reference/http/routes/) (The Things Network and The Things Industries) covering Hugo catalog #117 connector events:

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| GET application / end device | `GET /applications/{application_id}` (+ devices list/get) | Identity Server registry smoke |
| POST webhook downlink push | `POST /as/applications/{app}/webhooks/{id}/devices/{dev}/down/push` | Schedule downlink via webhook path |
| (AS downlink) | `POST /as/applications/{app}/devices/{dev}/down/push` | AppAs.DownlinkQueuePush |
| GET storage uplink\_message | `GET /as/applications/{app}/packages/storage/uplink_message` | Storage Integration (SSE / NDJSON) |

Default `BASE_ADDRESS` is `https://eu1.cloud.thethings.network/api/v3` (no trailing slash; substitute TTN `{region}` or TTI `https://{cluster}.cloud.thethings.industries/api/v3`). Topics use `cloud-iot/the-things-stack/<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_key}` (Console / CLI API key, typically `NNSXS.…`). Prefer Hub secrets (`THE_THINGS_STACK_AUTH`). Never commit real credentials. See [Scheduling Downlinks](https://www.thethingsindustries.com/docs/integrations/webhooks/scheduling-downlinks/) and the [HTTP API connectors](https://www.thethingsindustries.com/docs/api/reference/http/routes/).

> [!NOTE]
>
> This template has not been verified against a live authenticated The Things Stack tenant. Status remains blocked until an authenticated live smoke succeeds (prefer GET application → 200 and POST webhook downlink / GET storage uplink\_message → 2xx).

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — The Things Stack curated slice
# Auth: Authorization via {value.json.authorization} (Bearer NNSXS.…)
# BASE_ADDRESS: https://eu1.cloud.thethings.network/api/v3  → substitute region / TTI cluster

DEFINE ROUTE TheThingsStackRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://eu1.cloud.thethings.network/api/v3"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT GetApplication
        WITH SOURCE_TOPIC "cloud-iot/the-things-stack/application/get"
        WITH DESTINATION_TOPIC "cloud-iot/the-things-stack/application/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/applications/{value.json.application_id}?field_mask={value.json.field_mask}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT ListDevices
        WITH SOURCE_TOPIC "cloud-iot/the-things-stack/device/list"
        WITH DESTINATION_TOPIC "cloud-iot/the-things-stack/device/list/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/applications/{value.json.application_id}/devices?field_mask={value.json.field_mask}&limit={value.json.limit}&page={value.json.page}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT GetDevice
        WITH SOURCE_TOPIC "cloud-iot/the-things-stack/device/get"
        WITH DESTINATION_TOPIC "cloud-iot/the-things-stack/device/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/applications/{value.json.application_id}/devices/{value.json.device_id}?field_mask={value.json.field_mask}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT WebhookDownlinkPush
        WITH SOURCE_TOPIC "cloud-iot/the-things-stack/downlink/webhook-push"
        WITH DESTINATION_TOPIC "cloud-iot/the-things-stack/downlink/webhook-push/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/as/applications/{value.json.application_id}/webhooks/{value.json.webhook_id}/devices/{value.json.device_id}/down/push"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{payload}"
    ADD EVENT AsDownlinkPush
        WITH SOURCE_TOPIC "cloud-iot/the-things-stack/downlink/as-push"
        WITH DESTINATION_TOPIC "cloud-iot/the-things-stack/downlink/as-push/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/as/applications/{value.json.application_id}/devices/{value.json.device_id}/down/push"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{payload}"
    ADD EVENT GetStoredUplinks
        WITH SOURCE_TOPIC "cloud-iot/the-things-stack/storage/uplink-message"
        WITH DESTINATION_TOPIC "cloud-iot/the-things-stack/storage/uplink-message/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/as/applications/{value.json.application_id}/packages/storage/uplink_message?limit={value.json.limit}&after={value.json.after}&before={value.json.before}"
        WITH HEADERS
            ADD "Accept" "text/event-stream"
            ADD "Authorization" "{value.json.authorization}"
```

## MQTT topics

| Event | Source topic | Response topic |
| - | - | - |
| GetApplication | `cloud-iot/the-things-stack/application/get` | `…/application/get/response` |
| ListDevices | `cloud-iot/the-things-stack/device/list` | `…/device/list/response` |
| GetDevice | `cloud-iot/the-things-stack/device/get` | `…/device/get/response` |
| WebhookDownlinkPush | `cloud-iot/the-things-stack/downlink/webhook-push` | `…/downlink/webhook-push/response` |
| AsDownlinkPush | `cloud-iot/the-things-stack/downlink/as-push` | `…/downlink/as-push/response` |
| GetStoredUplinks | `cloud-iot/the-things-stack/storage/uplink-message` | `…/storage/uplink-message/response` |

## References

* [HTTP API connectors](https://www.thethingsindustries.com/docs/api/reference/http/routes/)
* [Scheduling Downlinks (webhooks)](https://www.thethingsindustries.com/docs/integrations/webhooks/scheduling-downlinks/)
* [Application Server APIs](https://www.thethingsindustries.com/docs/api/reference/grpc/application_server/)
* [Storage Integration API](https://www.thethingsindustries.com/docs/api/reference/grpc/storage_integration/)
* [End Device APIs](https://www.thethingsindustries.com/docs/api/reference/grpc/end_device/)
* [Storage Integration guide](https://www.thethingsindustries.com/docs/integrations/storage/)


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