// Get the access system.
const buildingA = await seam.acs.systems.get({
acs_system_id: '11111111-1111-1111-1111-111111111111',
})
// Define the listing.
const listing = {
listingId: '2222222-2222',
seamAccessGroupIds: ['555555-5555', '666666-6666'],
}
// Define the reservation.
const reservation = {
reservationId: '3333122-433',
guestEmail: 'jane@example.com',
listingId: '2222222-2222',
checkIn: '2024-11-01T15:00:00.000Z',
checkOut: '2024-11-04T11:00:00.000Z',
}
// Step 1:
// Create a user identity that corresponds to your user's app account.
const janeUser = await seam.userIdentities.create({
email_address: 'jane@example.com',
})
// Step 2:
// Create an access system user on the Salto KS access system.
// Specify the access schedule for the user.
const reservationUser = await seam.acs.users.create({
user_identity_id: janeUser.user_identity_id,
full_name: reservation.reservationId,
acs_system_id: buildingA.acs_system_id,
access_schedule: {
starts_at: reservation.checkIn,
ends_at: reservation.checkOut,
},
})
// Step 3:
// Add the access system user to all access groups for the listing.
for (const groupIdToAdd of listing.seamAccessGroupIds) {
await seam.acs.users.addToAccessGroup({
acs_user_id: reservationUser.acs_user_id,
acs_access_group_id: groupIdToAdd,
})
}
// Step 4:
// Create a mobile key for the access system user.
const reservationMobileKey = await seam.acs.credentials.create({
acs_user_id: reservationUser.acs_user_id,
access_method: 'mobile_key',
is_multi_phone_sync_credential: true,
})
// View the new credential.
console.log(reservationMobileKey)