Create an Access Code
Create an Access Code for a Device by its ID
Code Examples
Create an Access Code
POST
https://connect.getseam.com/access_codes/create
Headers
Authorization*
String
Bearer <API_KEY>
Request Body
device_id*
String
Device ID
name
String
Name of the Access Code
starts_at
ISO8601 string
Start Time of the Access Code
ends_at
ISO8601 string
End Time of the Access Code
code
string
Pin code to be programmed.
prefer_native_scheduling
boolean
Whether native scheduling should be used for time-bound codes if supported by the provider. Defaults to true.
sync
boolean
Set this to true to receive the
access_code
object in the
result
{
"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
},
"ok": true
}
Creating an Ongoing Access Code
seam.access_codes.create(
device_id: "123e4567-e89b-12d3-a456-426614174000",
name: 'My first code'
)
# <Seam::AccessCode:0x007cd58
# code="669781"
# name="My first code"
# type="ongoing"
# created_at="2022-07-06T23:26:42.223Z"
# access_code_id="f19bc8cb-15be-43af-bb52-f1a417e0ff09">
Creating a Time Bound Access Code
access_code = seam.access_codes.create(
device_id: "123e4567-e89b-12d3-a456-426614174000",
name: 'My first code',
starts_at: "2022-08-12T19:23:42+0000",
ends_at: "2022-08-13T19:23:42+0000"
)
puts access_code
# <Seam::AccessCode:0x007cd58
# code="669781"
# name="My first code"
# type="timebound"
# starts_at="2022-08-12T19:23:42+0000"
# ends_at="2022-08-13T19:23:42+0000"
# created_at="2022-07-06T23:26:42.223Z"
# access_code_id="f19bc8cb-15be-43af-bb52-f1a417e0ff09">
Parameters
device_id
type: string
ID of the Device
name
type: string Optional
Name of Access Code
starts_at
type: string Optional
From when is the code valid
ends_at
type: string Optional
Code expiry
code
type: string Optional
Access code of Device
common_code_key
type: string Optional
any two access codes with the same common_code_key
are guaranteed to have the same code
prefer_native_scheduling
type: string Optional
Whether native scheduling should be used for time-bound codes when supported by the provider (defaults to true)
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
},
"ok": true
}
Last updated
Was this helpful?