Add custom passcode
https://cnapi.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-urlencodedcurl --location -g --request POST 'https://cnapi.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
| Name | Type | Required | Description |
|---|---|---|---|
| clientId | String | Y | client_id from Create application |
| accessToken | String | Y | Access token,refer to: Get access token |
| lockId | Int | Y | Lock ID, generated by Lock init |
| keyboardPwd | Int | Y | Passcode |
| keyboardPwdName | String | N | Passcode name |
| keyboardPwdType | Int | N | Keyboard password type:2-permanent, 3-period, default value is 3 |
| startDate | Long | N | The time when it becomes valid (timestamp in millisecond), must be required if keyboard password type is 3-period |
| endDate | Long | N | The time when it is expired (timestamp in millisecond), must be required if keyboard password type is 3-period |
| addType | Int | Y | Method: 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. |
| date | Long | Y | Current time (timestamp in millisecond) |
3 Response and example
| Parameter | Type | Description |
|---|---|---|
| keyboardPwdId | Int | Passcode ID |
{
"keyboardPwdId": 24242
}