Create Many Access Codes

Create access codes across multiple devices that share a common code

/access_codes/create_multiple

POSThttps://connect.getseam.com/access_codes/create_multiple
Authorization
Body
device_ids*array of string (uuid)
behavior_when_code_cannot_be_sharedenum
throwcreate_random_code
namestring
starts_atstring
ends_atstring
attempt_for_offline_deviceboolean
Response

OK

Request
const response = await fetch('https://connect.getseam.com/access_codes/create_multiple', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer API token",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "device_ids": [
        "123e4567-e89b-12d3-a456-426614174000"
      ]
    }),
});
const data = await response.json();

Code Example

await seam.accessCodes.createMultiple({
    device_id: [
      "a83690b2-2b70-409a-9a94-426699b84c97", 
      "7bfe1838-5e64-432c-adb6-34e971bda001"
    ],
    preferred_code_length: 4
});

/*
[
  {
    code: '9913',
    type: 'ongoing',
    status: 'setting',
    created_at: '2022-08-26T11:08:24.161Z',
    access_code_id: 'e0e31756-9385-408b-89f8-9f5ea43f9adf',
    device_id: 'a83690b2-2b70-409a-9a94-426699b84c97',
    common_code_key: 'auto_set_by_create_multiple_996c8131-34a4-4d58-86c4-7820f2ccdefb',    
  },
  {
    code: '9913',
    type: 'ongoing',
    status: 'setting',
    created_at: '2022-08-26T11:08:24.161Z',
    access_code_id: 'f3a89135-1101-4197-b272-4b4c5ed092b5',
    device_id: '7bfe1838-5e64-432c-adb6-34e971bda001',
    common_code_key: 'auto_set_by_create_multiple_996c8131-34a4-4d58-86c4-7820f2ccdefb',    
  }
]
*/

Parameters

device_ids

type: string[]

ID of the Device

name

type: string Optional

Name of Access Codes

starts_at

type: string Optional

From when is the code valid

ends_at

type: string Optional

Code expiry

behavior_when_code_cannot_be_shared

type: enum Optional, default throw

If throw, no access codes will be created if any device cannot share a code. If create_random_code, a random code will be created on devices that cannot share a code.

preferred_code_length

type: number Optional

Preferred code length If the affected devices do 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

{
  "access_codes": [
    {
      "code": "9913",
      "type": "ongoing",
      "status": "setting",
      "created_at": "2022-08-26T11:08:24.161Z",
      "access_code_id": "e0e31756-9385-408b-89f8-9f5ea43f9adf",
      "device_id": "a83690b2-2b70-409a-9a94-426699b84c97",
      "common_code_key": "auto_set_by_create_multiple_996c8131-34a4-4d58-86c4-7820f2ccdefb",    
    },
    {
      "code": "9913",
      "type": "ongoing",
      "status": "setting",
      "created_at": "2022-08-26T11:08:24.161Z",
      "access_code_id": "f3a89135-1101-4197-b272-4b4c5ed092b5",
      "device_id": "7bfe1838-5e64-432c-adb6-34e971bda001",
      "common_code_key": "auto_set_by_create_multiple_996c8131-34a4-4d58-86c4-7820f2ccdefb",    
    }
  ],
  "ok": true
}

Last updated

Logo

© Seam Labs, Inc. All rights reserved.