# Protocol Specification

You can check below a chart with the different steps that an IoT device must follow to send data to the broker:

![](/files/B6PQ2Wa9oUeaByP62ZaW)

### Steps

1. The client first verifies if it already has credentials to access (*device\_key* and *password*).
   1. In case the client does not have any *device\_key* associated, you need to first set up one and link it to device. Please, go to  [Identity Handling](/infrastructure/identities/identity-handling.md#identity-creation) first.
   2. If the client already has an identity linked to it, it is time to request a password to the broker. Please. go to step 2 in the first level of the hierarchy of this numbered list.&#x20;
2. The client now needs to verify if it has a password available for connection.
   1. If no password is ready, follow these steps:
      1. Connect to broker at <broker.airtrace.io:1883> (no authentication required).
      2. Subscribe to \<admin/provider/*device\_key*> topic.
      3. Send *device\_key to* \<admin/provider> topic.
   2. If a password was already collected, got to step 3 in the first level of the hierarchy of this numbered list.
3. Before sending data to the broker, the client will authenticate using *device\_key* and *password* to <broker.airtrace.io:1884>.
   1. If connection is not possible, go again to step 2 in the first level of the hierarchy of this numbered list.
   2. If connection is ok, the client must continue to step 4.
4. Once the client has connected, the client will start sending data to \</admin/data/*device\_key*> in a continuous fashion.
   1. If there is a problem in the communication, the client can retry as many times as desired (5 times recommended). In case of recurrent connection failure, the client can:
      1. Go to to Step 2 in the first level of the hierarchy of this numbered list and retrieve a new password.
      2. Stop communicating data, and enter *standby* state.
   2. If the client decides to stop sending, communication to the broker will be closed.

{% hint style="info" %}
Current version of the protocol does not include SSL (Secure Socket Layer) encryption. It will be supported in short.
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://docs.airtrace.io/data-sending/clients/mqtt/protocol-specification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
