Programming Code-Based Latch Credentials

Learn how to create Latch PIN codes.

To use the Seam API to program codes for users in a Latch ACS:

  1. Create an ACS user.

    • Specify the acs_system_id of the Latch ACS in the building to which you want to grant the new user access.

    • Specify the details of the new ACS user, such as their full_name, email_address, and so on.

  2. Create an ACS credential.

    • Specify the acs_user_id of the user that you just created.

    • Specify the ID of the entrance to which you want to grant access. Note that you must create a separate credential for each entrance to which you want to grant the ACS user access.

    • Specify the desired start and end dates and times for this access.

    • Set the access_method to code.

    Creating a new acs_credential object prompts the Latch ACS to generate a PIN code for the user.

When you create a credential for a Latch ACS, you cannot specify a custom code. Instead, you must let Latch generate the PIN code.

The following example walks you through this process:

Code:

# Step 1:
# Create the new user on the Latch ACS.
# jane_user is a user_identity that represents
# a user within your set of app users.
building_a_resident = seam.acs.users.create(
  acs_system_id="11111111-1111-1111-1111-111111111111",
  user_identity_id=jane_user.user_identity_id,
  full_name="Jane Doe",
  email_address="jane@example.com"
)

# Step 2:
# Create a PIN code for each door for the ACS user.
for entrance in entrances:
  credential = seam.acs.credentials.create(
    acs_user_id=building_a_resident.acs_user_id,
    access_method="code",
    allowed_acs_entrance_ids=[
      # You must specify only one entrance per PIN code.
      entrance.acs_entrance_id
    ],
    starts_at="2024-07-13T16:50:42.072Z",
    ends_at="2024-07-18T16:50:42.072Z"
  )

  pprint(credential)

  # View the list of entrances to which the credential
  # grants access.
  seam.acs.credentials.list_accessible_entrances(
    acs_credential_id=credential.acs_credential_id
  )

Output:

AcsCredential(
  acs_credential_id='66666666-6666-6666-6666-666666666666',
  acs_user_id='33333333-3333-3333-3333-333333333333',
  code='1234567',
  access_method='code',
  starts_at='2024-07-13T16:50:42.072Z',
  ends_at='2024-07-18T16:50:42.072Z',
  ...
)
[
  AcsEntrance(
    acs_entrance_id='55555555-5555-5555-5555-555555555555',
    display_name='Room Entrance',
    ...
  )
]
...

Next Steps

To learn more about using the Seam API with your Latch ACS, see the following topics:

Last updated

Logo

© Seam Labs, Inc. All rights reserved.