# mqtt\_ticket

Source: https://zotonic.com/docs/2181/mqtt_ticket

URI: https://zotonic.com/id/2181

Language: en



A ticketing system for out of band MQTT posts via HTTP.

The controller <a href="/id/doc_controller_controller_mqtt_transport" class="doc-reference doc-reference-controller"><code>controller#controller_mqtt_transport</code></a> can accept HTTP posts. These posts MUST include a ticket and a topic for the payload to be sent.

The ticket is obtained via `model/mqtt_ticket/post/new`. This can only be accessed via MQTT, as the routines will check for a valid `client_id`.

If a ticket is created then the current request context is saved for max 30 seconds. If a request comes in then the ticket is used to fetch the stored context and the following information is copied over from the stored context to the HTTP request context:

- MQTT client-id
- MQTT client-topic
- MQTT routing-id
- ACL user id
- ACL auth\_options
- ACL read-only flag
- Timezone
- Language

A ticket can only be used once.

Available Model API Paths
-------------------------

| Method   | Path pattern | Description                                                                      |
| -------- | ------------ | -------------------------------------------------------------------------------- |
| `post`   | `/new`       | Create a one-time MQTT transport ticket for the current MQTT client context and return the generated ticket id (binary). No further lookups. |
| `delete` | `/+ticket`   | Invalidate/delete ticket `+ticket` and its stored context so it can no longer be exchanged. No further lookups. |

`/+name` marks a variable path segment. A trailing `/...` means extra path segments are accepted for further lookups.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2181?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2181?language=en>)
