Open Platform
Skip to content

Add custom passcode ​

https://euapi.ttlock.com/v3/keyboardPwd/add

Add a 4-9 digits custom passcode to the lock,there are two methods to do it:

(1)Add by APP nearby the lock via bluetooth: ​

You can develop your own APP based on our APP SDK,call Add passccode method to wirte a passcode into the lock,then request this API ( with addType=1) to add it to the cloud to facilitate follow-up management.

(2)Add by cloud API via gateway or WiFi lock: ​

If the lock is WiFi lock or it's connected to a gateway, you can add custom passcode remotely,just request cloud API Add custom passcode ( with addType=2) , the gateway will write the passcode into the lock.

If the WiFi lock is in power-saving mode, it can perform asynchronous data transmission (addType=4). For more information on asynchronous data transmission, please refer to:WiFi lock

Due to the limited storage space of the lock, only 250 passcodes can be added at most. If the number exceeds the limit, an error code of - 3009 will be returned, indicating that the space is full. You need to delete others before adding them.

1 Request example ​

POST, ContentType:application/x-www-form-urlencoded
javascript
curl --location -g --request POST 'https://euapi.ttlock.com/v3/keyboardPwd/add' \
--data-urlencode 'clientId=fd2ff35ee3xxxxxx' \
--data-urlencode 'accessToken=780f7671b6e6bxxxxxxx' \
--data-urlencode 'lockId=24451' \
--data-urlencode 'keyboardPwd=123456' \
--data-urlencode 'keyboardPwdName=Passcode for Jack' \
--data-urlencode 'startDate=1626945087000' \
--data-urlencode 'endDate=1746945087000' \
--data-urlencode 'addType=2' \
--data-urlencode 'date=1626945087000'

2 Request parameters ​

NameTypeRequiredDescription
clientIdStringYclient_id from Create application
accessTokenStringYAccess token,refer to: Get access token
lockIdIntYLock ID, generated by Lock init
keyboardPwdIntYPasscode
keyboardPwdNameStringNPasscode name
keyboardPwdTypeIntNKeyboard password type:2-permanent, 3-period, default value is 3
startDateLongNThe time when it becomes valid (timestamp in millisecond), must be required if keyboard password type is 3-period
endDateLongNThe time when it is expired (timestamp in millisecond), must be required if keyboard password type is 3-period
addTypeIntYMethod: 1-via phone bluetooth,should call APP SDK method to add passcode first. 2-via gateway or WiFi lock,you can call this api directly if it's a WiFi lock or it's connected to gateway.If the WiFi lock is in power-saving mode, it can transmit data asynchronously (using addType = 4). The default value is 1.
dateLongYCurrent time (timestamp in millisecond)

3 Response and example ​

ParameterTypeDescription
keyboardPwdIdIntPasscode ID
{
    "keyboardPwdId": 24242
}
CopyRight © 2012-2026 TTLock.All Rights Reserved