Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

the-things-stack-webhooks

FreeRuns bundled scriptsNot checked

Receive and authenticate The Things Stack webhooks (The Things Network and The Things Industries LoRaWAN Application Server). Use when creating a custom…

hookdeckby hookdeck★ 104 GitHub stars

About this skill

The Things Stack Webhooks

The Things Stack (the LoRaWAN network server behind The Things Network and The Things Industries) can send each application's messages to an HTTP endpoint: uplinks, join-accepts, downlink events, location results. You add a webhook under your application's Integrations > Webhooks in the Console. The Application Server always sends POST requests with a JSON body.

When to Use This Skill

  • How do I receive The Things Stack (TTN) uplinks with a webhook?
  • How do I authenticate The Things Stack webhook requests? (there's no signature)
  • What does "Request authentication" send? (Authorization: Basic …)
  • How do I tell uplink, join-accept and downlink messages apart?
  • What is the X-Downlink-Apikey header?

Authentication (core)

The Things Stack doesn't sign webhooks. Check Request authentication on the webhook and enter a username and password: the Console stores an Authorization header that the Application Server sends with every request.

Authorization: Basic base64(<username>:<password>)

The docs call it "Authentication: Basic ", but the Console code sets Authorization (headers.Authorization = 'Basic ' + btoa(username + ':' + password)).

const crypto = require('crypto');

const safeEqual = (a, b) => crypto.timingSafeEqual(
  crypto.createHash('sha256').update(a).digest(),
  crypto.createHash('sha256').update(b).digest());

function verifyBasicAuth(authorization, username, password) {
  const match = /^Basic\s+([A-Za-z0-9+/]+={0,2})\s*$/i.exec(String(authorization || ''));
  if (!match || !username || !password) return false;
  const decoded = Buffer.from(match[1], 'base64').toString('utf8');
  const i = decoded.indexOf(':');                    // split at the FIRST colon
  if (i < 0) return false;
  const userOk = safeEqual(decoded.slice(0, i), username);
  const passOk = safeEqual(decoded.slice(i + 1), password);
  return userOk && passOk;
}
  • Compare both values in constant time, and evaluate both before combining, so a wrong username doesn't return faster.
  • The password can contain :. Split at the first colon only.
  • Missing or wrong credentials: 401. Credentials not configured: 500.
  • Webhooks made with templates, the CLI or the API can set any header, so Authorization is just a stored header. Without Request authentication, nothing authenticates the request: use HTTPS and a hard-to-guess path at the least.

For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.

Hookdeck: Hookdeck's The Things Stack source type (THE_THINGS_STACK) checks the basic auth credentials. Enter the same username and password as in Request authentication.

Messages

Every message has end_device_ids, correlation_ids and received_at, plus one message object named after its type:

{
  "end_device_ids": { "device_id": "dev1", "application_ids": { "application_id": "app1" }, "dev_eui": "0004A30B001C0530", "dev_addr": "00BCB929" },
  "correlation_ids": ["as:up:01E0WZGT6Y7657CPFPE5WEYDSQ"],
  "received_at": "2020-02-12T15:15:46.014773143Z",
  "uplink_message": {
    "f_port": 1, "f_cnt": 1, "frm_payload": "gkHe",
    "decoded_payload": { "temperature": 1.0, "luminosity": 0.64 },
    "rx_metadata": [{ "gateway_ids": { "gateway_id": "gtw1" }, "rssi": -35, "snr": 5.2 }]
  }
}
Message object Sent for
uplink_message An uplink. frm_payload is base64; decoded_payload appears when a payload formatter is set
uplink_normalized A normalized uplink
join_accept A device joined
downlink_ack, downlink_nack, downlink_sent, downlink_failed, downlink_queued, downlink_queue_invalidated Downlink events
location_solved A location result
service_data Service data

Fields whose value is "", 0 or false are left out of the payload. See references/overview.md.

Headers

Header When
Authorization Request authentication is on (or you set it yourself)
X-Downlink-Apikey, X-Downlink-Push, X-Downlink-Replace A Downlink API key is set. The key can schedule downlinks: don't log it
X-Tts-Domain The deployment's domain

Environment Variables

TTS_WEBHOOK_USERNAME=your-username   # the same values as in Request authentication
TTS_WEBHOOK_PASSWORD=your-password

Local Development

# Express / Next.js (use 8000 for FastAPI). No install or account required.
npx hookdeck-cli listen 3000 the-things-stack --path /webhooks/the-things-stack

Use the printed URL as the webhook's Base URL, turn on Request authentication with the same credentials, and enable Uplink message. See references/setup.md.

Reference Materials

  • [references/overview.md](referenc
Full SKILL.md on GitHub

Install the-things-stack-webhooks in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

examples/express/.env.exampleexamples/express/README.mdexamples/express/package.jsonexamples/express/src/index.jsexamples/fastapi/.env.exampleexamples/fastapi/README.mdexamples/fastapi/main.pyexamples/fastapi/requirements.txtexamples/fastapi/test_webhook.pyexamples/nextjs/.env.exampleexamples/nextjs/README.mdexamples/nextjs/app/webhooks/the-things-stack/route.tsexamples/nextjs/lib/verify-the-things-stack.tsexamples/nextjs/package.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

What does the the-things-stack-webhooks skill do?

Receive and authenticate The Things Stack webhooks (The Things Network and The Things Industries LoRaWAN Application Server). Use when creating a custom webhook in the Console, enabling Request authentication (Authorization: Basic header), checking basic auth credentials, choosing enabled event types and paths, handling the X-Downlink-Apikey header, or processing uplink_message, join_accept, downlink_ack, downlink_failed and location_solved messages.

How do I install the the-things-stack-webhooks skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the the-things-stack-webhooks skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare the-things-stack-webhooks with