Create an Access Code
Create an access code for a device by ID
Creates a new access code.
ID of the device for which you want to create the new access code.
Name of the new access code. Enables administrators and users to identify the access code easily, especially when there are numerous access codes.
Note that the name provided on Seam is used to identify the code on Seam and is not necessarily the name that will appear in the lock provider's app or on the device. This is because lock providers may have constraints on names, such as length, uniqueness, or characters that can be used. In addition, some lock providers may break down names into components such as `first_name` and `last_name`.
To provide a consistent experience, Seam identifies the code on Seam by its name but may modify the name that appears on the lock provider's app or on the device. For example, Seam may add additional characters or truncate the name to meet provider constraints.
To help your users identify codes set by Seam, Seam provides the name exactly as it appears on the lock provider's app or on the device as a separate property called `appearance`. This is an object with a `name` property and, optionally, `first_name` and `last_name` properties (for providers that break down a name into components).
Date and time at which the validity of the new access code starts, in ISO 8601 format.
Date and time at which the validity of the new access code ends, in ISO 8601 format. Must be a time in the future and after starts_at
.
Code to be used for access.
^\d+$
false
true
Key to identify access codes that should have the same code. Any two access codes with the same common_code_key
are guaranteed to have the same code
. See also Creating and Updating Multiple Linked Access Codes.
Indicates whether native scheduling should be used for time-bound codes when supported by the provider. Default: true
.
Indicates whether to use a backup access code pool provided by Seam. If true
, you can use /access_codes/pull_backup_access_code
.
Indicates whether external modification of the code is allowed. Default: false
.
Indicates whether external modification of the code is allowed. Default: false
.
Preferred code length. Only applicable if you do not specify a code
. If the affected device does not support the preferred code length, Seam reverts to using the shortest supported code length.
Indicates whether the access code is an offline access code.
Indicates whether the offline access code is a single-use access code.
Maximum rounding adjustment. To create a daily-bound offline access code for devices that support this feature, set this parameter to 1d
.
1hour
Possible values: POST /access_codes/create HTTP/1.1
Host: connect.getseam.com
Authorization: Bearer Customer Client Session Token
Content-Type: application/json
Accept: */*
Content-Length: 437
{
"device_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "text",
"starts_at": "text",
"ends_at": "text",
"code": "text",
"sync": false,
"attempt_for_offline_device": true,
"common_code_key": "text",
"prefer_native_scheduling": true,
"use_backup_access_code_pool": true,
"allow_external_modification": true,
"is_external_modification_allowed": true,
"preferred_code_length": 1,
"is_offline_access_code": true,
"is_one_time_use": true,
"max_time_rounding": "1hour"
}
{
"action_attempt": {
"action_attempt_id": "123e4567-e89b-12d3-a456-426614174000",
"status": "pending",
"result": null,
"error": null,
"action_type": "LOCK_DOOR"
},
"access_code": {
"common_code_key": "text",
"is_scheduled_on_device": true,
"type": "time_bound",
"is_waiting_for_code_assignment": true,
"access_code_id": "123e4567-e89b-12d3-a456-426614174000",
"device_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "text",
"code": "text",
"created_at": "2025-07-02T14:04:47.568Z",
"errors": [
{
"message": "text",
"is_access_code_error": true,
"created_at": "2025-07-02T14:04:47.568Z",
"error_code": "smartthings_failed_to_set_access_code"
}
],
"warnings": [
{
"message": "text",
"created_at": "2025-07-02T14:04:47.568Z",
"warning_code": "smartthings_failed_to_set_access_code"
}
],
"is_managed": true,
"starts_at": "2025-07-02T14:04:47.568Z",
"ends_at": "2025-07-02T14:04:47.568Z",
"status": "setting",
"is_backup_access_code_available": true,
"is_backup": true,
"pulled_backup_access_code_id": "123e4567-e89b-12d3-a456-426614174000",
"is_external_modification_allowed": true,
"is_one_time_use": true,
"is_offline_access_code": true
},
"ok": true
}
Code Examples
Creating an Ongoing Access Code
Request:
device_id = "6aae9d08-fed6-4ca5-8328-e36849ab48fe"
created_access_code = seam.access_codes.create(
device = device_id,
name = "my ongoing code",
code = "1234"
)
pprint(created_access_code)
Response:
AccessCode(access_code_id='daf89de3-ad3a-49aa-93bd-25f27d58f699',
device_id='6aae9d08-fed6-4ca5-8328-e36849ab48fe',
type='ongoing',
code='1234',
created_at='2023-10-19T02:15:04.911Z',
errors=[],
warnings=[],
starts_at=None,
ends_at=None,
name='my ongoing code',
status='setting',
common_code_key=None,
is_managed=True,
is_waiting_for_code_assignment=None,
is_scheduled_on_device=None,
pulled_backup_access_code_id=None,
is_backup_access_code_available=False,
is_backup=None,
appearance=None,
is_external_modification_allowed=False,
is_offline_access_code=False,
is_one_time_use=False)
Creating a Time-Bound Access Code
Request:
device_id = "6aae9d08-fed6-4ca5-8328-e36849ab48fe"
created_access_code = seam.access_codes.create(
device = device_id,
name = "my time-bound code",
starts_at = "2025-01-01T16:00:00Z",
ends_at = "2025-01-22T12:00:00Z",
code = "2345"
)
pprint(created_access_code)
Response:
AccessCode(access_code_id='1bbd1eba-e4a2-4f96-b1b9-8498a5405b2b',
device_id='6aae9d08-fed6-4ca5-8328-e36849ab48fe',
type='time_bound',
code='2345',
created_at='2023-10-19T02:21:58.738Z',
errors=[],
warnings=[],
starts_at='2025-01-01T16:00:00.000Z',
ends_at='2025-01-22T12:00:00.000Z',
name='my time-bound code',
status='unset',
common_code_key=None,
is_managed=True,
is_waiting_for_code_assignment=None,
is_scheduled_on_device=False,
pulled_backup_access_code_id=None,
is_backup_access_code_available=False,
is_backup=None,
appearance=None,
is_external_modification_allowed=False)
Creating an Access Code with a Preferred Code Length
Request:
seam.access_codes.create(
device = "6aae9d08-fed6-4ca5-8328-e36849ab48fe",
name = "my access code",
starts_at = "2025-01-01T16:00:00Z",
ends_at = "2025-01-22T12:00:00Z",
preferred_code_length = 4
)
Response:
AccessCode(access_code_id='1bbd1eba-e4a2-4f96-b1b9-8498a5405b2b',
device_id='6aae9d08-fed6-4ca5-8328-e36849ab48fe',
type='time_bound',
code='2345',
created_at='2023-10-19T02:21:58.738Z',
errors=[],
warnings=[],
starts_at='2025-01-01T16:00:00.000Z',
ends_at='2025-01-22T12:00:00.000Z',
name='my access code',
status='unset',
common_code_key=None,
is_managed=True,
is_waiting_for_code_assignment=None,
is_scheduled_on_device=False,
pulled_backup_access_code_id=None,
is_backup_access_code_available=False,
is_backup=None,
appearance=None,
is_external_modification_allowed=False)
Creating an Time-Bound Offline Access Code
Request:
device_id = "9689dc30-77d8-4728-9968-b3abd0835f47"
created_access_code = seam.access_codes.create(
device = device_id,
name = "my time-bound offline code",
starts_at = "2023-11-10T00:00:00-00:00",
ends_at = "2023-11-15T18:00:00-00:00",
is_offline_access_code = True
)
pprint(created_access_code)
Response:
AccessCode(access_code_id='f078dce8-3c5e-4bc4-bd08-3ad013ee8be6',
device_id='9689dc30-77d8-4728-9968-b3abd0835f47',
type='time_bound',
code=None,
created_at='2023-11-07T03:51:56.096Z',
errors=[],
warnings=[],
starts_at='2023-11-10T00:00:00.000Z',
ends_at='2023-11-15T18:00:00.000Z',
name='my time-bound offline code',
status='unset',
common_code_key=None,
is_managed=True,
is_waiting_for_code_assignment=True,
is_scheduled_on_device=False,
pulled_backup_access_code_id=None,
is_backup_access_code_available=False,
is_backup=None,
appearance=None,
is_external_modification_allowed=False,
is_offline_access_code=True,
is_one_time_use=False)
Creating a Daily-Bound Offline Access Code
Request:
device_id = "9689dc30-77d8-4728-9968-b3abd0835f47"
created_access_code = seam.access_codes.create(
device = device_id,
name = "my daily-bound offline code",
starts_at = "2023-11-17T00:00:00-00:00",
ends_at = "2023-12-18T00:00:00-00:00",
max_time_rounding = "1d",
is_offline_access_code = True
)
pprint(created_access_code)
Response:
AccessCode(access_code_id='7cac9c2c-4313-4a94-a034-ceee2a4bd9ef',
device_id='9689dc30-77d8-4728-9968-b3abd0835f47',
type='time_bound',
code=None,
created_at='2023-11-07T04:38:45.865Z',
errors=[],
warnings=[],
starts_at='2023-11-17T00:00:00.000Z',
ends_at='2023-12-18T00:00:00.000Z',
name='my daily-bound offline code',
status='unset',
common_code_key=None,
is_managed=True,
is_waiting_for_code_assignment=True,
is_scheduled_on_device=False,
pulled_backup_access_code_id=None,
is_backup_access_code_available=False,
is_backup=None,
appearance=None,
is_external_modification_allowed=False,
is_offline_access_code=True,
is_one_time_use=False)
Creating a One-Time-Use Offline Access Code
Request:
device_id = "9689dc30-77d8-4728-9968-b3abd0835f47"
created_access_code = seam.access_codes.create(
device = device_id,
name = "my one-time-use offline code",
starts_at = "2023-11-12T00:00:00-00:00",
is_offline_access_code = True,
is_one_time_use = True
)
pprint(created_access_code)
Response:
AccessCode(access_code_id='995957b0-5db5-43f2-ac64-e8ad076c09cf',
device_id='9689dc30-77d8-4728-9968-b3abd0835f47',
type='time_bound',
code=None,
created_at='2023-11-07T05:03:31.469Z',
errors=[],
warnings=[],
starts_at='2023-11-12T00:00:00.000Z',
ends_at=None,
name='my one-time-use offline code',
status='unset',
common_code_key=None,
is_managed=True,
is_waiting_for_code_assignment=True,
is_scheduled_on_device=False,
pulled_backup_access_code_id=None,
is_backup_access_code_available=False,
is_backup=None,
appearance=None,
is_external_modification_allowed=False,
is_offline_access_code=True,
is_one_time_use=True)
Parameters
device_id
String
ID of the device.
name
String Optional
Name of the access code.
starts_at
String Optional
Timestamp to indicate from when is the access code is valid.
ends_at
String Optional
Timestamp to indicate the code expiry time.
Must be a timestamp in the future and after starts_at
.
code
String Optional
Access code.
use_backup_access_code_pool
Boolean Optional
Indicated whether to use a backup access code pool provided by Seam.
This enables you to use /access_codes/pull_backup_access_code
common_code_key
String Optional
Key to identify access codes that should have the same code.
Any two access codes with the same common_code_key
are guaranteed to have the same code.
prefer_native_scheduling
Boolean Optional
Indicates whether native scheduling should be used for time-bound codes when supported by the provider.
Default: true
.
allow_external_modification
Boolean Optional
Indicates whether external modification of the codes is allowed.
Default: false
.
is_one_time_use
Boolean Optional
Indicates whether the offline access code is a single-use access code.
preferred_code_length
Number Optional
Preferred code length.
Only applicable if you do not specify a code
.
If the affected device does not support the preferred code length, Seam reverts to using the shortest supported code length.
Response
This section shows the JSON response returned by the API. Since each language encapsulates this response inside objects specific to that language and/or implementation, the actual type in your language might differ from what’s written here.
JSON format
{
"action_attempt": {
"status": "pending",
"action_type": "CREATE_ACCESS_CODE",
"action_attempt_id": "c10e3db5-a5a2-47f2-a76f-48379ed9cd22",
"result": null,
"error": null
},
"access_code": {
"access_code_id": "12525e70-9474-4bb6-a7f6-12bbe4166f36",
"device_id": "1c459b4c-0008-4752-befc-bc18521247d4",
"name": "My code",
"code": "1988",
"common_code_key": null,
"type": "ongoing",
"status": "setting",
"created_at": "2023-05-11T11:16:10.359Z",
"errors": [],
"warnings": [],
"is_managed": true,
"is_external_modification_allowed": false,
"is_offline_access_code": false,
"is_one_time_use": false
},
"ok": true
}
Last updated
Was this helpful?