APIs Device to Cloud Send and receive IoT data

Before you continue, please consult the operating instructions/ user manual of your LwM2M-device.

Please get familiar with:

  • Which LwM2M-Objects does your LwM2M-Device support?
  • Which LwM2M-Ressources are could you READ, which LwM2M-Resources could you WRITE?
  • What’s the main use-case of the device?
    • Do you have a battery powered device? What’s the battery lifetime of your device? What’s your expected battery life time? What does your hardware vendor recommend?
    • What’s triggering your main use-case? Do you need some values only in a special case? Do you need the data of your main-use case in some fixed time intervall or if something happens on the device (condition)?

We suggest to execute a READ on all Objects that you find in the operating instructions/ user manual of your device.

Send message to IoT device

Messages sent to the outgoing-msg container will be forwarded to the device. The con field contains the information sent to the device.

This example requests LwM2M-Object 3 (Device):

  • Request
  • Response
POST {{API_URL}}/device-management-orchestrator/v3/{{TENANT}}/device-communication/<deviceID>/outgoing-msg HTTP/2
Accept: application/json
Content-Type: application/json;ty=4
X-M2M-Origin: CTestApp
X-M2M-RI: 123
Authorization: Bearer {{ACCESS_TOKEN}}

{
  "m2m:cin": {
    "con": "GET /3\n"
  }
}
{
  "contentInstance": {
    "content": "GET /3\n",
    "resourceType": 4,
    "contentSize": 7,
    "stateTag": 10,
    "creator": "CTestApp",
    "resourceName": "f4587503-9545-4430-adb4-3055076633de",
    "resourceID": "6879032d3c8c87cdb4009999",
    "parentID": "68767201272211da007e5999",
    "creationTime": "20250717T140533,829000",
    "lastModifiedTime": "20250717T140533,829000"
  }
}

After processing the request, the message is transferred to the /device-communication/<deviceID>/sent-msg container.

You can read the last message (/la) sent to device using:

  • Request
  • Response
GET {{API_URL}}/device-management-orchestrator/v3/{{TENANT}}/device-communication/<deviceID>/sent-msg/la
Accept: application/json
Content-Type: application/json
X-M2M-Origin: CTestApp
X-M2M-RI: 123
Authorization: Bearer {{ACCESS_TOKEN}}
{
  "contentInstance": {
    "content": "GET /3\n",
    "resourceType": 4,
    "contentSize": 7,
    "stateTag": 7,
    "creator": "CTestApp",
    "resourceName": "efd62c6f-050f-436f-aef4-55499ec4d01d",
    "resourceID": "6879032e50fa7af1af3e4999",
    "parentID": "68767201272211da007e5999",
    "creationTime": "20250717T140534,016000",
    "lastModifiedTime": "20250717T140534,016000"
  }
}

LwM2M operation mappings

To interact with LwM2M devices, the content (con) of the outgoing-msg is similar to COAP or HTTP protocol:

LwM2M Operation“con” StructureSupported
READ resource
GET /<obj>/<inst>/<res> 
WRITE resource value
PUT /<obj>/<inst>/<res>
<type>: <value>
WRITE instance
PUT /<obj>/<inst>/<res> 
<JSON>
WRITE object
PUT /<obj> 
<JSON>
1
EXECUTE resource
POST /<obj>/<inst>/<res>
EXECUTE with parameter
POST /<obj>/<inst>/<res>?
<type>: <value>
1
OBSERVE
PUT /22 
<JSON>
1
CANCEL OBSERVE
DELETE /22
1

Note: (1) are planned operations

Get last received device messages via API

The following query gets the last message sent to the received msg container:

  • Request
  • Response
GET {{API_URL}}/device-management-orchestrator/v3/{{TENANT}}/device-communication/<deviceID>/received-msg/la
Accept: application/json
Content-Type: application/json
X-M2M-Origin: CTestApp
X-M2M-RI: 123
Authorization: Bearer {{ACCESS_TOKEN}}
{
  "contentInstance": {
    "content": {
      "nodeResourceName": "device001",
      "time": 1752761134124,
      "messageType": "response",
      "resourcePath": "3",
      "dataValue": {
        "3/0/0": "My Demo Device",
        "3/0/1": "Model 500",
        "3/0/2": "LT-500-000-0001",
        "3/0/3": "1.0.0",
        "3/0/9": 72,
        "3/0/10": 75108,
        "3/0/11/0":0,
        "3/0/13": 1752761133000,
        "3/0/14": "+02",
        "3/0/15": "Europe/Berlin",
        "3/0/16": "U",
        "3/0/17": "Demo",
        "3/0/18": "1.0.1",
        "3/0/19": "1.0.2", 
        "3/0/20": 3,
        "3/0/21": 129024
        }
    },
    "contentInfo": "application/json:0",
    "resourceType": 4,
    "contentSize": 464,
    "stateTag": 12,
    "creator": "CDevice-Provisioning",
    "resourceName": "aabefd77-2166-4710-8e22-cce1c8d76312",
    "resourceID": "6879032f50fa7af1af3e4999",
    "parentID": "68767201272211da007e5999",
    "creationTime": "20250717T140535,167000",
    "lastModifiedTime": "20250717T140535,167000"
  }
}

