# Adding variables to MQTT topic urls in Routes

**URL:** <https://discuss.blues.com/t/adding-variables-to-mqtt-topic-urls-in-routes/292>\
**Category:** Notehub.io\
**Created:** [June 9, 2021, 5:26pm UTC](https://discuss.blues.com/t/adding-variables-to-mqtt-topic-urls-in-routes/292 "2021-06-09T17:26:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptbkt](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/ptbkt/32/181_2.png) [@ptbkt](https://discuss.blues.com/u/ptbkt)\
**Post date:** [June 9, 2021, 5:26pm UTC](https://discuss.blues.com/t/adding-variables-to-mqtt-topic-urls-in-routes/292/1 "2021-06-09T17:26:59Z")

</div>

Hi, I’m trying to integrate our product with a third party whose API requires us to insert a unique token into the MQTT topic URL.

Is there a way to dynamically insert this in a similar way to how JSONata works, I.E. “body.deviceToken” ?

Apologies if this has been covered or is lurking somewhere in the docs that I have not seen.

---

<div class="post-metadata">

**Author:** ![RobLauer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/roblauer/32/1567_2.png) [@RobLauer](https://discuss.blues.com/u/RobLauer)\
**Post date:** [June 9, 2021, 7:38pm UTC](https://discuss.blues.com/t/adding-variables-to-mqtt-topic-urls-in-routes/292/2 "2021-06-09T19:38:23Z")

</div>

Hi @ptbkt ,

Yes, you can substitute DeviceUID, ProductUID, or device serial number in the topic URL. It’s actually documented in the [MQTT route guide](https://dev.blues.io/build/routing-guides/mqtt-route/#using-substitutions-for-the-mqtt-topic).

---

<div class="post-metadata">

**Author:** ![ptbkt](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/ptbkt/32/181_2.png) [@ptbkt](https://discuss.blues.com/u/ptbkt)\
**Post date:** [June 9, 2021, 8:00pm UTC](https://discuss.blues.com/t/adding-variables-to-mqtt-topic-urls-in-routes/292/3 "2021-06-09T20:00:16Z")

</div>

Thank you @RobLauer, I knew there was probably something I’d not ready properly 🙂

---

<div class="post-metadata">

**Author:** ![jlandgrave62](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/jlandgrave62/32/517_2.png) [@jlandgrave62](https://discuss.blues.com/u/jlandgrave62)\
**Post date:** [August 30, 2022, 6:59pm UTC](https://discuss.blues.com/t/adding-variables-to-mqtt-topic-urls-in-routes/292/4 "2022-08-30T18:59:58Z")

</div>

@RobLauer , @tjvantoll - this will send the NoteCard device ID to the route. Is it possible for me to send the ID of the END LORA device in the MQTT topic?

Also, it would be nice if I didn’t have to pick each individual #air.qo file for the route rather than list air.qo as the file time and having ALL of them routed. As it works now I would have to modify the route every time I added another sensor even if nothing has changed other than just adding a sensor!

---

<div class="post-metadata">

**Author:** ![tjvantoll](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.blues.com/tjvantoll/32/231_2.png) [@tjvantoll](https://discuss.blues.com/u/tjvantoll)\
**Post date:** [August 31, 2022, 12:51pm UTC](https://discuss.blues.com/t/adding-variables-to-mqtt-topic-urls-in-routes/292/5 "2022-08-31T12:51:31Z")

</div>

Hey @jlandgrave62,

> Is it possible for me to send the ID of the END LORA device in the MQTT topic?

You can do this by manually including the identifier in the topic (aka providing the `2037335832365003004e001d` in `2037335832365003004e001d#motion.qo`), but there’s no built-in substitution shorthand like `[device]`.

> Also, it would be nice if I didn’t have to pick each individual #air.qo file for the route rather than list air.qo as the file time and having ALL of them routed. As it works now I would have to modify the route every time I added another sensor even if nothing has changed other than just adding a sensor!

Ah, interesting. Just so I understand your desired behavior—you’d like to be able to select a file on a route (e.g. `air.qo`) and have it automatically route all `air.qo` events on that gateway regardless of which sensor they came from?

And thanks for all this feedback 🙂

TJ
