Docs / iglooworks / BLE SDK / PIN Management
PIN Management
Create and delete custom PINs on Igloohome locks.
createPin
Creates a custom PIN on the lock via Bluetooth and registers it on the server. The SDK writes the PIN to lock hardware first, then registers on the server. If server registration fails, the SDK automatically deletes the PIN from the lock.
Signature
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
deviceId |
String |
Yes | Bluetooth device name of the lock. |
key |
String |
Yes | Guest key with CREATE_PIN permission. |
pin |
String |
Yes | PIN code (numeric, 1–12 digits). |
pinType |
PinType |
Yes | PIN type: ONETIME, PERMANENT, or DURATION. |
name |
String |
Yes | User-assigned name for the PIN. |
startTimeInSeconds |
Long? |
Duration only | Start time in epoch seconds. Required for DURATION type. |
endTimeInSeconds |
Long? |
Duration only | End time in epoch seconds. Required for DURATION type. |
accessToken |
String? |
OAuth only | OAuth access token for server calls. |
Supporting Types
Return Type
Error Codes
| Exception | Code | Description |
|---|---|---|
BluetoothException |
708 | Bluetooth is off or unavailable. |
ConnectionException |
12 | Device disconnected during PIN creation. |
TimeoutException |
703 | BLE operation exceeded the timeout. |
DuplicatePinException |
880 | PIN already exists on the lock. |
LockStorageFullException |
912 | No storage for more PINs on the lock. |
ApiException |
varies | Server registration failed (PIN rolled back from lock). |
Example
Notes
- On iOS, passing
pinType: .durationwithout bothstartDateandendDatethrowsIglooworksError.genericErrorimmediately, before any Bluetooth command is sent.
deletePin
Deletes a PIN from the lock and removes the server record.
The SDK fetches the PIN value from the server, removes it from lock hardware via BLE, then deletes the server record. If the PIN is already removed from the lock (BLE error 890), the SDK still deletes the server record.
Signature
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
deviceId |
String |
Yes | Bluetooth device name of the lock. |
key |
String |
Yes | Guest key with DELETE_PIN permission. |
accessId |
String |
Yes | Server-assigned access ID of the PIN to delete. |
accessToken |
String? |
OAuth only | OAuth access token for server calls. |
Error Codes
| Exception | Code | Description |
|---|---|---|
BluetoothException |
708 | Bluetooth is off or unavailable. |
ConnectionException |
12 | Device disconnected during deletion. |
TimeoutException |
703 | BLE operation exceeded the timeout. |
ApiException |
varies | Server deletion failed. |
Example
Notes
- Server deletion retries up to 3 times with 1-second delays on failure.
PinNotFoundException(890, Android) /IglooworksError.pinNotFound(iOS) during BLE delete is treated as non-fatal — the SDK continues to delete the server record.