How to Create Reusable MQTT Publish Templates in Katman
Save MQTT messages as reusable templates, publish JSON, text or binary payloads, run publishing cycles, and add MQTT 5 request metadata in Katman.
Testing an MQTT device often means sending the same command several times: request its status, change one field, and send the message again while watching the reply. Recreating the topic, payload, and delivery settings each time adds work and makes it easier to send a different message than intended.
Katman's Publish Templates keep those settings together in reusable cards. You can publish a saved message once or start a repeating cycle. This guide walks through a status-request example, shows how to verify what the broker received, and explains the MQTT 5 fields available on each card.
Prepare a broker and an observer
You need Katman MQTT, an MQTT broker you can publish to, and a way to
observe the test topic. Use a dedicated test topic such as
lab/device-01/command so the example stays separate from operational commands.
The sample payload below is an example application message; a real device must
implement that command to act on it.
If you have Mosquitto installed, you can start a local MQTT broker in a terminal:
mosquitto -p 18884
With Mosquitto 2.x, a broker started this way listens on the local machine's loopback interface. See the Mosquitto broker manual for configuration details.
Connect the Katman desktop app to localhost on port 18884, using MQTT 3.1.1
or MQTT 5.0. This local TCP example has no TLS or credentials. For your own
secured broker, use its required settings; the
MQTT certificates guide explains the TLS fields.
Start an independent subscriber before publishing:
mosquitto_sub -h localhost -p 18884 -t 'lab/device-01/command' -q 1 -v
Alternatively, subscribe to that exact topic in another MQTT client. Observing the message independently helps distinguish publishing success from a device's application behavior.
Create a reusable publish template
Open PUBLISH in Katman's toolbar. Select an existing blank card or choose ADD TEMPLATE, then enter these settings:
| Field | Example value |
|---|---|
| Topic | lab/device-01/command |
| QoS | 1 |
| Cycle | Publish once |
| Retain | Off |
| Payload format | JSON |
Paste this payload into the card:
{
"command": "get_status",
"includeDiagnostics": true
}
Katman validates JSON and shows its payload size. A publish topic must be a
concrete topic: subscription wildcards such as + and # cannot be used here.

Select PUBLISH. The observer should receive the topic and the JSON you entered:
lab/device-01/command {
"command": "get_status",
"includeDiagnostics": true
}
The template remains available for another send. Edit a field when you want a different test input, or add another card for a separate command.
Broker acknowledgement and device response are different
At QoS 1, Katman can report that the broker acknowledged the publish. This confirms the MQTT delivery step to the broker. It does not confirm that a device processed the command or published a reply.
For this first check, seeing the message in the independent subscriber is the expected result. A device response requires a subscriber that understands your application's command and reply convention.
Keep RETAIN off for this example. Enabling it asks the broker to retain the message for later subscribers, which can be useful for state but needs deliberate handling when the payload represents a command.
Choose JSON, text, or binary payloads
Each template supports three payload input formats:
| Format | Use it for | Example |
|---|---|---|
| JSON | Structured application messages | {"command":"get_status"} |
| Text | Plain UTF-8 messages | get_status |
| Base64 | Entering binary payload bytes | SGVsbG8= |
Base64 input is decoded before publishing. For example, SGVsbG8= represents the
five bytes of Hello; the literal Base64 characters are not the payload sent to
the broker. Use standard padded Base64. The format tab controls how Katman
interprets the input, so choose Text if you intend to send Base64 characters as
ordinary text.
JSON must parse successfully before the card can publish. If PUBLISH is disabled, check the active connection, topic, payload validation, and any MQTT 5 field errors shown on the card.
Publish repeatedly with a cycle
Change CYCLE from Publish once to an interval, then select START CYCLE. Katman sends the first message immediately and continues until you stop the cycle or a publish error stops it.
The available intervals are one second, five seconds, ten seconds, thirty seconds, one minute, and five minutes. During a cycle, the card shows its sent count and last-send time. Its message fields are locked; choose STOP CYCLE before editing.

For a quick check, choose Every second, observe several messages, and select STOP CYCLE. Subsequent sends should stop. An already submitted message can still be in transit when you stop.
Cycle sends run serially. Katman waits for a publish to settle before starting the next interval, so a slow broker can make the actual spacing longer than the selected interval. Treat this as a repeatable testing workflow rather than a precise throughput benchmark.
The card reuses the payload you entered. It does not automatically expand payload variables, increment counters, or generate random sensor values.
Add MQTT 5 request metadata
On an MQTT 5 connection, expand Advanced MQTT 5 to configure the message's request metadata:
| Field | What it controls |
|---|---|
| Response Topic | The concrete topic on which the responder should reply |
| Correlation Data Mode | Auto-generate or Manual |
| Correlation Data | A value you provide when Manual is selected |
| Correlation Data Encoding | UTF-8 text or Base64 for a manual value |
For the status example, set Response Topic to lab/device-01/reply and leave
Correlation Data Mode on Auto-generate.

Auto-generate creates a new UUID for each MQTT 5 message, including every cyclic send. A responding application should publish to the Response Topic and return the same correlation bytes in its response. This lets a monitoring client distinguish overlapping requests.
Manual mode is useful when testing a known correlation value. Text is encoded as UTF-8; Base64 lets you enter the bytes directly. These properties require an MQTT 5 connection. For MQTT 3.1.1, your application can use its own request/reply topic convention.
Adding these fields does not create a responder. Katman's separate Request / Response workspace monitors matching exchanges and their timing; MQTT 5 metadata-based monitoring there requires Pro. Publishing the metadata from a template is a separate operation. The Request / Response guide explains how to pair those replies and inspect latency and timeouts.
Turn an observed message into a template
You can also start from a message already visible in Katman's message table. Choose its Create publish template action to create a card with its topic, payload, QoS, and retain setting.
When original payload bytes are available, Katman uses them rather than an abbreviated preview. Binary and image payloads become Base64 inputs. Review the resulting card before sending, particularly the topic and retain flag.
The new card starts with Publish once. If MQTT 5 correlation metadata was copied, remember that new cards default to Auto-generate; select Manual deliberately if you need to resend a particular correlation value.
Save useful test messages for the next session
Templates are saved locally in the app or browser storage. Their settings survive normal restarts, but running cycles do not restart automatically. When you return, connect to the intended broker and start the sends you need.
Templates publish through the active connection. Check that connection before reusing a command card against another environment.
The Free plan supports three usable templates. Pro removes that product count limit; see current plan details. This makes it possible to start with a small set of test commands and expand it as your debugging workflow grows.
The examples and screenshots in this guide were checked using Katman's 1.0.1 source browser workspace over MQTT 5 WebSocket, a local Mosquitto broker, and an independent subscriber. The desktop app uses the same template controls with its native connection options.
Download Katman MQTT and create your first reusable test message.