Create device
Registers a LoRaWAN device on the server. An OTAA device then joins the network by itself using its DevEUI and AppKey. An ABP device does not join, but the server must know its DevAddr and session keys in advance — they are passed in the request.
Request and response: create_device_req → create_device_resp.
Access: high access level token only; a device can be created in any application of the owner. With a low access level token the server responds with error 1.
application_euiis not required: without it the device is created in the application you are connected to.adr_fixis a DR number ornull, not a bool;seq_chkis a number, 0 or 1.- There are 38 region codes (0–37), not 24 — see Region codes.
- In the response
down_queuerepeats the request value rather than the stored one, and there is an extraactivefield.
Request
Fields not marked as required may be omitted.
| Field | Type | Description |
|---|---|---|
cmd | string | create_device_req |
operation_id | string | Any string; the server returns it in the response to match the request and the response |
devEui | string | Required. Device DevEUI, 16 hex characters. Case does not matter; the server strips spaces, : and -. Must be unique across the whole server |
app_key | string | Required. AppKey, 32 hex characters. For OTAA it is the device root key: the server checks join requests with it. For ABP the server does not use it, but the field is still required |
tariff_code | string | Required. Tariff code from get_tariffs_req |
application_eui | string | AppEUI of the application to create the device in, 16 hex characters. Default — the application you are connected to |
activation | uint8 | Activation method: 0 — OTAA, 1 — ABP. Default 0 |
devAddr | string | DevAddr, 8 hex characters. For ABP pass the address from the device firmware. For OTAA the field is not needed: without it the server assigns a free address, and it assigns a new one on every join anyway |
nwks_key | string | NwkSKey, 32 hex characters. For ABP pass the key from the firmware. Without the field the server generates a random key |
apps_key | string | AppSKey, 32 hex characters. For ABP pass the key from the firmware. Without the field the server generates a random key |
region | uint8 | Region code — the device frequency plan, 0–37, see Region codes. Default 6 (KZ865-868) |
node_class | uint8 | LoRaWAN class: 1 — A, 2 — B, 3 — C. Default 1. See Device classes |
rx_window | uint8 | Receive window for downlink: 1 — RX1, or RX2 if the server cannot make it to RX1; 2 — always RX2. Default 1 |
adr | bool | ADR: the server chooses the device data rate and transmit power. Works only if ADR is enabled in the device too. Default true |
adr_interval | uint16 | How often the server recalculates the data rate, in uplink frames; 0 — never. Default 20 |
adr_min | uint8 | Lowest DR that ADR may lower the data rate to, 0–15. Default 0 |
adr_max | uint8 | Highest DR for ADR, 0–15. Default 5. See "Good to know" |
adr_fix | uint8 | Fixed DR, 0–15: ADR keeps this data rate and the highest power. Default null — not set |
seq_up | uint32 | Initial uplink frame counter (FCntUp). Default 0. Useful for an ABP device moved from another server; after that the server maintains the counters |
seq_down | uint32 | Initial downlink frame counter (FCntDown). Default 0 |
seq_chk | uint8 | Frame counter check: 0 — Strict, 1 — Relaxed. Default 0. The server currently only stores the value |
duty_cycle | uint8 | Default 0. The server currently only stores the value |
down_queue | uint8 | Default 0. The server currently only stores the value |
description | string | Description, up to 255 characters. Default — empty string |
lat | float | Latitude, WGS 84. Applied only together with lon |
lon | float | Longitude, WGS 84. Applied only together with lat |
An OTAA device in a given application:
{
"cmd": "create_device_req",
"operation_id": "rnt",
"devEui": "7DA50BE8C74CE6DC",
"application_eui": "819EA8554FCD762A",
"app_key": "948205A2939E8C999D641DE5CB731861",
"tariff_code": "A1"
}
A class C ABP device — address and session keys from the firmware:
{
"cmd": "create_device_req",
"operation_id": "abp1",
"devEui": "7DA50BE8C74CE6DD",
"app_key": "948205A2939E8C999D641DE5CB731861",
"tariff_code": "A1",
"activation": 1,
"devAddr": "26011F4A",
"nwks_key": "EEFBF983C00B35240C9A7C2D8D011301",
"apps_key": "6F17B97CEA2C63D1089EF4268FD68D38",
"node_class": 3,
"region": 7
}
Response
| Field | Type | Description |
|---|---|---|
cmd | string | create_device_resp |
operation_id | string | Value from the request |
status | uint8 | 1 — the device is created, 2 — error |
devEui, devAddr, application_eui | string | Identifiers of the created device, hex in upper case. devAddr — the one passed or assigned by the server |
app_key, nwks_key, apps_key | string | Device keys, including the ones generated by the server |
description, node_class, rx_window, adr, adr_interval, adr_min, adr_max, adr_fix, duty_cycle, seq_up, seq_down, seq_chk, region, activation, tariff_code | Stored values: from the request or defaults. Types as in the request | |
down_queue | uint8 | Value from the request; null if the field was not passed |
active | bool | Repeats the request field of the same name, usually null. Does not affect creation |
lat, lon | float | Coordinates; null if not set |
error_code, error_text | uint8, string | Only on error, see below |
Response to the first request example:
{
"cmd": "create_device_resp",
"operation_id": "rnt",
"status": 1,
"devEui": "7DA50BE8C74CE6DC",
"devAddr": "41410509",
"application_eui": "819EA8554FCD762A",
"description": "",
"app_key": "948205A2939E8C999D641DE5CB731861",
"nwks_key": "A3C51F0E9D27B4686F02E1CB5D7390AA",
"apps_key": "1B9E04D7C26A58F3E0B4719DA2C86E5F",
"node_class": 1,
"rx_window": 1,
"adr": true,
"adr_interval": 20,
"adr_min": 0,
"adr_max": 5,
"adr_fix": null,
"duty_cycle": 0,
"seq_up": 0,
"seq_down": 0,
"seq_chk": 0,
"region": 6,
"activation": 0,
"down_queue": null,
"tariff_code": "A1",
"active": null,
"lon": null,
"lat": null
}
Errors
error_code | error_text | What happened |
|---|---|---|
| 1 | Unauthorized access | The request came with a low access level token |
| 2 | Required field is not filled | devEui, app_key or tariff_code is missing, or application_eui is empty |
| 3 | Data is filled in with an error | devEui, application_eui, devAddr or a key has an invalid format; lat or lon is not a number; node_class is not 1–3; region is not 0–37 |
| 4 | Uniq failed | A device with this DevEUI or DevAddr already exists on the server — under any owner |
| 5 | Application does not exists | The owner has no application with this application_eui, or it is deleted |
| 6 | Tariff does not exists | There is no active tariff with the code tariff_code |
| 0 | Unexpected error | The database rejected a value — e.g. rx_window above 2, a negative frame counter, a description longer than 255 characters — or an internal server error occurred |
Region codes
The code sets the device frequency plan: channels, the RX2 window, allowed data rates and the downlink frame size. For details, see Frequency plans. For US915 and AU915, the table gives the numbers of the enabled channels as defined in the LoRaWAN Regional Parameters specification.
| Code | Region | Uplink channels, MHz | RX2 |
|---|---|---|---|
| 0 | EU | 868.1, 868.3, 868.5 | 869.525 MHz, DR0 |
| 1 | KZ_OLD | 864.5–865.3, 5 channels | 865.6 MHz, DR0 |
| 2 | RU | 868.9, 869.1 and 864.1–864.9, 7 channels | 869.1 MHz, DR0 |
| 3 | BY | 868.1, 868.3, 868.5 | 869.525 MHz, DR0 |
| 4 | UA | 868.1, 868.3, 868.5 | 869.525 MHz, DR0 |
| 5 | KG863-865 | 863.7–864.5, 5 channels | 869.1 MHz, DR0 |
| 6 | KZ865-868 — default | 865.1–865.9, 5 channels | 866.7 MHz, DR0 |
| 7 | EU863-870 | 867.1–867.9 and 868.1–868.5, 8 channels | 869.525 MHz, DR0 |
| 8 | KZ864-868 | 864.5–865.9, 8 channels | 866.7 MHz, DR0 |
| 9 | EU433 | 433.175–434.775, 9 channels | 434.665 MHz, DR0 |
| 10 | AS923-1 | 923.2–924.6, 8 channels — in the current version the server sends neither a Join Accept nor a downlink to a device or multicast group with this code; use code 11 or 13 | 923.2 MHz, DR2 |
| 11 | AS923-2 | 923.2–924.6, 8 channels — same as AS923-1 in the current server version | 923.2 MHz, DR2 |
| 12 | AS923-3 | 916.0–917.4, 8 channels | 916.6 MHz, DR2 |
| 13 | AS923-4 | 923.2–924.6, 8 channels — same as AS923-1 in the current server version | 923.2 MHz, DR2 |
| 14 | KR920 | 923.2–924.6, 8 channels — same as AS923-1 in the current server version | 923.2 MHz, DR2 |
| 15 | US915-1 | channels 0–7 and 64 | 923.3 MHz, DR8 |
| 16 | US915-2 | channels 8–15 and 65 | 923.3 MHz, DR8 |
| 17 | US915-3 | channels 16–23 and 66 | 923.3 MHz, DR8 |
| 18 | US915-4 | channels 24–31 and 67 | 923.3 MHz, DR8 |
| 19 | US915-5 | channels 32–39 and 68 | 923.3 MHz, DR8 |
| 20 | US915-6 | channels 40–47 and 69 | 923.3 MHz, DR8 |
| 21 | US915-7 | channels 48–55 and 70 | 923.3 MHz, DR8 |
| 22 | US915-8 | channels 0–7, 56–63 and 71 | 923.3 MHz, DR8 |
| 23 | US915-9 | channels 0–15, 64 and 65 | 923.3 MHz, DR8 |
| 24 | AU915-1 | channels 0–7 and 64 | 923.3 MHz, DR8 |
| 25 | AU915-2 | channels 8–15 and 65 | 923.3 MHz, DR8 |
| 26 | AU915-3 | channels 16–23 and 66 | 923.3 MHz, DR8 |
| 27 | AU915-4 | channels 24–31 and 67 | 923.3 MHz, DR8 |
| 28 | AU915-5 | channels 32–39 and 68 | 923.3 MHz, DR8 |
| 29 | AU915-6 | channels 40–47 and 69 | 923.3 MHz, DR8 |
| 30 | AU915-7 | channels 48–55 and 70 | 923.3 MHz, DR8 |
| 31 | AU915-8 | channels 56–63 and 71 | 923.3 MHz, DR8 |
| 32 | AU915-9 | channels 0–15, 64 and 65 | 923.3 MHz, DR8 |
| 33 | UZ926 | 926.4–927.8, 8 channels | 926.2 MHz, DR2 |
| 34 | UZ927 | 926.4–927.8, 8 channels | 927.8 MHz, DR2 |
| 35 | KZ865-only | 865.1, 865.3, 865.5 | 866.7 MHz, DR0 |
| 36 | IN865-867 | 865.0625, 865.4025, 865.985 | 866.55 MHz, DR2 |
| 37 | IN865+KZ865 | 865.0625, 865.4025, 865.985 and 865.1–865.9, 8 channels | 866.55 MHz, DR2 |
Good to know
- OTAA. On every join the server assigns the device a new DevAddr and new session keys and writes them into the device record. So the
devAddr,nwks_keyandapps_keyfrom the creation response are valid only until the first join. - ABP. The server does not check that
devAddr,nwks_keyandapps_keyare passed for ABP: without them it generates random values and cannot process the device uplinks. Pass all three fields from the firmware. - DevEUI is unique across the whole server, not only within the application. A deleted device does not occupy its DevEUI and DevAddr.
- The device was powered on before it was registered. If it has already tried to join, the server temporarily blocks its join requests. Creating the device lifts the block, and the next join attempt goes through.
- Not all fields are validated. The server validates
node_classandregionitself. It does not validaterx_window,adr_*,seq_*,duty_cycleanddown_queue: an invalid value is either stored as is or rejected by the database with error 0. adr_maxcurrently does not limit ADR when it is below the highest DR of the frequency plan: the server takes it into account only when it is above that DR. To limit the data rate, setadr_fix.
See also
get_tariffs_req— tariff codes fortariff_code.update_device_req— change device settings.get_devices_req— device record.