Creating and Updating Multiple Linked Access Codes

Learn how to create and update groups of access codes with the same code for properties with multiple door locks.

Users with more than one door lock in a property may want to create groups of linked access codes, all of which have the same code (PIN). For example, a short-term rental host may want to provide guests the same PIN for both a front door lock and a back door lock. In this case, use /access_codes/create_multiple. Specify the device_id of each device for which you want to create linked access codes. You can also include additional optional properties, such as the following:

  • A name to apply to all of the access codes.

  • The preferred_code_length.

  • Whether to throw an error or create a random code if any of the included devices cannot share a code.

  • Starting and ending timestamps if you want to create time-bound access codes.

Note that you cannot specify a custom code.

When you use /access_codes/create_multiple, Seam assigns a common_code_key to all of the created access codes and returns this key. The common_code_key identifies all the access codes within this linked group.

Then, you can change the starting or ending time for the group of access codes—for example, if a short-term rental guest requests an early check-in or late checkout. To update a group of linked access codes, use /access_codes/update_multiple, specifying the common_code_key of the linked access code group, along with the replacement starting and ending timestamps.


Create Linked Access Codes

The following example creates two linked access codes for two devices.

Request:

# Create the group of linked access codes.
# Each returned access code includes a common_code_key.
seam.access_codes.create_multiple(
  device_ids = [
    "8e94044d-a4d1-4691-9f7e-e97d3e8a0b73",
    "d87eea5d-71c6-4633-a966-396c5ac51177"
  ],
  name = "Jane's reservation",
  starts_at = "2024-11-15T15:00:00Z",
  ends_at = "2024-11-17T11:00:00Z",
  preferred_code_length = 4
)

Response:

[
  AccessCode(
    access_code_id='4ae69d7a-de72-4bb0-a32e-afc2ac025e2e',
    name="Jane's reservation",
    device_id='8e94044d-a4d1-4691-9f7e-e97d3e8a0b73',
    code='2709',
    common_code_key='auto_set_by_create_multiple_a11a027a-5070-47f5-aabf-279051117b0d',
    starts_at='2024-11-15T15:00:00.000Z',
    ends_at='2024-11-17T11:00:00.000Z',
    ...
  ),
  AccessCode(
    access_code_id='adcd39ff-a334-4890-9904-0c056d8f8f8c',
    name="Jane's reservation",
    device_id='d87eea5d-71c6-4633-a966-396c5ac51177',
    code='2709',
    common_code_key='auto_set_by_create_multiple_a11a027a-5070-47f5-aabf-279051117b0d',
    starts_at='2024-11-15T15:00:00.000Z',
    ends_at='2024-11-17T11:00:00.000Z',
    ...
  )
]

Update Linked Access Codes

The following example changes both the starting and ending times for a group of linked access codes:

Request:

# Update the starting and ending times
# for all these linked access codes,
# using the common_code_key to identify
# the group of access codes to update.
seam.access_codes.update_multiple(
  common_code_key = common_code_key,
  starts_at = "2024-11-15T12:00:00Z",
  ends_at = "2024-11-17T15:00:00Z"
)

Response:

None

Last updated

Logo

© Seam Labs, Inc. All rights reserved.