Seam provides a universal API to connect and control many brands of IoT devices and systems, including smart locks, access control systems (ACSs), thermostats, and noise sensors.
This guide gives you a rapid introduction to connecting and controlling your 4SUITES lock using the Seam API. For application developers, you can use the Seam API in your app, and your users can authorize your app to control their devices using Seam.
For detailed information about the 4SUITES devices that Seam supports, see the following table and our 4SUITES Supported Devices page:
To learn more about other IoT device and system brands that Seam supports—such as Yale, Schlage, Google Nest, and many more—visit our integration page.
This guide shows you how to install a Seam SDK and then control your 4SUITES lock using the Seam API.
Another easy way to learn about what you can do with the Seam API is to explore the interactive Seam CLI, which you can access from directly within the Seam Console.
Seam provides client libraries for many languages, including JavaScript, Python, Ruby, PHP, and others, as well as a Postman collection and an OpenAPI spec.
This guide uses a sandbox workspace. You can only connect virtual devices and systems in this type of workspace. If you want to connect a real 4SUITES lock, use a non-sandbox workspace and API key.
Step 2: Link your 4SUITES account with Seam
To control your 4SUITES lock using the Seam API, you must first authorize your Seam workspace to connect to your 4SUITES account. If your application needs to connect to your users' 4SUITES accounts, Seam provides fully-embedded, customizable client-side Connect Webviews to collect their authorization securely. These user-friendly pre-built authorization flows walk your users through the process of granting your Seam workspace permission to control their 4SUITES locks. The Connect Webview presents a flow that prompts your users to enter their credentials for their 4SUITES account.
In this guide, you create a Connect Webview object. Then, you display the graphical component of the created Connect Webview and enter a set of sample credentials to connect a sandbox 4SUITES account.
This guide shows you how to create a Connect Webview programmatically using the Seam API.
The Seam Console provides another easy way to connect devices to your Seam workspace.
Create a connect_webview object and then note the returned URL.
Code:
from seam import Seamseam =Seam()# Seam automatically uses your exported SEAM_API_KEY.connect_webview = seam.connect_webviews.create(accepted_providers=["four_suites"])assert connect_webview.login_successful isFalse# Use the returned Connect Webview URL to display# the Connect Webview authorization flow to your user.print(connect_webview.url)
import { Seam } from"seam";constseam=newSeam(); // Seam automatically uses your exported SEAM_API_KEY.constconnectWebview=awaitseam.connectWebviews.create({ accepted_providers: ['four_suites']});console.log(connectWebview.login_successful); // false// Use the returned Connect Webview URL to display// the Connect Webview authorization flow to your user.console.log(connectWebview.url);
require"seam"seam =Seam.new() # Seam automatically uses your exported SEAM_API_KEY.connect_webview = seam.connect_webviews.create( accepted_providers: ["four_suites"])puts connect_webview.login_successful # false# Use the returned Connect Webview URL to display# the Connect Webview authorization flow to your user.puts connect_webview.url
<?phprequire'vendor/autoload.php';$seam =newSeam\SeamClient(); // Seam automatically uses your exported SEAM_API_KEY.$connect_webview = $seam->connect_webviews->create( accepted_providers: ["four_suites"]);echo $connect_webview->login_successful ?'true':'false',"\n"; // false// Use the returned Connect Webview URL to display// the Connect Webview authorization flow to your user.echo $connect_webview->url;
usingSeam.Client;var seam =newSeamClient(apiToken: SEAM_API_KEY);var connectWebview =seam.ConnectWebviews.Create( acceptedProviders:new() {Seam.Api.ConnectWebviews.CreateRequest.AcceptedProvidersEnum.FourSuites});Console.WriteLine(connectWebview.LoginSuccessful); // False// Use the returned Connect Webview URL to display// the Connect Webview authorization flow to your user.Console.WriteLine(connectWebview.Url);
importjava.io.Console;importjava.util.*;importcom.fasterxml.jackson.annotation.*;importcom.fasterxml.jackson.databind.annotation.JsonDeserialize;importcom.seam.api.Seam;importcom.seam.api.core.ObjectMappers;importcom.seam.api.types.ConnectWebview;importcom.seam.api.types.Device;importcom.seam.api.types.Manufacturer;importcom.seam.api.types.ActionAttempt;importcom.seam.api.types.AccessCode;importcom.seam.api.resources.connectwebviews.requests.ConnectWebviewsCreateRequest;importcom.seam.api.resources.connectwebviews.requests.ConnectWebviewsGetRequest;importcom.seam.api.resources.devices.requests.DevicesListRequest;importcom.seam.api.resources.devices.requests.DevicesGetRequest;importcom.seam.api.resources.locks.requests.LocksUnlockDoorRequest;importcom.seam.api.resources.accesscodes.requests.AccessCodesCreateRequest;importcom.seam.api.resources.accesscodes.requests.AccessCodesListRequest;publicclassMain {publicstaticvoidmain(String[] args) {Seam seam =Seam.builder().apiKey(SEAM_API_KEY).build();ConnectWebview connectWebview =seam.connectWebviews().create(ConnectWebviewsCreateRequest.builder().acceptedProviders(List.of(AcceptedProvider.FOUR_SUITES)).build());System.out.println(connectWebview.getLoginSuccessful()); // false// Use the returned Connect Webview URL to display// the Connect Webview authorization flow to your user.System.out.println(connectWebview.getUrl()); }}
In a web browser, go to the URL that the Connect Webview object returned.
For application developers, you can redirect your user to this Connect Webview URL so that they can authorize your app to control their devices using Seam. We even provide a prebuilt Connect Account Button within our suite of Seam Components that help you build your device management flow.
Because you're using a sandbox workspace, you can connect Seam's test 4SUITES account. We provide virtual devices for each of the brands that we support. These sandbox devices and systems enable you to test your app with devices from multiple brands without the need to own all the corresponding physical devices.
Complete the Connect Webview authorization flow by entering the following 4SUITES sandbox account credentials:
Email: jane@example.com
Password: 1234
Confirm that authorization through the Connect Webview was successful by querying its status.
When you link a 4SUITES account with Seam, we create a device object to represent each 4SUITES lock in your account. You can then retrieve these 4SUITES devices using the List Devices and Get Device endpoints.
The Seam API exposes each device's properties, such as the door lock status, power status, capabilities, and so on.
Code:
# Retrieve all devices, filtered by manufacturer,# which is one of several filters that list() supports.all_four_suites_locks = seam.devices.list(manufacturer="four_suites")# Select the first device as an example.front_door = all_four_suites_locks[0]# Inspect specific properties.assert front_door.properties["online"]isTrue# Trueassert front_door.properties["locked"]isTrue# True# View the entire returned device object.pprint(front_door)
# Retrieve all devices, filtered by manufacturer, which is# one of several filters that the list endpoint supports.all_four_suites_locks=$(# Use GET or POST.curl-X'GET' \'https://connect.getseam.com/devices/list' \-H'accept: application/json' \-H"Authorization: Bearer ${SEAM_API_KEY}" \-H'Content-Type: application/json' \-d'{ "manufacturer": "four_suites" }')# Select the first device as an example.front_door=$(jq-r'.devices[0]'<<<${all_four_suites_locks})# Inspect specific properties.echo $(jq-r'"Online (true): " + (.properties.online | tostring)'<<<${front_door})echo $(jq-r'"Locked (true): " + (.properties.locked | tostring)'<<<${front_door})# View the entire returned device object.echo ${front_door}
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.constallFourSuitesLocks=awaitseam.devices.list({manufacturer:"four_suites"});// Select the first device as an example.constfrontDoor= allFourSuitesLocks[0];// Inspect specific properties.console.log(frontDoor.properties.online); // trueconsole.log(frontDoor.properties.locked); // true// View the entire returned device object.console.log(frontDoor);
# Retrieve all devices, filtered by manufacturer,# which is one of several filters that list() supports.all_four_suites_locks = seam.devices.list(manufacturer: "four_suites")# Select the first device as an example.front_door = all_four_suites_locks[0]# Inspect specific properties.puts front_door.properties.online # trueputs front_door.properties.locked # true# View the entire returned device object.puts front_door.inspect
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.$all_four_suites_locks = $seam->devices->list(manufacturer:"four_suites");// Select the first device as an example.$front_door = $all_four_suites_locks[0];// Inspect specific properties.echo $front_door->properties->online ?'true':'false',"\n"; // trueecho $front_door->properties->locked ?'true':'false',"\n"; // true// View the entire returned device object.echojson_encode($front_door, JSON_PRETTY_PRINT);
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.var allFourSuitesLocks =seam.Devices.List( manufacturer:Seam.Api.Devices.ListRequest.ManufacturerEnum.FourSuites);// Select the first device as an example.Device frontDoor =allFourSuitesLocks[0];// Inspect specific properties.Console.WriteLine(frontDoor.Properties.Online); // trueConsole.WriteLine(frontDoor.Properties.Locked); // true// View the entire returned device object.Console.WriteLine(frontDoor);
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.var allFourSuitesLocks =seam.devices().list(DevicesListRequest.builder().manufacturer(Manufacturer.FOURSUITES).build());// Select the first device as an example.Device frontDoor =allFourSuitesLocks.get(0);// Inspect specific properties.System.out.println(frontDoor.getProperties().getOnline()); // trueSystem.out.println(frontDoor.getProperties().getLocked()); // true// View the entire returned device object.System.out.println(frontDoor);
// Retrieve all devices, filtered by manufacturer,// which is one of several filters that list() supports.allFourSuitesLocks, err := client.Devices.List( context.Background(), &api.DevicesListRequest{ Manufacturer: api.ManufacturerFourSuites.Ptr(), },)// Select the first device as an example.frontDoor := allFourSuitesLocks[0]if err !=nil {return err}// Inspect specific properties.fmt.Println(frontDoor.Properties.Online) // truefmt.Println(*frontDoor.Properties.Locked) // true// View the entire returned device object.fmt.Println(frontDoor)returnnil
Next, you can use the Seam API to control your lock.
Each device that you connect to Seam has a specific set of capabilities. These capabilities define the Seam API actions that you can use, such as remote unlock actions, programming access codes, and so on. Seam's intuitive and granular capability flags inform your application about what features and behaviors each device supports. Notice the capability flags within the code samples in this guide.
Try out the following actions on your 4SUITES lock:
Unlock your lock
To unlock a door, use the Unlock Door endpoint. Specify the device that you want to unlock by including the device_id in the request body. This endpoint returns an action attempt to track the progress of the unlock operation.
Code:
# Confirm that the device can remotely unlock.# You're using a capability flag here!if front_door.can_remotely_unlock:# Perform the unlock operation# and return an action attempt. action_attempt=seam.locks.unlock_door(device_id=front_door.device_id)
# Confirm that the device can remotely unlock.# You're using a capability flag here!if$(jq-r'.can_remotely_lock'<<<${front_door}); then \# Perform the unlock operation# and return an action attempt.curl-X'POST' \'https://connect.getseam.com/locks/unlock_door' \-H'accept: application/json' \-H"Authorization: Bearer ${SEAM_API_KEY}" \-H'Content-Type: application/json' \-d"{ \"device_id\": \"$(jq-r '.device_id' <<<${front_door})\" }";fi
// Confirm that the device can remotely unlock.// You're using a capability flag here!if (frontDoor.can_remotely_unlock) {// Perform the unlock operation// and return an action attempt.constactionAttempt=awaitseam.locks.unlockDoor({ device_id:frontDoor.device_id });};
# Confirm that the device can remotely unlock.# You're using a capability flag here!if (front_door.can_remotely_unlock)# Perform the unlock operation# and return an action attempt. action_attempt = seam.locks.unlock_door(device_id: front_door.device_id)end
// Confirm that the device can remotely unlock.// You're using a capability flag here!if ($front_door->can_remotely_unlock) {// Perform the unlock operation// and return an action attempt. $action_attempt = $seam->locks->unlock_door(device_id: $front_door->device_id);}
// Confirm that the device can remotely unlock.// You're using a capability flag here!if (frontDoor.CanRemotelyUnlock==true) { // Perform the unlock operation // and return an action attempt.ActionAttempt actionAttempt =seam.Locks.UnlockDoor(deviceId:frontDoor.DeviceId);}
// Confirm that the device can remotely unlock.// You're using a capability flag here!if (frontDoor.getCanRemotelyUnlock()){// Perform the unlock operation// and return an action attempt.ActionAttempt actionAttempt =seam.locks().unlockDoor(LocksUnlockDoorRequest.builder().deviceId(frontDoor.getDeviceId()).build());}
// Confirm that the device can remotely unlock.// You're using a capability flag here!if*frontDoor.CanRemotelyUnlock {// Perform the unlock operation. actionAttempt, err := client.Locks.UnlockDoor( context.Background(),&api.LocksUnlockDoorRequest{ DeviceId: frontDoor.DeviceId, }, )if err !=nil {return err }}returnnil
You can track the status of the unlock operation to confirm that the device unlocked successfully. Query the locked status of the device, retrieve the action attempt by ID, or look for a lock.unlocked event.
To query the locked status of the device:
Code:
# Get the device by ID.updated_front_door = seam.devices.get(device_id=front_door.device_id)# Inspect the locked property to confirm# that the unlock operation was successful.assert updated_front_door.properties["locked"]isFalse# False
Output:
False
Code:
# Get the device by ID.updated_front_door=$(# 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\": \"$(jq-r '.device_id' <<<${front_door})\" }")# Inspect the locked property to confirm# that the unlock operation was successful.echo $(jq-r'"Locked (false): " + (.device.properties.locked | tostring)'<<<${updated_front_door})
Output:
Locked (false): false
Code:
// Get the device by ID.constupdatedFrontDoor=awaitseam.devices.get({device_id:frontDoor.device_id});// Inspect the locked property to confirm// that the unlock operation was successful.console.log(updatedFrontDoor.properties.locked) // false
Output:
false
Code:
# Get the device by ID.updated_front_door = seam.devices.get(device_id: front_door.device_id)# Inspect the locked property to confirm# that the unlock operation was successful.puts updated_front_door.properties.locked # false
Output:
false
Code:
// Get the device by ID.$updated_front_door = $seam->devices->get(device_id: $front_door->device_id);// Inspect the locked property to confirm// that the unlock operation was successful.echo $updated_front_door->properties->locked ?'true':'false',"\n"; // false
Output:
false
Code:
// Get the device by ID.Device updatedFrontDoor =seam.Devices.Get( deviceId:frontDoor.DeviceId);// Inspect the locked property to confirm// that the unlock operation was successful.Console.WriteLine(updatedFrontDoor.Properties.Locked); // false
Output:
False
Code:
// Get the device by ID.Device updatedFrontDoor =seam.devices().get(DevicesGetRequest.builder().deviceId(frontDoor.getDeviceId()).build());// Inspect the locked property to confirm// that the unlock operation was successful.System.out.println(updatedFrontDoor.getProperties().getLocked()); // false
Output:
false
Code:
// Get the device by ID.updatedFrontDoor, err := client.Devices.Get( context.Background(), &api.DevicesGetRequest{ DeviceId: api.String(frontDoor.DeviceId), },)if err !=nil {return err}// Inspect the locked property to confirm// that the unlock operation was successful.fmt.Println(*updatedFrontDoor.Properties.Locked) // false
Output:
false
Step 5: Connect a real 4SUITES lock
Now that you have learned the basics of using the Seam API, you can connect and control a real 4SUITES device. To do so, make sure to switch to a non-sandbox workspace and API key.
Seam makes it easy to develop your application. In addition to the robust Seam API and the wide variety of programming languages that our SDKs support, we also provide a suite of Seam Components. These prebuilt UI components help you to build your device management flow.
For example, you can use the Device Table Seam Component to display a list of devices and to identify all devices with issues. You can use the Device Details Seam Component to display a device's properties, settings, and issues, as well as to enable your users to perform actions based on each device's capabilities. The Access Code Details Seam Component provides a similar display and actions for access codes.
Seam Components use a responsive design to fit seamlessly on any screen size. They also provide device debugging flows to help your users.
To learn about all the Seam Components that we provide, see Seam Components.
Next steps
Now that you've completed this getting started guide for 4SUITES devices, you can learn more about what you can do with the Seam API.
If you have any questions or want to report an issue, email us at support@seam.co.