Seam enables you to lock or unlock your door lock remotely. This guide walks you through how to perform these actions using the Seam API.
When you send a command to a smart lock, it might take a while for Seam to confirm the action's success. To handle this, Seam provides , which indicates whether the action was successful.
To ensure that the action has been successfully executed, we advise checking the status of the action attempt object by polling the . Once Seam has successfully confirmed the action, the action attempt's status will indicate success.
For those who prefer using webhooks to verify the success of an action, we'll soon introduce events that confirm an action's success.
Before You Begin: Confirm Capabilities
Before you attempt to lock or unlock a device, be sure to confirm that your device has the capability to perform these operations. You can inspect the capabilities of a device by checking the following for the device:
device.can_remotely_lock
device.can_remotely_unlock
Use for a specific device to return these capability flags. Then, use an if statement or similar check to confirm that the relevant flag is both present and true before attempting to lock or unlock the device.
If either of these capability flags is false or not present, you can view the of the device, or for the device, and related to the device to learn more about the cause of these issues. For example, you could examine device.properties.online. In addition, you could look for a device.disconnected event.
Device(
device_id='11111111-1111-1111-1111-444444444444',
can_remotely_lock=True, // You can use seam.locks.lock_door() on this device.
can_remotely_unlock=True, // You can use seam.locks.unlock_door() on this device.
...
)
Request:
# Use GET or POST.
curl -X 'GET' \
'https://connect.getseam.com/devices/get' \
-H 'accept: application/json' \
-H "Authorization: Bearer ${SEAM_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"device_id": "11111111-1111-1111-1111-444444444444"
}'
Response:
{
"device": {
"device_id": "11111111-1111-1111-1111-444444444444",
"can_remotely_lock": true, // You can use /locks/lock_door on this device.
"can_remotely_unlock": true, // You can use /locks/unlock_door on this device.
...
},
"ok": true
}
{
device_id: '11111111-1111-1111-1111-444444444444',
can_remotely_lock: true, // You can use seam.locks.lockDoor() on this device.
can_remotely_unlock: true, // You can use seam.locks.unlockDoor() on this device.
...
}
<
Seam::Device:0x00438
device_id="11111111-1111-1111-1111-444444444444"
can_remotely_lock=true // You can use client.locks.lock_door() on this device.
can_remotely_unlock=true // You can use client.locks.unlock_door() on this device.
...
>
{
"device_id": "11111111-1111-1111-1111-444444444444",
"can_remotely_lock": true, // You can use $seam->locks->lock_door() on this device.
"can_remotely_unlock": true, // You can use $seam->locks->unlock_door() on this device.
...
}
{
"device_id": "11111111-1111-1111-1111-444444444444",
"can_remotely_lock": true, // You can use seam.Locks.LockDoor() on this device.
"can_remotely_unlock": true, // You can use seam.Locks.UnlockDoor() on this device.
...
}
{
"device_id": "11111111-1111-1111-1111-444444444444",
"can_remotely_lock": true, // You can use seam.locks.lockDoor() on this device.
"can_remotely_unlock": true, // You can use seam.locks.unlockDoor() on this device.
...
}
{
"device_id": "11111111-1111-1111-1111-444444444444",
"can_remotely_lock": true, // You can use client.Locks.LockDoor() on this device.
"can_remotely_unlock": true, // You can use client.Locks.UnlockDoor() on this device.
...
}
Locking a Door
Request:
# Get the device.
device = seam.devices.get(
device_id="11111111-1111-1111-1111-444444444444"
)
# Confirm that the device can remotely lock.
if device.can_remotely_lock:
# Perform the lock operation.
seam.locks.lock_door(device_id=device.device_id)
// Get the device.
const device = await seam.devices.get({
device_id: "11111111-1111-1111-1111-444444444444"
});
// Confirm that the device can remotely lock.
if (device.can_remotely_lock) {
// Perform the lock operation.
await seam.locks.lockDoor({
device_id: device.device_id
})
};
# Get the device.
device = client.devices.get(device_id: "11111111-1111-1111-1111-444444444444")
# Confirm that the device can remotely lock.
if (device.can_remotely_lock)
# Perform the lock operation.
client.locks.lock_door(device_id: device.device_id)
end
// Get the device.
$device = $seam->devices->get(device_id: "11111111-1111-1111-1111-444444444444");
// Confirm that the device can remotely lock.
if ($device->can_remotely_lock) {
// Perform the lock operation.
$seam->locks->lock_door(device_id: $device->device_id);
}
// Get the device.
Device device = seam.Devices.Get(deviceId: "11111111-1111-1111-1111-444444444444");
// Confirm that the device can remotely lock.
if (device.CanRemotelyLock == true) {
// Perform the lock operation.
seam.Locks.LockDoor(deviceId: device.DeviceId);
}
// Get the device.
Device device = seam.devices()
.get(DevicesGetRequest.builder()
.deviceId("11111111-1111-1111-1111-444444444444")
.build());
// Confirm that the device can remotely lock.
if (device.getCanRemotelyLock())
{
// Perform the lock operation.
seam.locks()
.lockDoor(LocksLockDoorRequest.builder()
.deviceId(device.getDeviceId())
.build());
}
# Get the device.
device = seam.devices.get(
device_id="11111111-1111-1111-1111-444444444444"
)
# Confirm that the device can remotely unlock.
if device.can_remotely_unlock:
# Perform the unlock operation.
seam.locks.unlock_door(device_id=device.device_id)
// Get the device.
const device = await seam.devices.get({
device_id: "11111111-1111-1111-1111-444444444444"
});
// Confirm that the device can remotely unlock.
if (device.can_remotely_unlock) {
// Perform the unlock operation.
await seam.locks.unlockDoor({
device_id: device.device_id
})
};
# Get the device.
device = client.devices.get(device_id: "11111111-1111-1111-1111-444444444444")
# Confirm that the device can remotely unlock.
if (device.can_remotely_unlock)
# Perform the unlock operation.
client.locks.unlock_door(device_id: device.device_id)
end
// Get the device.
$device = $seam->devices->get(device_id: "11111111-1111-1111-1111-444444444444");
// Confirm that the device can remotely unlock.
if ($device->can_remotely_unlock) {
// Perform the unlock operation.
$seam->locks->unlock_door(device_id: $device->device_id);
}
// Get the device.
Device device = seam.Devices.Get(deviceId: "11111111-1111-1111-1111-444444444444");
// Confirm that the device can remotely unlock.
if (device.CanRemotelyUnlock == true) {
// Perform the unlock operation.
seam.Locks.UnlockDoor(deviceId: device.DeviceId);
}
// Get the device.
Device device = seam.devices()
.get(DevicesGetRequest.builder()
.deviceId("11111111-1111-1111-1111-444444444444")
.build());
// Confirm that the device can remotely unlock.
if (device.getCanRemotelyUnlock())
{
// Perform the unlock operation.
seam.locks()
.lockDoor(LocksUnlockDoorRequest.builder()
.deviceId(device.getDeviceId())
.build());
}
You can lock a door using the endpoint. To confirm the success of the action, see .
You can unlock a door using the endpoint. To confirm the success of the action, see .
Use the action_attempt_id from the prior response to make a . When the action attempt's status changes to success, it indicates the action has been successful.
To retrieve the locked status of a specific door lock, use the or endpoint by providing the device_id of the desired lock. This operation returns detailed information, including the current locked status. Note that if the lock is offline, Seam does not return the device.locked property.
Whenever a lock is locked or unlocked, Seam emits a lock.locked or lock.unlocked event. You can see these events by making a or by setting up a webhook. For more information on how to set up webhooks, see the .
For more information about the lock.locked and lock.unlocked attributes, please see.