# Messages

## Send text to a device

> Send text or raw data over UDP or TCP to a device with a specific SIM ID.\
> \
> If the protocol is UDP, the packet will be sent to the receiving port. If the protocol is TCP, a connection will be established with the device on that port and the data will be sent. If the device does not accept incoming connections on that port, the data will be discarded.\
> \
> Either \`text\` or \`data\` must be provided, but not both. Use \`text\` for string data and \`data\` for base64-encoded binary data that will be decoded and sent as raw bytes.

```json
{"openapi":"3.0.0","info":{"title":"Onomondo's API","version":"1.0.0"},"servers":[{"url":"https://api.onomondo.com"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"apiKey","in":"header","name":"Authorization"}}},"paths":{"/messages/{sim_id}":{"post":{"summary":"Send text to a device","description":"Send text or raw data over UDP or TCP to a device with a specific SIM ID.\n\nIf the protocol is UDP, the packet will be sent to the receiving port. If the protocol is TCP, a connection will be established with the device on that port and the data will be sent. If the device does not accept incoming connections on that port, the data will be discarded.\n\nEither `text` or `data` must be provided, but not both. Use `text` for string data and `data` for base64-encoded binary data that will be decoded and sent as raw bytes.","parameters":[{"name":"sim_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["protocol","port"],"properties":{"protocol":{"type":"string","enum":["udp","tcp"],"description":"The protocol to use for sending the message"},"port":{"type":"integer","minimum":1,"maximum":65535,"description":"The target port number"},"text":{"type":"string","description":"String data to send (mutually exclusive with data)"},"data":{"type":"string","format":"byte","description":"Base64-encoded binary data to send (mutually exclusive with text)"}},"oneOf":[{"required":["text"],"not":{"required":["data"]}},{"required":["data"],"not":{"required":["text"]}}]}}}},"responses":{"200":{"description":"Message sent successfully","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"}}}}}},"400":{"description":"Bad request, invalid parameters or device offline","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}}}}}}
```


---

# 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.onomondo.com/readme/messages.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.
