mailbox.send
The mailbox.send command enables you to send a command to a thing in the platform.
The most common use case is sending commands to things by addressing the thingKey of the device. Alternatively, you can send commands directly to a session (that represents a specific connection from an application/user to the portal). This is typically used for asynchronous exchanges where an application sends a command to a device, and the device needs to respond with multiple responses.
TR50 Request
// Send a command to a thing
{
"cmd": {
"command": "mailbox.send",
"params": {
"thingKey": "52ebe698f2057f19980001e1",
"command": "COMMAND",
"params": {
...
},
"singleton": false,
"ackTimeout": 30
}
}
}
// Send a command to a session
{
"cmd": {
"command": "mailbox.send",
"params": {
"sessionId": "52ebe698f2057f19980001e1",
"command": "COMMAND",
"params": {
...
},
"singleton": false,
"ackTimeout": 30
}
}
}
Request Parameters
Name |
Type |
Required |
Description |
---|---|---|---|
thingKey |
String |
|
The thing that should execute the command. |
command |
String |
Yes |
The command to execute. |
params |
Object |
|
The parameters for the command. |
ackTimeout |
Integer |
|
Specifies how long the sender is willing to wait for a reply from the receiving client. |
ttl |
Integer |
|
Specifies the lifetime of the message. If the value is -1 the message is held until it is delivered to the client. |
singleton |
Boolean |
|
Ensures that if multiple mailbox messages are sent with the same command and singleton is true, only one of the commands is executed. |
sessionId |
String |
|
The unique ID of the established session. |
TR50 Response
If the command is sent successfully a success message and the command results are returned. Otherwise, an error and error message will be returned.
{
"cmd": {
"success": true,
"params": {
"key1": "value string",
"key2": false,
"key3": 42
}
}
}
Response Parameters
An object of results. Actual object structure will vary according to the command executed.