Passcodes

Passcodes are used to access a given lock. On this page, we'll dive into the different passcode endpoints you can use to manage passcodes programmatically.

The passcode model

The passcode model contains all the information about the passcodes.

Properties

  • Name
    keyboardPwdId
    Type
    integer
    Description

    The id of the passcode.

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    keyboardPwd
    Type
    string
    Description

    Passcode value

  • Name
    keyboardPwdName
    Type
    string
    Description

    Passcode name

  • Name
    keyboardPwdType
    Type
    integer
    Description

    Passcode type

  • Name
    startDate
    Type
    long
    Description

    The time when the passcode becomes valid (in milliseconds)

  • Name
    endDate
    Type
    long
    Description

    The time when the passcode expires (in milliseconds)

  • Name
    sendDate
    Type
    long
    Description

    Init time (in milliseconds)

  • Name
    isCustom
    Type
    integer
    Description

    Whether the passcode is custom or random

  • Name
    senderUsername
    Type
    String
    Description

    The username of the user who created the passcode

  • Name
    createDate
    Type
    long
    Description

    Creation time (in milliseconds)

  • Name
    effectiveDate
    Type
    long
    Description

    Effective time (in milliseconds)

  • Name
    expiryDate
    Type
    long
    Description

    Expiry time (in milliseconds)

  • Name
    enable
    Type
    boolean
    Description

    Whether the passcode is enabled

Passcode Object

{
  "keyboardPwdId": 12345,
  "lockId": 865759,
  "keyboardPwd": "123456",
  "keyboardPwdName": "Front Door",
  "keyboardPwdType": 1,
  "startDate": 1672689580361,
  "endDate": 1675281580361,
  "sendDate": 1672689580361,
  "isCustom": 1,
  "senderUsername": "John",
  "createDate": 1672689580361,
  "effectiveDate": 1672689580361,
  "expiryDate": 1675281580361,
  "enable": true
}

GET/api/v1/passcode/list

List all passcodes

This endpoint allows you to retrieve a paginated list of all passcodes for a specific lock.

Required attributes

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    pageNo
    Type
    integer
    Description

    Page number (minimum 1)

  • Name
    pageSize
    Type
    integer
    Description

    Page size minimum 10, maximum 1000

Request

GET
/api/v1/passcode/list
curl --location --request GET 'https://api.dusaw.com/api/v1/passcode/list?lockId=865759&pageNo=1&pageSize=20' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {token}'

Response

{
  "list": [
    ...
    {
      "keyboardPwdId": 12345,
      "lockId": 865759,
      "keyboardPwd": "123456",
      "keyboardPwdName": "Front Door",
      "keyboardPwdType": 1,
      "startDate": 1672689580361,
      "endDate": 1675281580361,
      "sendDate": 1672689580361,
      "isCustom": 1,
      "senderUsername": "John",
      "createDate": 1672689580361,
      "effectiveDate": 1672689580361,
      "expiryDate": 1675281580361,
      "enable": true
    }
    ...
  ],
  "pageNo":1,
  "pageSize":10,
  "pages":3,
  "total":25
}

POST/api/v1/passcode/random

Get a random passcode

Generates a random passcode for a given lock.

We advise you to set the startDate and endDate on the hour because the random passcode's valid period can only be accurate to hours. For example, if the startDate is set to a timestamp of 19:20, the real start time will be 19:00.

When a passcode's validity term exceeds a year, it can only be accurate to a month. It means the day and time of the startDate and the endDate must be the same, for example: 2021-03-18 00:00:00 to 2022-03-18 00:00:00.

Required attributes

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    keyboardPwdType
    Type
    integer
    Description

    Passcode type

  • Name
    startDate
    Type
    long
    Description

    The time when the passcode becomes valid (in milliseconds). Must be later than 6 hours ago.

Optional attributes

  • Name
    keyboardPwdName
    Type
    string
    Description

    Passcode name

  • Name
    endDate
    Type
    long
    Description

    The time when the passcode expires (in milliseconds). Must be greater than startDate.

Request

POST
/api/v1/passcode/random
curl --location --request POST 'https://api.dusaw.com/api/v1/passcode/random' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {token}' \
  --data-raw '{
    "lockId": 865759,
    "keyboardPwdType": 2,
    "keyboardPwdName": "Front Door",
    "startDate": 1672689580361,
    "endDate": 1675281580361
  }'

Response

{
  "keyboardPwdId": 225875322,
  "keyboardPwd": "09577481"
}

POST/api/v1/passcode/custom