LwM2M resource mappings

Device to Cloud automatically reads LwM2M Objects 3 and 6 (LwM2M-READ) when an LwM2M-Device connects with an LwM2M-Register.

The Device to Cloud reads the following LwM2M resources when a LwM2M Client makes a LwM2M Register request. This process involves transitioning from LwM2M to oneM2M.

LwM2M resourceLwM2M resource nameoneM2M management objectoneM2M management object fieldremark
endpoint nameendpoint namem2m:dvi (DeviceInfo)dlb (deviceLabel)
/3/0/0Manufacturerm2m:dvi (DeviceInfo)dvnm (deviceName)
/3/0/3Firmware Versionm2m:dvi (DeviceInfo)fwv (firmwareVersion)
/3/0/13Current Timem2m:dvi (DeviceInfo)syst (systemTime)
/6/0/0Latitudem2m:dvi (DeviceInfo)loc (Location)
/6/0/1Longitudem2m:dvi (DeviceInfo)loc (Location)

*¹ Reliability of Information depends on Device Firmware, see also Object 5 “Firmware Update” , Object 9 Software Management , and chapter “E.6 LwM2M Object: Firmware Update” in LwM2M Specification .

*² format: geo:<latitude>,<longitude> (see RFC5870 )

To get this data from a node, use a http request like this:

  • Request
  • Response
GET {{API_URL}}/device-management-orchestrator/v3/{{tenant_name}}/device001?ty=13&rcn=8 HTTP/2
Accept: application/json
Content-Type: application/json
X-M2M-Origin: CAdmin
X-M2M-RI: 123
Authorization: Bearer {{ACCESS_TOKEN}}
{
  "node": {
    "credentials": [
      {
        "description": "cred",
        "mgmtDefinition": 1029,
        "resourceName": "credentials",
        "resourceType": 13,
        "resourceID": "680b85bb8482fd7b93dc2999",
        "parentID": "680b85bb8482fd7b93dc2999",
        "creationTime": "20250425T125315,719000",
        "lastModifiedTime": "20250425T125315,719000",
        "credentialID": "test@test.com",
        "credentialSecret": "test123"
      }
    ],
    "deviceInfo": [
      {
        "resourceName": "device-info",
        "mgmtDefinition": 1007,
        "deviceLabel": "device001",
        "resourceType": 13,
        "resourceID": "680b85bb8482fd7b93dc2999",
        "parentID": "680b85bb8482fd7b93dc2999",
        "creationTime": "20250425T125315,860000",
        "lastModifiedTime": "20250428T090849,562000",
        "deviceName": "My Demo Device",
        "fwVersion": "1.0.0",
        "systemTime": "1752761133000"
      }
    ]
  }
}

Parameters:

  • ty=13 to receive the oneM2M management object of the node
  • rcn=8 to retrieve all details of all resources directly under the specified path

LwM2M defines following interfaces in the LwM2M Client Registration Interface (see chapter 6.2. Client Registration Interface on page 38):

  • LwM2M-Register
  • LwM2M-Update
  • LwM2M-De-Register

When a device makes an LwM2M-Register, LwM2M-Update or LwM2M-De-Register, Device to Cloud stores the server time in a oneM2M label in oneM2M device node. In addition to that, Device to Cloud stores the server time, when an LwM2M Client exceeds the LwM2M Lifetime as expiration timestamp.

LwM2M Operationlabel nameformat
LwM2M-Registerregistrations_timestampseconds since first January 1970 UTC
LwM2M-De-Registerderegistrations_timestampseconds since first January 1970 UTC
LwM2M-Updateupdates_timestampseconds since first January 1970 UTC
Client Expiresexpirations_timestampseconds since first January 1970 UTC

To see these labels call:

  • Request
  • Response
GET  {{API_URL}}/device-management-orchestrator/v3/{{tenant_name}}/device001 HTTP/2
Accept: application/json
Content-Type: application/json
fullName: {{fullname}}
X-M2M-Origin: CDevice-Provisioning
X-M2M-RI: 123
Authorization: Bearer {{ACCESS_TOKEN}}
{
  "node": {
    "nodeID": "urn:gsma:imei:3519345467882060",
    "labels": [
      "UplinkProperty_Address:Kuckhoff street",
      "UplinkProperty_Room:2035",
      "profile:SCS-lwM2M",
      "ICCID:89882280000004492060",
      "updates_timestamp: 1738537906296",
      "registrations_timestamp: 1733389745807"
    ],
    "resourceName": "device001",
    "resourceType": 14,
    "resourceID": "680b85bb8482fd7b93dc2999",
    "parentID": "d2c-dev-1",
    "creationTime": "20250425T125315,410000",
    "lastModifiedTime": "20250428T084509,703000"
  }
}

Next: Forward messages to applications

In the next step, you learn how to integrate your application and use device groups to configure the data routing to your application endpoint.