---
title: "Downlink Data Message"
canonical: "https://docs.loriot.io/space/NMS/6031866/Downlink+Data+Message"
format: markdown
---
**LoRaWAN® Downlink Data Message**

<u>**Sending downlinks**</u>

LORIOT Network Management System (NMS) users can [send data down to end-devices](https://docs-loriot.atlassian.net/wiki/spaces/NMS/pages/6031666), whether it is through the NMS Web UI, API requests or a WebSocket client.

Send downlink messages using either plaintext (the Network Server will encrypt tha data using the end-device's APPSKEY) or ciphertext (the payload is already encrypted, therefore the Network Server will send it as is).

Messages will be enqueued and delivered based on target device class.

**Message format ****[Typescript interface notation](https://www.typescriptlang.org/docs/handbook/interfaces.html)**

|  |
| --- |
| ```json
{
    cmd        : 'tx';    // must always have the value 'tx'
    EUI        : string;  // device EUI, 16 hex digits (without dashes)
    port       : number;  // port to be used (1..223)
    confirmed? : boolean; // request confirmation (ACK) from end-device, default set to false
    priority?  : number;  // queue priority to be assigned to the message
                          // higher values are prioritized, default set to 0 (0 is the lowest priority)
 
    data?      : string;  // data payload (decrypted; plaintext hex string to be encrypted on Network Server)
                          // only present if APPSKEY is assigned to device
                          // if no APPSKEY is assigned to device, this will return an error
 
    encdata?   : string;  // data payload (already APPSKEY encrypted hex string)
                          // only present if APPSKEY is not assigned to device
}
``` |

**Example Message**

|  |
| --- |
| ```json
{
    "cmd"       : "tx",
    "EUI"       : "0102030405060708",
    "port"      : 1,
    "confirmed" : false,
    "priority"  : 3,
    "data"      : "0102AABB"
}
``` |

| Parameter | Type | Description |
| --- | --- | --- |
| `cmd` | string | identifies type of message, always `tx` for downlink messages |
| `EUI` | string | device EUI, 16 hex digits (without dashes) |
| `port` | number | port number (1 to 223) |
| `confirmed` | boolean (optional) | request confirmation (ACK) from end-device, default set to false |
| `priority` | number (optional) | queue priority to be assigned to the message, higher values are prioritized, default set to `0` (0 is the lowest priority) |
| `data` | string (optional) | data payload (to be encrypted on Network Server) as hexadecimal string, minimum two hex characters (equivalent of one byte); only present if APPSKEY is assigned to device |
| `encdata` | string (optional) | data payload (APPSKEY encrypted) as hexadecimal string, minimum two hex characters (equivalent of one byte); only present if APPSKEY is not assigned to device |


> ℹ️ Users should not send downlink message requests (`cmd: 'tx'`) massively to the NMS, but instead they should wait for the corresponding response for a given request (see section **Downlink enqueue acknowledgement** below for more information) before sending the next request.
> ℹ️ 
> ℹ️ If users send requests massively:
> ℹ️ 
> ℹ️ - it’s possible that they surpass the NMS incoming requests limit set for the server instance, causing that one or multiple requests are not processed and thus the associated downlink won’t be enqueued.
> ℹ️ - in the case users don’t implement a check mechanism, they may not notice if a request is responded with an error; so instead of re-sending that request, they would just continue to send the following requests instead.
> ℹ️ - sending several sequential requests without waiting for the NMS feedback does not ensure the same order for downlinks delivery to the end-device.
> ℹ️ 
> ℹ️ ![Downlink_data_message_(sending_downlinks).png](media://f84fc4db-1a16-450c-b6dd-a27a5a8ee320)


<u>**Downlink request WebSocket response**</u>

<u>When sending a downlink request through a WebSocket client</u>, a response is returned immediately after the request, indicating the success or failure of the request.

This response is always sent, even when the **Downlink enqueue acknowledgement** message is disabled for the Application (see next section for more information).

**Message format ****[Typescript interface notation](https://www.typescriptlang.org/docs/handbook/interfaces.html)**

```json
{
    cmd       : 'tx';    // always has the value 'tx'
    EUI       : string;  // device EUI, 16 hex digits (without dashes)
    priority? : number   // queue priority assigned to the message
                         // only present if the command succeeded
    data      : string;  // data that was enqueued (either plaintext or ciphertext)
    port      : number;  // port number (1 to 223)
    success?  : string;  // on success, will contain a confirmation message
                         // only present if the command succeeded
    error?    : string;  // string describing the encountered error
                         // only present if the command failed
}
```

**Example Message**

When command succeeded:

|  |
| --- |
| ```json
{
    "cmd"      : "tx",
    "EUI"      : "0102030405060708",
    "priority" : 0,
    "data"     : "0102AABB",
    "port"     : 1,
    "success"  : "Data enqueued"
}
``` |

When command failed:

|  |
| --- |
| ```json
{
    "cmd"      : "tx",
    "EUI"      : "0102030405060708",
    "data"     : "0102AABB",
    "port"     : 1,
    "error"    : "Data enqueue failed. Error: Device not registered in this application"
}
``` |

| Parameter | Type | Description |
| --- | --- | --- |
| `cmd` | string | identifies type of message, always `tx` for this type of message |
| `EUI` | string | End-Point EUI, 16 hex digits (without dashes) |
| `priority` | number (optional) | queue priority assigned to the message, only present on success |
| `data` | string | data that was enqueued |
| `port` | number | port number (1 to 223) |
| `success` | string (optional) | If command succeeded, it will contain a confirmation message. |
| `error` | string (optional) | If command failed, it will report the error description. |


<u>**Downlink enqueue acknowledgement**</u>

This message is sent to all configured Outputs in the Application after a downlink is added to the end-device downlink queue.

Starting with NMS release version v8.9.0, users can toggle the sending of the downlink enqueue acknowledgement message to the configured Outputs for the Application (the message is enabled by default).

![image-20260123-110455.png](media://21cecdaf-2c25-48e8-8125-182928dafef7)

**Message format ****[Typescript interface notation](https://www.typescriptlang.org/docs/handbook/interfaces.html)**

|  |
| --- |
| ```json
{
    cmd   : 'tx';    // always has the value 'tx'
    EUI   : string;  // device EUI, 16 hex digits (without dashes)
    seqdn : number;  // FCnt used for the downlink
    seqq  : number;  // queue sequence number
    ts    : number;  // Unix timestamp, at the moment of downlink enqueue
    port  : number;  // port number (1 to 223)
    data  : string;  // data that was enqueued (either plaintext or ciphertext)
}
``` |

**Example Messages**

When command succeeded**:**

|  |
| --- |
| ```json
{
    "cmd"      : "tx",
    "EUI"      : "0102030405060708",
    "seqdn"    : 1,
    "seqq"     : 2,
    "ts"       : 1690901930908,
    "port"     : 1,  
    "data"     : "0102AABB"
}
``` |

| Parameter | Type | Description |
| --- | --- | --- |
| `cmd` | string | identifies type of message, always `tx` for this type of message |
| `EUI` | string | device EUI, 16 hex digits (without dashes) |
| `seqdn` | number | FCnt used for the downlink |
| `seqq` | number | queue sequence number |
| `ts` | number | Unix timestamp, at the moment of downlink enqueue |
| `port` | number | port number (1 to 223) |
| `data` | string | data that was enqueued (either plaintext or ciphertext) |


<u>**Downlink Confirmation Event**</u>

The confirmation event is forwarded to the configured Outputs once a downlink message has been sent to a gateway for delivery.

Starting with NMS release version v8.9.0, users can toggle the sending of the downlink confirmation event message to the configured Outputs for the Application (the message is enabled by default).

![image-20260123-110544.png](media://055551f0-5d2e-4872-a605-725835d36f1a)

**Message format ****[Typescript interface notation](https://www.typescriptlang.org/docs/handbook/interfaces.html)**

|  |
| --- |
| ```json
{
    cmd          : 'txd';   // always has the value 'txd'
    EUI          : string;  // device EUI, 16 hex digits (without dashes)
    seqdn        : number;  // FCnt used for the downlink
    seqq         : number;  // queue sequence number
    ts           : number;  // Unix timestamp, at the moment of the transfer to gateway
    gweui        : string;  // gateway selected by the Network Server to transmit the downlink to the end-device
    freq         : number;  // frequency instructed by the NMS to the gateway for the delivery of the downlink
    sf           : number;  // spreading factor instructed by the NMS to the gateway for the delivery of the downlink
    codr         : string;  // code rate of the downlink frame, fixed at 4/5 by protocol
    toa          : number;  // time-on-air calculated by the NMS for the delivery of the downlink
    msgType      : string;  // indicates the sender of the message, either a user ("User DL") or the Network Server ("System DL")
    time         : number;  // "ts" Unix timestamp converted to human-readable date format
    ackRequested : boolean; // confirmation request (ACK) from end-device
    port         : number;  // port number (1 to 223)
    data         : number;  // data that was enqueued (either plaintext or ciphertext)
}
``` |

**Example Message**

|  |
| --- |
| ```json
{
   "cmd"          : "txd",
   "EUI"          : "0102030405060708",
   "seqdn"        : 1,
   "seqq"         : 2,
   "ts"           : 1690901930921,
   "gweui"        : "1020304050607080",
   "freq"         : 867500000,
   "sf"           : 12,
   "codr"         : "4/5",
   "toa"          : 1155,
   "msgType"      : "User DL",
   "time"         : 1690901930921,
   "ackRequested" : false,
   "port"         : 1,
   "data"         : "0102AABB"
}
``` |

| Parameter | Type | Description |
| --- | --- | --- |
| `cmd` | string | identifies type of message, always `txd` for this type of message |
| `EUI` | string | device EUI, 16 hex digits (without dashes) |
| `seqdn` | number | FCnt used for the downlink |
| `seqq` | number | queue sequence number |
| `ts` | number | Unix timestamp, at the moment of the transfer to gateway |
| `gweui` | string | gateway selected by the Network Server to transmit the downlink to the end-device |
| `freq` | number | frequency instructed by the NMS to the gateway for the delivery of the downlink |
| `sf` | number | spreading factor instructed by the NMS to the gateway for the delivery of the downlink |
| `codr` | string | code rate of the downlink frame, fixed at 4/5 by protocol |
| `toa` | number | time-on-air calculated by the NMS for the delivery of the downlink |
| `msgType` | string | indicates the sender of the message, either a user (`User DL`) or the Network Server (`System DL`) |
| `time` | number | `ts` Unix timestamp converted to human-readable date format |
| `ackRequested` | boolean | confirmation request (ACK) from end-device |
| `port` | number | port number (1 to 223) |
| `data` | string | data that was enqueued (either plaintext or ciphertext) |


If the message fails to be delivered to the gateway, a `txd` error message is returned (see the example below).

**Example Message**

|  |
| --- |
| ```json
{
      "cmd"   : "txd",
      "EUI"   : "0102030405060708",
      "data"  : "0102AABB",
      "port"  : 1,
      "seqdn" : 1,
      "seqq"  : 2,
      "ts"    : 1690901801691,
      "error" : "No APPSKEY to encrypt message for device 0102030405060708"
}
``` |

**mioty® Downlink Data Message**

<u>**Sending downlinks**</u>

LORIOT Network Management System users can [send data down to End-Points](https://docs-loriot.atlassian.net/wiki/spaces/NMS/pages/6031666), whether it is through the NMS Web UI, API requests or a WebSocket client.

Downlink messages always contain plaintext (data is encrypted in Base Stations).

Messages will be enqueued and delivered to designated End-Points.

**Message format ****[Typescript interface notation](https://www.typescriptlang.org/docs/handbook/interfaces.html)**

|  |
| --- |
| ```json
{
    cmd        : 'tx';      // must always have the value 'tx'
    EUI        : string;    // End-Point EUI, 16 hex digits (without dashes)
    protocol   : 'mioty';   // must always have the value 'mioty'
    data       : string;    // data payload in hex code (to be encrypted by Base Station)
    appid      : string;    // application Id, 8 hex digits
    confirmed? : boolean;   // request confirmation (ACK) from End-Point, default set to false
    priority?  : number;    // queue priority to be assigned to the message
                            // higher values are prioritized, default set to 0 (0 is the lowest priority)
    bsEui?     : string;    // Base Station EUI, 16 hex digits (without dashes)
}
``` |

> ℹ️ "bsEui" can be used to instruct the Service Center to send the downlink to a specific Base Station (that should be already attached to the target End-Point).
> ℹ️ 
> ℹ️ When not provided, the Service Center will choose the most suitable Base Station to send the downlink to based on the radio parameters of the target End-Point's last uplink message.


**Example Message**

|  |
| --- |
| ```json
{
    "cmd"       : "tx",
    "EUI"       : "0102030405060708",
    "protocol"  : "mioty",
    "data"      : "0102AABB",
    "appid"     : "0AA45784",
    "confirmed" : false,
    "priority"  : 2,
    "bsEui"     : "1020304050607080"
}
``` |

| Parameter | Type | Description |
| --- | --- | --- |
| `cmd` | string | identifies type of message, always `tx` for downlink messages |
| `EUI` | string | End-Point EUI, 16 hex digits (without dashes) |
| `protocol` | string | identifies the mioty® protocol, always `mioty` |
| `data` | string | data payload (to be encrypted by Base Station) as a hexadecimal string, minimum two hex characters (equivalent of one byte) |
| `appid` | string | indicates the application Id in which the End-Point is registered, 8 hex digits |
| `confirmed` | boolean (optional) | request confirmation (ACK) from end-device, default set to false |
| `priority` | number (optional) | queue priority to be assigned to the message, higher values are prioritized, default set to 0 (0 is the lowest priority) |
| `bsEui` | string (optional) | Base Station EUI, 16 hex digits (without dashes) |


> ℹ️ Users should not send downlink message requests (`cmd: 'tx'`) massively to the NMS, but instead they should wait for the corresponding response for a given request (see section **Downlink enqueue acknowledgement** below for more information) before sending the next request.
> ℹ️ 
> ℹ️ If users send requests massively:
> ℹ️ 
> ℹ️ - it’s possible that they surpass the NMS incoming requests limit set for the server instance, causing that one or multiple requests are not processed and thus the associated downlink won’t be enqueued.
> ℹ️ - in the case users don’t implement a check mechanism, they may not notice if a request is responded with an error; so instead of re-sending that request, they would just continue to send the following requests instead.
> ℹ️ - sending several sequential requests without waiting for the NMS feedback does not ensure the same order for downlinks delivery to the end-device.
> ℹ️ 
> ℹ️ ![Downlink_data_message_(sending_downlinks).png](media://f84fc4db-1a16-450c-b6dd-a27a5a8ee320)


<u>**Downlink request WebSocket response**</u>

<u>When sending a downlink request through a WebSocket client</u>, a response is returned immediately after the request, indicating the success or failure of the request.

This response is always sent, even when the **Downlink enqueue acknowledgement** message is disabled for the Application (see next section for more information).

**Message format ****[Typescript interface notation](https://www.typescriptlang.org/docs/handbook/interfaces.html)**

|  |
| --- |
| ```json
{
    cmd       : 'tx';    // always has the value 'tx'
    EUI       : string;  // End-Point EUI, 16 hex digits (without dashes)
    data?     : string;  // data that was enqueued
                         // only present if the command succeeded
    success?  : string;  // on success, will contain a confirmation message
                         // only present if the command succeeded
    error?    : string;  // string describing the encountered error
                         // only present if the command failed
}
``` |

**Example Message**

When command succeeded:

|  |
| --- |
| ```json
{
    "cmd"      : "tx",
    "EUI"      : "0102030405060708",
    "data"     : "0102AABB",
    "success"  : "Data enqueued"
}
``` |

When command failed:

|  |
| --- |
| ```json
{
    "cmd"   : "tx",
    "EUI"   : "0102030405060708",
    "error" : "Data enqueue failed: Cannot find online base stations"
}
``` |

| Parameter | Type | Description |
| --- | --- | --- |
| `cmd` | string | identifies type of message, always `tx` for this type of message |
| `EUI` | string | End-Point EUI, 16 hex digits (without dashes) |
| `data` | string (optional) | data that was enqueued, only present on success. |
| `success` | string (optional) | If command succeeded, it will contain a confirmation message. |
| `error` | string (optional) | If command failed, it will report the error description. |


<u>**Downlink enqueue acknowledgement**</u>

This message is sent to all configured Outputs in the Application once the **dlDataQue** operation is completed; this is, when the downlink has been delivered to the Base Station.

Starting with NMS release version v8.9.0, users can toggle the sending of the **Downlink enqueue acknowledgement** message for the Application (the message is disabled by default).

![image-20260903-074328.png](media://97669127-e2c7-4a02-a2cb-82ef1674fe97)

**Message format ****[Typescript interface notation](https://www.typescriptlang.org/docs/handbook/interfaces.html)**

|  |
| --- |
| ```json
{
    cmd       : 'tx';    // always has the value 'tx'
    ts        : number;  // unix timestamp, moment of the transfer to Base Station
    EUI       : string;  // End-Point EUI, 16 hex digits (without dashes)
    gweui     : string;  // Base Station EUI, 16 hex digits (without dashes)
    fcnt      : number;  // frame count used for downlink
    data      : string;  // data payload sent
    protocol  : 'mioty'  // must always have the value 'mioty'
}
``` |

**Example Message**

|  |
| --- |
| ```json
{
    "cmd"      : "tx",
    "ts"       : 1688716314950,
    "EUI"      : "0102030405060708",
    "gweui"    : "0908090809080908",
    "fcnt"     : 1,
    "data"     : "0102AABB",
    "protocol" : "mioty"
}
``` |

| Parameter | Type | Description |
| --- | --- | --- |
| `cmd` | string | identifies type of message, always `txd` for this type of message |
| `ts` | number | Unix timestamp, at the moment of the transfer to gateway |
| `EUI` | string | End-Point EUI, 16 hex digits (without dashes) |
| `gweui` | string | Base Station EUI, 16 hex digits (without dashes) |
| `fcnt` | number | frame count used for downlink |
| `data` | string | data payload sent |
| `protocol` | string | identifies the mioty® protocol, always `mioty` |


<u>**Downlink confirmation event**</u>

This message is sent to all configured Outputs once the **dlDataRes** command is received; this is, when the downlink has been transmitted by the Base Station.

Starting with NMS release version v8.9.0, users can toggle the sending of the **Downlink confirmation event** message for the Application (the message is enabled by default).

![image-20260903-085417.png](media://6e747374-9fa5-4883-8bcf-e3bfeaff126c)

**Message format ****[Typescript interface notation](https://www.typescriptlang.org/docs/handbook/interfaces.html)**

|  |
| --- |
| ```json
{
    cmd      : 'txd';   // always has the value 'txd'
    ts       : number;  // unix timestamp, moment of the transmission by Base Station
    EUI      : string;  // End-Point EUI, 16 hex digits (without dashes)
    gweui    : string;  // Base Station EUI, 16 hex digits (without dashes)
    data     : string;  // data payload sent
    fcnt     : number;  // frame count used for downlink
    protocol : 'mioty'  // must always have the value 'mioty'
}
``` |

**Example Message**

|  |
| --- |
| ```json
{
    "cmd"      : "txd",
    "ts"       : 1688716314960,
    "EUI"      : "0102030405060708",
    "gweui"    : "0908090809080908",
    "data"     : "0102AABB",
    "fcnt"     : 1,
    "protocol" : "mioty"
}
``` |

| Parameter | Type | Description |
| --- | --- | --- |
| `cmd` | string | identifies type of message, always `txd` for this type of message |
| `ts` | number | Unix timestamp, at the moment of transmission by the Base Station |
| `EUI` | string | End-Point EUI, 16 hex digits (without dashes) |
| `gweui` | string | Base Station EUI, 16 hex digits (without dashes) |
| `data` | string | data payload sent |
| `fcnt` | number | frame count used for downlink |
| `protocol` | string | identifies the mioty® protocol, always `mioty` |