Add a custom passcode

Adds a custom passcode for a given lock. The passcode must be a 4-9 digit number.

We advise you to set the startDate and endDate on the hour because the passcode's valid period can only be accurate to hours. For example, if the startDate is set to a timestamp of 19:20, the real start time will be 19:00.

When a passcode's validity term exceeds a year, it can only be accurate to a month. It means the day and time of the startDate and the endDate must be the same, for example: 2021-03-18 00:00:00 to 2022-03-18 00:00:00.

Required attributes

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    keyboardPwd
    Type
    integer
    Description

    Passcode value (4-9 digits)

  • Name
    keyboardPwdType
    Type
    integer
    Description

    Passcode type

  • Name
    addType
    Type
    integer
    Description

    1 - via phone bluetooth, should add through the app first. 2 - via gateway or WiFi lock, you can call this api directly if it's a WiFi lock or it's connected to a gateway.

  • Name
    startDate
    Type
    long
    Description

    The time when the passcode becomes valid (in milliseconds). Must be later than 6 hours ago.

  • Name
    endDate
    Type
    long
    Description

    The time when the passcode expires (in milliseconds). Must be greater than startDate.

Optional attributes

  • Name
    keyboardPwdName
    Type
    string
    Description

    Passcode name

Request

POST
/api/v1/passcode/custom
curl --location --request POST 'https://api.dusaw.com/api/v1/passcode/custom' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {token}' \
  --data-raw '{
    "lockId": 865759,
    "keyboardPwd": 123456,
    "keyboardPwdType": 2,
    "addType": 2,
    "keyboardPwdName": "Front Door",
    "startDate": 1672689580361,
    "endDate": 1675281580361
  }'

Response

{
  "keyboardPwdId": 225875323
}

PUT/api/v1/passcode/change

Change a passcode

You can modify the name, validity period, or passcode itself using this API. When you want to change only the passcode name, only the keyboardPwdName parameter is needed. The startDate and endDate parameters must be provided together when changing a validity period. When changing the passcode value, the keyboardPwd parameter is required.

Required attributes

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    keyboardPwdId
    Type
    integer
    Description

    The passcode ID.

  • Name
    changeType
    Type
    integer
    Description

    1 - via phone bluetooth, should change through the app first. 2 - via gateway or WiFi lock, you can call this api directly if it's a WiFi lock or it's connected to a gateway.

Optional attributes

  • Name
    keyboardPwd
    Type
    integer
    Description

    New passcode value (4-9 digits)

  • Name
    keyboardPwdName
    Type
    string
    Description

    Passcode name

  • Name
    startDate
    Type
    long
    Description

    The time when the passcode becomes valid (in milliseconds). Required when endDate is provided. Must be later than 6 hours ago.

  • Name
    endDate
    Type
    long
    Description

    The time when the passcode expires (in milliseconds). Must be greater than startDate.

Request

PUT
/api/v1/passcode/change
curl --location --request PUT 'https://api.dusaw.com/api/v1/passcode/change' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {token}' \
  --data-raw '{
    "lockId": 865759,
    "keyboardPwdId": 12345,
    "changeType": 1,
    "keyboardPwd": 654321
  }'

Response

{
  "success": true
}

DELETE/api/v1/passcode/delete

Delete a passcode

This endpoint deletes a passcode from a lock.

Required attributes

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    keyboardPwdId
    Type
    integer
    Description

    The passcode ID.

  • Name
    deleteType
    Type
    integer
    Description

    1 - via phone bluetooth, should delete through the app first. 2 - via gateway or WiFi lock, you can call this api directly if it's a WiFi lock or it's connected to a gateway.

Request

DELETE
/api/v1/passcode/delete
curl --location --request DELETE 'https://api.dusaw.com/api/v1/passcode/delete?lockId=865759&keyboardPwdId=12345&deleteType=1' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {token}'

Response

{
  "success": true
}

DELETE/api/v1/passcode/delete-all

Delete all passcodes

This endpoint deletes all passcodes from a specific lock.

Required attributes

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    deleteType
    Type
    integer
    Description

    1 - via phone bluetooth, should delete through the app first. 2 - via gateway or WiFi lock, you can call this api directly if it's a WiFi lock or it's connected to a gateway.

Request

DELETE
/api/v1/passcode/delete-all
curl --location --request DELETE 'https://api.dusaw.com/api/v1/passcode/delete-all?lockId=865759&deleteType=2' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {token}'

Response

{
  "success": true
}

Was this page helpful?