"HTTP code 204" but code apparently not created

Hello,

Our solution sends requests to generate codes on smartlocks. It usually works correctly, but this month, a customer of ours (who pays a Nuki subscription) got two issues with his smartlocks (these specific smartlocks work usually).
We sent: PUT https://api.nuki.io/smartlock/{smartlockId}/auth, for instance at these datetimes:
2024-09-01 20:13:21 UTC
2024-09-02 21:03:23 UTC

In return, we received from Nuki a success HTTP code 204, but our customer could not find the codes, so he had to create them on Nuki’s user interface.

Do you know what happened as these codes seemed created with the requests but were apparently not?

Thank you,

Hello,

If you are not using webhooks:

The Nuki Web API is asynchronous. When you send a command, you will get an immediate OK response (i.e. 200, or in this case 204) which means that the request has succeeded, but that doesn’t guarantee that the client has executed the request successfully. Once the server has received the API call, it will try to reach the Smart Lock and create the code (all the codes are stored on the Smart Lock itself). This usually takes some seconds, and the device should be online.

Thus, call the GET /smartlock/auth endpoint within a few minutes to validate if the auth was created successfully.

The auths may not be created successfully if the devices were not online during this time.

If you are using webhooks:

A webhook is triggered when an authorization is created (also when it is modified or deleted).

Example webhook response:

AuthResponse {
“feature”: “DEVICE_AUTHS”,
“deleted”: false,
“smartlockAuth”: {
“id”: “65219648fe57075d71a6cb01”,
“smartlockId”: 11000009999,
“authId”: 1,
“code”: 982345,
“type”: 13,
“name”: “example”,

}
}

Thus, the best practice is to use webhooks to validate if auths are created successfully.