|
| 1 | +# Create an Access Code |
| 2 | + |
| 3 | +``` |
| 4 | +POST /access_codes/create ⇒ { access_code } |
| 5 | +``` |
| 6 | + |
| 7 | +Creates a new [access code](https://docs.seam.co/latest/capability-guides/smart-locks/access-codes). |
| 8 | + |
| 9 | +## Authentication Methods |
| 10 | + |
| 11 | +- API key |
| 12 | +- Client session token |
| 13 | +- Personal access token |
| 14 | + <br>Must also include the `seam-workspace` header in the request. |
| 15 | + |
| 16 | +## Request Parameters |
| 17 | + |
| 18 | +### `device_id` |
| 19 | + |
| 20 | +Format: `UUID` |
| 21 | +Required: Yes |
| 22 | + |
| 23 | +ID of the device for which to create the new access code. |
| 24 | + |
| 25 | +*** |
| 26 | + |
| 27 | +### `allow_external_modification` |
| 28 | + |
| 29 | +Format: `Boolean` |
| 30 | +Required: No |
| 31 | + |
| 32 | +Indicates whether [external modification](https://docs.seam.co/latest/api/access_codes#external-modification) of the code is allowed. Default: `false`. |
| 33 | + |
| 34 | +*** |
| 35 | + |
| 36 | +### `attempt_for_offline_device` |
| 37 | + |
| 38 | +Format: `Boolean` |
| 39 | +Required: No |
| 40 | + |
| 41 | +*** |
| 42 | + |
| 43 | +### `code` |
| 44 | + |
| 45 | +Format: `String` |
| 46 | +Required: No |
| 47 | + |
| 48 | +Code to be used for access. |
| 49 | + |
| 50 | +*** |
| 51 | + |
| 52 | +### `common_code_key` |
| 53 | + |
| 54 | +Format: `String` |
| 55 | +Required: No |
| 56 | + |
| 57 | +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](../../capability-guides/smart-locks/access-codes/creating-and-updating-multiple-linked-access-codes.md). |
| 58 | + |
| 59 | +*** |
| 60 | + |
| 61 | +### `ends_at` |
| 62 | + |
| 63 | +Format: `String` |
| 64 | +Required: No |
| 65 | + |
| 66 | +Date and time at which the validity of the new access code ends, in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Must be a time in the future and after `starts_at`. |
| 67 | + |
| 68 | +*** |
| 69 | + |
| 70 | +### `is_external_modification_allowed` |
| 71 | + |
| 72 | +Format: `Boolean` |
| 73 | +Required: No |
| 74 | + |
| 75 | +Indicates whether [external modification](https://docs.seam.co/latest/api/access_codes#external-modification) of the code is allowed. Default: `false`. |
| 76 | + |
| 77 | +*** |
| 78 | + |
| 79 | +### `is_offline_access_code` |
| 80 | + |
| 81 | +Format: `Boolean` |
| 82 | +Required: No |
| 83 | + |
| 84 | +Indicates whether the access code is an [offline access code](https://docs.seam.co/latest/capability-guides/smart-locks/access-codes/offline-access-codes). |
| 85 | + |
| 86 | +*** |
| 87 | + |
| 88 | +### `is_one_time_use` |
| 89 | + |
| 90 | +Format: `Boolean` |
| 91 | +Required: No |
| 92 | + |
| 93 | +Indicates whether the [offline access code](https://docs.seam.co/latest/capability-guides/smart-locks/access-codes/offline-access-codes) is a single-use access code. |
| 94 | + |
| 95 | +*** |
| 96 | + |
| 97 | +### `max_time_rounding` |
| 98 | + |
| 99 | +Format: `Enum` |
| 100 | +Required: No |
| 101 | + |
| 102 | +Maximum rounding adjustment. To create a daily-bound [offline access code](https://docs.seam.co/latest/capability-guides/smart-locks/access-codes/offline-access-codes) for devices that support this feature, set this parameter to `1d`. |
| 103 | + |
| 104 | +Possible enum values: |
| 105 | +- `1hour` |
| 106 | +- `1day` |
| 107 | +- `1h` |
| 108 | +- `1d` |
| 109 | + |
| 110 | +*** |
| 111 | + |
| 112 | +### `name` |
| 113 | + |
| 114 | +Format: `String` |
| 115 | +Required: No |
| 116 | + |
| 117 | +Name of the new access code. |
| 118 | + |
| 119 | +*** |
| 120 | + |
| 121 | +### `prefer_native_scheduling` |
| 122 | + |
| 123 | +Format: `Boolean` |
| 124 | +Required: No |
| 125 | + |
| 126 | +Indicates whether [native scheduling](https://docs.seam.co/latest/capability-guides/smart-locks/access-codes#native-scheduling) should be used for time-bound codes when supported by the provider. Default: `true`. |
| 127 | + |
| 128 | +*** |
| 129 | + |
| 130 | +### `preferred_code_length` |
| 131 | + |
| 132 | +Format: `Number` |
| 133 | +Required: No |
| 134 | + |
| 135 | +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. |
| 136 | + |
| 137 | +*** |
| 138 | + |
| 139 | +### `starts_at` |
| 140 | + |
| 141 | +Format: `String` |
| 142 | +Required: No |
| 143 | + |
| 144 | +Date and time at which the validity of the new access code starts, in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. |
| 145 | + |
| 146 | +*** |
| 147 | + |
| 148 | +### `use_backup_access_code_pool` |
| 149 | + |
| 150 | +Format: `Boolean` |
| 151 | +Required: No |
| 152 | + |
| 153 | +Indicates whether to use a [backup access code pool](https://docs.seam.co/latest/core-concepts/access-codes#backup-access-codes) provided by Seam. If `true`, you can use [`/access_codes/pull_backup_access_code`](../../api-clients/access_codes/pull_backup_access_code.md). |
| 154 | + |
| 155 | +*** |
| 156 | + |
| 157 | +### `use_offline_access_code` |
| 158 | + |
| 159 | +Format: `Boolean` |
| 160 | +Required: No |
| 161 | + |
| 162 | +*** |
| 163 | + |
| 164 | +## Return Type |
| 165 | + |
| 166 | +[access\_code](./) |
| 167 | + |
| 168 | +### `CREATE_ACCESS_CODE` |
| 169 | + |
| 170 | +#### `action_attempt_id` |
| 171 | + |
| 172 | +Format: `UUID` |
| 173 | + |
| 174 | +ID of the action attempt. |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +#### `action_type` |
| 179 | + |
| 180 | +Format: `Enum` |
| 181 | + |
| 182 | +Value: `CREATE_ACCESS_CODE` |
| 183 | + |
| 184 | +--- |
| 185 | + |
| 186 | +#### `error` |
| 187 | + |
| 188 | +Format: `Object` |
| 189 | + |
| 190 | +<details> |
| 191 | + |
| 192 | +<summary><code>message</code> Format: <code>String</code></summary> |
| 193 | +</details> |
| 194 | + |
| 195 | +<details> |
| 196 | + |
| 197 | +<summary><code>type</code> Format: <code>String</code></summary> |
| 198 | +</details> |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +#### `result` |
| 203 | + |
| 204 | +Format: `Object` |
| 205 | + |
| 206 | +This object has no properties. |
| 207 | + |
| 208 | +--- |
| 209 | + |
| 210 | +#### `status` |
| 211 | + |
| 212 | +Format: `Enum` |
| 213 | + |
| 214 | +Possible enum values: |
| 215 | +- `success` |
| 216 | +- `pending` |
| 217 | +- `error` |
| 218 | + |
| 219 | +--- |
| 220 | + |
0 commit comments