Web API Example: Create a key for your Nuki Smart Lock

Hello, for my app I need to get the key via web-api for further use via bluetooth api. The question is - how can I get a shared key through web api?

Hello @MatthiasK,

I try to understand your example a bit more. (I dont have currently http bridge but not sure if I buy it whether my scenario be possible). Considering I generated “key” for the user - how I can share it with him?How the user can use this key to open the lock?

I have Nuki keypad - would it be possible to integrate this generated key with the keypad - so i can just share a pin with the user? And user would use keypad to open the lock?

Regards,
Jan

@jroman In the first step a Nuki Bridge is a device to get remote access to your Smart Lock. If you have a Keypad you can create entry codes for that and just give those to guests.
Additionally you can use the Bridge API (locally) and the Web API (needing a Nuki Web account) to automate tasks. Still authorizations are created on the device itself (locally ore remotely if online and reachable through the Bridge).

Hi @MatthiasK,
Thank you very much for your answer yet it is still a bit unclear. Please note I am exploring automated way of creating authorisations - doing it from application works fine.

I believe it is only possible with bluetooth API or manually from mobile app.

I was going trough bridge api spec - but I cannot figure out which endpoint could be used for creating authorisation. I would appreciate if you can point me to some reference reading.

So here we arrive at this very topic :slight_smile: Inside authorisation object I can see there is property “code” is it the value that user needs to enter using keypad?

Sorry if my first answer was too general as I was not 100% sure about your usecase.

Yes, this is what you seem to be looking for.
You can set a Keypad entry code (6 digits from 1-9) for an authorization of type=13

See also

1 Like

This post is not displaying anymore there seem to be a JS error in the page

Should be fixed now.

On creation an e-mail with the invite-key is sent to the users EMAIL.

In our case the user is connected to the smartlock correctly (we can see this in the Web version), but no invitation e-mail is sent on creation. The deactivation e-mail is received correctly afterwards. Can we debug this somehow?

I have issues creating nuki keys with pin codes. When using the following URL and parameters:

Request URL: https://api.nuki.io/smartlock/17965718244/auth

data:{‘accountUserId’: ‘1555484306’, ‘name’: ‘29646434 #1:SVV-Key-PIN’, ‘remoteAllowed’: False, ‘smartActionsEnabled’: False, ‘allowedFromDate’: ‘2022-10-31T18:0:0.000Z’, ‘allowedUntilDate’: ‘2022-11-02T10:30:0.000Z’, ‘allowedWeekDays’: 0, ‘allowedFromTime’: 0, ‘allowedUntilTime’: 0, ‘code’: 242801, ‘type’: 13}

The key gets created BUT we do not receive your NUKI Email with the invitation to activate the key.
Do you have an idea what the problem is?

Hello Christian,

We found the registered email to be “001nuki@msd-ag.de”. Is this your registered email? Could you please check this account for KP codes?

Sorry for my later answer. This is our registered email address, correct. We have not received any specific email with KP codes (You mean the PIN codes for the nuki keyboard - correct? Can you send us a sample how this email should look like?

Hi Christian,

We send out emails for KP codes and/or invites for the custom integrations but in your case, we do not send out an email if you create just a KP code via the Web API. You would have to send it yourself to the guest. In case you create an authorisation, we send out an invite email, like the below:

Hello!

abc@gmail.com has granted you access to a Nuki Smart Lock.

Open this email on your smartphone and click on the button to accept the invitation:
[Accept invitation]
You can redeem the invitation once within 48h.

If you have any questions, please visit the support center or contact the Nuki support at contact@nuki.io

Best regards,
your Nuki team

Thank you for the answer. So my understanding is, if I create a nuki key with a KP code the nuki key is created including KP code but Nuki does not send out a invitation email in this case. Correct? So the nuki key is unknown to anybody (only to you) but the KP code is active and can be used by the guest to open the door.

Yes, that is correct.

Hi can u please tell me what smart lock Id I put to get smart lock Id’s. I mean to say I want payload input data for smart lock related api’s.

Below error I getting it. ```
“The supplied value ‘123’ for parameter ‘smartlockId’ doesn’t exist”
Can u please help me to add correct SmartlockId

Hi Yogesh,

The Web API expects Nuki Device IDs to be sent as an integer. Device IDs are in HEX therefore they need to be converted to DEC. For the Nuki Opener this needs the type as a prefix to ensure unique IDs for Web API usage

device type ID (HEX) example ID (HEX) example with prefix calulated ID (DEC) example
keyturner 0 1A2B3C4D 1A2B3C4D 439041101
opener 2 1A2B3C4D 21A2B3C4D 9028975693
smartdoor 3 1A2B3C4D 31A2B3C4D 13323942989
smartlock3 4 1A2B3C4D 41A2B3C4D 17618910285

Thank u poonam but still getting same error as below ```
The supplied value ‘17618910285’ for parameter ‘smartlockId’ doesn’t exist

Hi Yogesh,

Which version of Smart Lock do you have? Since you cannot share the Smart Lock ID on the forum, I would request you to check once more if you are providing the correct ID, which is on your Smart Lock.

thank u.