> For the complete documentation index, see [llms.txt](https://docs.cybus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cybus.io/2-6-0/access/user-management/mqtt-user-authentication/adding-an-mqtt-publish-prefix.md).

# Adding an MQTT Publish Prefix

A publish prefix is a fixed topic fragment that Connectware prepends to every MQTT message a user publishes. Because you set it per user, different users can route their data to different destinations without changing the topics they publish to.

For example, if `UserA` has the prefix `topicA/` and publishes a message to `some/values`, Connectware delivers it on `topicA/some/values`.

Mapping resources can achieve the same routing, but each mapping adds an MQTT message transfer that a prefix avoids. This makes prefixes a good fit for high-throughput installations that need fast MQTT delivery.

## Admin UI Configuration

To add an MQTT prefix to an existing user in the Admin UI, edit the **MQTT Publish Prefix** field in the **Edit User** dialog.

1. Toggle the **Advanced mode** switch in the top right of the dialog. This extends the dialog with an **Additional permissions** section.

<figure><img src="/files/kD9DINJPqECAKv9tWobG" alt="Advanced mode switch in the Edit User dialog"><figcaption></figcaption></figure>

<figure><img src="/files/LHp6Ju2Ml1mGWLxCY9hH" alt="Edit User dialog in advanced mode"><figcaption></figcaption></figure>

2. Edit the **MQTT Publish Prefix** field.

<figure><img src="/files/uUPpkufetfNCzGGgRION" alt="MQTT Publish Prefix field"><figcaption></figcaption></figure>

{% hint style="warning" %}
The configured MQTT prefix must include the trailing topic-level separator `/`. Connectware does not insert a separator automatically, so the trailing separator has to be part of the configured value.
{% endhint %}

3. In the **Additional permissions** section, add an MQTT write permission for each topic the user publishes to, including the prefix. For example, if the prefix is `topicA/` and the user publishes to `some/values`, add write permission for `topicA/some/values`. To omit the prefix from the permission, use an MQTT wildcard as a placeholder, for example `+/some/values`.

## Example

This example sets up and validates a publish prefix for the user `newuser`:

1. Add the MQTT prefix `route-to-downstream/` using the **Edit User** dialog as described above.
2. Add an MQTT write permission for the topic `route-to-downstream/my-topic` (that is, including the prefix) for this user in the user management.

To confirm that the setting works as expected, send an MQTT message with an MQTT client, such as the `mosquitto_sub` and `mosquitto_pub` command-line tools. Install these tools before you continue.

3. Subscribe to the topic `route-to-downstream/my-topic` with the following command:

{% code lineNumbers="true" %}

```bash
mosquitto_sub -h 127.0.0.1 -p 1883 -u admin -P ${ADMIN_PASSWORD} \
-t 'route-to-downstream/my-topic'
```

{% endcode %}

Replace `${ADMIN_PASSWORD}` with the password of the `admin` user.

4. Publish a message to the topic `my-topic` with the following command:

{% code lineNumbers="true" %}

```bash
mosquitto_pub -h 127.0.0.1 -p 1883 -u newuser -P ${NEW_USER_PASSWORD} \
-t 'my-topic' -m 'Hello World'
```

{% endcode %}

Replace `${NEW_USER_PASSWORD}` with the password of the `newuser` user.

The subscribed client receives the published message `Hello World` on the prefixed topic `route-to-downstream/my-topic`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cybus.io/2-6-0/access/user-management/mqtt-user-authentication/adding-an-mqtt-publish-prefix.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
