API POST /api/devices/{device_keys.dev_eui}/keys

I found when creating the device keys for a specific device which uses OTAA and I use the “appKey” parameter in the body of the API, it gives me following output:

{
    "error": "lorawan: exactly 16 bytes are expected",
    "code": 3,
    "message": "lorawan: exactly 16 bytes are expected",
    "details": []
}

The “appKey” is: 2a0773da7ec38065bec455ca1c800872 (it was generated in the Chirpstack App UI).
But, when I’m using the “nwkKey” as the application key, the key is added to the device perfectly.
Is this intended, because refering to the LoRaWAN specs “nwkKey” has nothing to do with the “appKey”…
I am really confused about that :- :neutral_face:

That is intended. If you look at the Swagger model (or protobuf file comments, etc), you will see:

nwkKey (string, optional):

Network root key (HEX encoded). Note: For LoRaWAN 1.0.x, use this field for the LoRaWAN 1.0.x 'AppKey`! 
2 Likes

Ok. Thank you very much for the explanation :slight_smile:

I agree it is confusing, though. That endpoint is trying to shoehorn different values from both LoRaWAN 1.0 and 1.1 into the same set of fields.