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

Passcode Object

{
  "keyboardPwdId": 1234567,
  "lockId": 456789,
  "keyboardPwd": "123456",
  "keyboardPwdName":"Passcode for John",
  "keyboardPwdType": "3",
  "startDate": 1528848944000,
  "endDate": 1628875944000,
  "sendDate": 1528871944000,
  "senderUsername": "user@google.com"
}

Passcode Types

TypeValueDescription
One-time1Valid for once within 6 hours from the Start Time
Permanent2Must be used at least once within 24 Hours after the startDate, or it will be invalidated
Period3Must be used at least once within 24 Hours after the startDate, or it will be invalidated
Delete4Deletes all other codes
Weekend Cyclic5Valid only during the specified time period at the weekend
Daily Cyclic6Valid only during the specified time period everyday
Workday Cyclic7Valid only during the specified time period on workdays
Monday Cyclic8Valid only during the specified time period on Mondays
Tuesday Cyclic9Valid only during the specified time period on Tuesdays
Wednesday Cyclic10Valid only during the specified time period on Wednesdays
Thursday Cyclic11Valid only during the specified time period on Thursdays
Friday Cyclic12Valid only during the specified time period on Fridays
Saturday Cyclic13Valid only during the specified time period on Saturdays
Sunday Cyclic14Valid only during the specified time period on Sundays

GET/api/v1/passcode/list

List all passcodes

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

Required attributes

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    pageNo
    Type
    integer
    Description

    Page number

  • Name
    pageSize
    Type
    integer
    Description

    Page size minimum 10, maximum 1000

Request

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

Response

{
  "list": [
    ...
    {
      "endDate": 0,
      "sendDate": 1672364970000,
      "keyboardPwdId": 224740764,
      "nickName": "nathan",
      "keyboardPwdType": 1,
      "lockId": 7454852,
      "keyboardPwdVersion": 4,
      "isCustom": 0,
      "keyboardPwd": "30956695",
      "startDate": 1672362000000,
      "senderUsername": "user@google.com",
      "receiverUsername": "",
      "status": 1
    },
    ...
  ],
  "pageNo": 1,
  "pageSize": 20,
  "pages": 1,
  "total": 6
}

POST/api/v1/passcode/random

Get a random passcode

Generates a random passcode for a given lock, consisting of 6-9 random digits.

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)

Optional attributes

  • Name
    keyboardPwdName
    Type
    String
    Description

    Passcode name

  • Name
    endDate
    Type
    long
    Description

    The time when the passcode expires (in milliseconds)

Request

POST
/api/v1/passcode/random
curl --location --request POST 'https://api.dusaw.com/api/v1/passcode/random?lockId=7454852&keyboardPwdType=2&startDate=1672705893769' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {token}'

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

  • 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 gateway.

  • 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)

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?lockId=7454852&keyboardPwd=123456&keyboardPwdType=2&addType=2&startDate=1672705893769&endDate=1675298633978' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'

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 keyboardPwdName parameter is needed, changeType is not needed. The parameters "startDate" and "endDate" must be provided when changing a validity period; When changing passcode newKeyboardPwd parameter is required.

Required attributes

  • Name
    lockId
    Type
    integer
    Description

    The lock's unique identifier.

  • Name
    keyboardPwdId
    Type
    integer
    Description

    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 gateway.

  • 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)

Optional attributes

  • Name
    keyboardPwdName
    Type
    String
    Description

    Passcode name

  • Name
    newKeyboardPwd
    Type
    integer
    Description

    New passcode value

Request

PUT
/api/v1/passcode/change
curl --location --request PUT 'https://api.dusaw.com/api/v1/passcode/change?lockId=7116676&keyboardPwdId=225878256&newKeyboardPwd=123456&changeType=1' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer {token}'

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

    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 gateway.

Request

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

Response

{
  "success": true
}