A small example how you could create invite keys for you smart lock via our Web API.
If you got problems or are unsure about how to test it you can use our Swagger Interface to check the commands there first.
You need an ACCESS_TOKEN to do this. See Web API Authentication how to get one first, if this is new for you.
Get the Smart Lock ID
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' 'https://api.nuki.io/smartlock'
Store the smartlockId for you Smart Lock as e.g. SMARTLOCK_ID.
Create a user
To be able to send an e-mail invite for the key we will create we have to create a user first.
To create a user via the web API you need a valid e-mail address EMAIL and an user name USERNAME.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' -d '{ \
"email": "EMAIL", \
"name": "USERNAME" \
}' 'https://api.nuki.io/account/user'
Get the user ID
curl -X GET --header ‘Accept: application/json’ --header ‘Authorization: Bearer ACCESS_TOKEN’ ‘https://api.nuki.io/account/user’
Store the accountUserId for the USERNAME/EMAIL you set as ACCOUNT_USER_ID.
Create a key
A new access authentification for a Smart Lock (‘key’) needs a name KEY_NAME, which is then shown as a Smart Lock permisson in Nuki Web, as well as Boolean values for remoteAllowed (allowing remote lock actions) and smartActionsEnabled (allowing the user to set smart actions like auto-unlock or auto-lock).
Furthermor you can set restrictions to times at which lock actions are allowed for that key.
allowedFromDate (string, optional): General validity start in the format YYYY-MM-DDTHH:MM:SSZ
allowedUntilDate (string, optional): General validity end in the format YYYY-MM-DDTHH:MM:SSZ
allowedWeekDays (integer, optional): The allowed weekdays bitmask: 64 .. monday, 32 .. tuesday, 16 .. wednesday, 8 .. thursday, 4 .. friday, 2 .. saturday, 1 .. sunday
allowedFromTime (integer, optional): Specific allowed from time (in minutes from midnight)
allowedUntilTime (integer, optional): Specific allowed until time (in minutes from midnight); to remove set to ‘Null’
Just leave those values out to not set restrictions.
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' -d '{ "accountUserId": ACCOUNT_USER_ID,
"name": "KEY_NAME", "remoteAllowed": false,
"smartActionsEnabled": false}' 'https://api.nuki.io/smartlock/SMARTLOCK_ID/auth'
On creation an e-mail with the invite-key is sent to the users EMAIL.
Get the key ID
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' 'https://api.nuki.io/smartlock/SMARTLOCK_ID/auth'
Store the id of the auth for the KEY_NAME/ACCOUNT_USER_ID you created as KEY_ID.
Edit a key
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' -d '{ \
"name": "NEW_KEY_NAME" \
}' 'https://api.nuki.io/smartlock/SMARTLOCK_ID/auth/KEY_ID'
Deactivate a key
Just update the key with “enable”: false:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' -d '{ \
"enable": false \
}' 'https://api.nuki.io/smartlock/SMARTLOCK_ID/auth/KEY_ID'
Delete a key
curl -X DELETE --header 'Accept: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' 'https://api.nuki.io/smartlock/SMARTLOCK_ID/auth/KEY_ID'
Delete a user
curl -X DELETE --header 'Accept: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' 'https://api.nuki.io/account/user/AccountUserID