> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt. For full content including API reference and SDK examples, see https://learning.postman.com/llms-full.txt.

# Creating your first MQTT request

In this example of an MQTT request, you will connect to a public broker, subscribe to topics, publish messages, and visualize the response.

## Create an MQTT request

In a Postman workspace, click <img alt="Add icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-action-add-stroke.svg#icon" width="20px" /> and select <img alt="MQTT icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-entity-mqtt-stroke.svg#icon" width="20px" /> **MQTT**.

<img alt="Create an MQTT request" src="https://assets.postman.com/postman-docs/v12/create-mqtt-request-v12-12-1.png" width="280px" />

## Connect to a broker with Postman

To connect to an MQTT service, you need a broker URL. This example uses the `broker.hivemq.com` public broker. You can also use any other public broker or a broker hosted on your local machine.

1. Enter `broker.hivemq.com` as the request **URL**.
2. Click **Connect** to connect to the broker.

A message in the response area indicates that you're connected to the broker.

<img src="https://assets.postman.com/postman-docs/v12/mqtt-connected-v12-12.png" alt="Connect to a broker" />

If you're using the Postman web app, use the Postman Desktop Agent to connect to an MQTT broker. See [About the Postman Agent](/docs/getting-started/basics/about-postman-agent/) for more information.

## Subscribe to topics

While connected to the broker, click the **Topics** tab. This enables you to create, document, and subscribe to multiple topics.

1. In the **Topics** column, enter `my-topic` as the topic name.
2. Turn on the **Subscribe** toggle.

A message appears in the response area indicating that you're subscribed to the topic.

<img src="https://assets.postman.com/postman-docs/v12/mqtt-subscribed-v12-12.png" alt="Subscribe to a topic" />

## Publish messages

You can use the **Message** tab to compose and send messages to the broker.

1. Click the **Message** tab and enter `{"age": 3, "number of toys": 5}` as the message.
2. Enter `my-topic` as the topic name.
3. Click **Send** to publish the message.

An outgoing message appears in the response area indicating that the message was published. Because you've already subscribed to the `my-topic` topic, you'll also view an incoming message with the same body. Go ahead and send a few more messages counting the number of toys you had growing up.

<img src="https://assets.postman.com/postman-docs/v12/mqtt-published-v12-12-1.png" alt="Publish messages" />

## Visualize the response

Now that you've subscribed to a topic and published a few messages, you can use the Postman Visualizer to view the messages in a more comprehensible format.

1. Switch to the **Visualization** tab in the response area. You'll notice the messages for the `age` field visualized as a line chart.
2. Click the field name dropdown list to select the field you want to visualize.
3. Click <img alt="Add icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-action-add-stroke.svg#icon" width="20px" /> **Add** to add more fields to the chart and view the changes in the values.
4. Click <img alt="Line chart icon" src="https://assets.postman.com/postman-docs/aether-icons/v12/icon-descriptive-lineChart-stroke.svg#icon" width="20px" /> **Change Visualization Type** to change the chart type.

The visualization changes in real time as you receive newer messages for the same topic.

<img src="https://assets.postman.com/postman-docs/v10/mqtt/mqtt-visualization-v10.jpg" alt="Visualization" />

## Next step

Try subscribing to multiple topics at once and publishing messages to them.