> For the complete documentation index, see [llms.txt](https://docs.eseye.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eseye.com/smartconnect/at-command-reference/mqtt-at-commands/emqpubopen-create-a-publish-message-topic.md).

# EMQPUBOPEN – create a publish message topic

Create and view publish message topics. Use these topics to publish data to things in the cloud.

The topic name depends on the MQTT parameter unless you use a token. See [Using the AnyNet SMARTconnect™ configuration file](/smartconnect/getting-started/using-the-anynet-smartconnect-tm-configuration-file.md).

You can use the following tokens to construct the topic name:

* `$t` — Returns the cloud `thingName`.
* `$i` — Returns the device International Mobile Equipment Identity (IMEI).

For example, `status/$i` publishes as `status/`.

You can only include one token in a topic.

| Type  | Syntax                              | Response                           |
| ----- | ----------------------------------- | ---------------------------------- |
| Test  | `AT+EMQPUBOPEN=?`                   | `+EMQPUBOPEN: (0-7)` and `OK`      |
| Read  | `AT+EMQPUBOPEN?`                    | A list of publish topics and `OK`  |
| Write | `AT+EMQPUBOPEN=(0-7),"/[$t \| $i]"` | Creates or updates a publish topic |

The Read command returns topics in this format:

```
0: /<[mqtt] topicsuffix>
1: /<[mqtt] topicsuffix>
OK
```

The returned topic list includes:

* An index number, starting at `0`.
* The unique publish topic name for the index.
* The appended `topicsuffix` path.

`topicsuffix` can include `$i` for the IMEI or `$t` for the cloud `thingName`. The maximum `$t` length is `128` characters for AWS and `255` characters for Google. The complete topic must not exceed the MQTT broker limit of `256` characters. The Quectel module does not return empty topics.

For the Write command:

* Set the publish index from `0` through `7`.
* Set a publish topic title up to `256` characters, including `/cloudThingName` or `/IMEI`.
* Do not use special characters in a topic title.
* Optionally include `$t` or `$i`.

#### Examples

Create a topic with the IMEI token:

```
AT+EMQPUBOPEN=0,"PublishToCloud0/$i"
OK
+EMQPUBOPEN: 0,0
```

Create a topic without a token:

```
AT+EMQPUBOPEN=1,"PublishToCloud1"
OK
+EMQPUBOPEN: 1,0
```

List publish topics:

```
AT+EMQPUBOPEN?
0: PublishToCloud0/862061040777777
1: PublishToCloud1/AWSthingName
OK
```

Publish a JSON message:

```
AT+EMQPUBLISH=0,1,"{"imei":"$i","user":"1","sys":"128","dia":"112","pul":"075","ano":"0","time":"2023/11/30,20:10:12-20","ver":"BP01\_2.0","devdata":{"r":$r,"rat":"$a","mcc":$c,"mnc":$n,"imsi":$s,"batt":87\}}"
OK
:SEND OK
```

In the last example, the MQTT broker receives:

```json
{
  "imei": "867730056224474",
  "user": "1",
  "sys": "128",
  "dia": "112",
  "pul": "075",
  "ano": "0",
  "time": "2023/11/30,20:10:12-20",
  "ver": "BP01_2.0",
  "devdata": {
    "r": -68,
    "rat": "eMTC",
    "mcc": 310,
    "mnc": 230,
    "imsi": 302760007540320,
    "batt": 87
  }
}
```

For useful AWS information regarding maximum lengths, see: AWS IoT Core endpoints and quotas.


---

# 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.eseye.com/smartconnect/at-command-reference/mqtt-at-commands/emqpubopen-create-a-publish-message-topic.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.
