---
title: "SendDeviceMessage"
method: POST
path: "/devices/{deviceId}/messages"
tags: ["Messages"]
---

# SendDeviceMessage

`POST /devices/{deviceId}/messages`

Allows a user or [IP device](https://docs.nordicsemi.com/bundle/nrf-cloud/page/Devices/Properties/Types.html) to
send a message that is subsequently published over an MQTT topic, on behalf of the
IP device whose deviceId is specified. The device ID for the message comes from the topic. For instance,
if the topic property on the request is `m/d/nrf-352656101081837/d2c/custom`, the device ID determined
for the message will be `'nrf-352656101081837'`.

For [dictionary based binary logs](https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/logging/index.html#dictionary-based_logging) via the `d2c/bin` topic, the message must be base64 encoded.
For instance, for the device  `nrf-352656101081837` the request body would be:
```json
{
  "topic": "d/nrf-352656101081837/d2c/bin",
  "message": "blJGQwAAAAAd2qCkkAEAAAEAAABoZWxsbyB3b3JsZA=="
}
```

For more information, see
[Sending device messages](https://docs.nordicsemi.com/bundle/nrf-cloud/page/Devices/MessagesAndAlerts/DeviceMessages.html#sending-device-messages).

## Path parameters

- `deviceId` string, required — This is the canonical device id used in the device certificate, and as the MQTT client id.

## Request body

- DeviceMessageInput — Device message input
  - `topic` string — A string specifying an MQTT topic.
  - `message` union, required
    - Message — A JSON object containing a device message that conforms to the device-to-cloud application protocol defined [here](https://github.com/nRFCloud/application-protocols/tree/v1/schemas/deviceToCloud).
    - Message[]
    - string — Binary data encoded as a base64 string. This is intended for binary dictionary based logging data. For more info [see here](https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/logging/index.html#dictionary-based_logging).

## Response `202`

---

[API](https://skmtc.dev/nrfcloud/apis/nrf-cloud-rest-api.md) · [All operations](https://skmtc.dev/nrfcloud/apis/nrf-cloud-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/nrfcloud/nrf-cloud-rest-api/revisions/c4e56e458ebf/schema)
