API Keys

Create an API key for authorization that enables you to control devices connected to a specific Seam workspace.

You create an API key in your sandbox workspace or production workspace to authorize your use of the Seam API. When using the Seam HTTP API or any of the Seam SDKs, you must provide this API key to issue commands that enable you to control the devices in the associated workspace. It is useful to export your API key as an environment variable. You can also test your API key.

Never use an API key in a web browser or expose it to your users.

Create an API Key

Each API key is associated with a specific workspace. For example, if you have a sandbox workspace and a production workspace, you must create and use a different API key for each of these two workspaces.

If you need to access multiple workspaces, create a Personal Access Token to use instead of a workspace-specific API key.

  1. In the upper-right corner of the Seam Console, click the down arrow to display the workspace list.

  2. Click the workspace for which you want to create an API key.

  3. In the left navigation pane, click API Keys.

  4. In the upper-right corner of the API Keys page, click + Add API Key.

  5. In the Add API Key dialog, type a name for your new API key and then click Create API Key.

  6. Copy the newly-created API key and store it for future use.

Production API keys do not include test, while API keys for sandbox workspaces do include test. In addition, if you accidentally commit your API key to a GitHub repo, the seam_ prefix is detected, and you are notified.

Export an API Key

Once you have created an API key, it is useful to export this key as an environment variable. Then, all installed Seam SDKs automatically use this exported API key.

Open a terminal window and enter the following command to export your API key:

$ export SEAM_API_KEY=seam_test2bMS_94SrGUXuNR2JmJkjtvBQDg5c

Test an API Key

Test an API key by exporting the key as an environment variable and then running the code in this section. If the API key is valid, the response displays the corresponding workspace information.

First, export the API key, as follows:

$ export SEAM_API_KEY=seam_test2bMS_94SrGUXuNR2JmJkjtvBQDg5c

Then, run the following code to test the API key:

Code:

from seam import Seam

seam = Seam()  # Seam automatically uses your exported SEAM_API_KEY.

workspace = seam.workspaces.get()
pprint(workspace)

Output:

Workspace(
  workspace_id='00000000-0000-0000-0000-000000000000',
  name='Sandbox',
  company_name='Acme',
  connect_partner_name='Acme',
  is_sandbox=True
)

Last updated

Logo

© Seam Labs, Inc. All rights reserved.