

# Access API Reference

API endpoints for managing access.

## AlgoPIN

### Create a Daily AlgoPIN

`POST` `https://api.igloohome.co/home/devices/{deviceId}/algopin/daily`

Returns a duration (Daily) AlgoPIN code.

Allowable Range: 29 to 367 days (in days only, 29.5 days not allowed)

#### Path Parameters

| Parameter | Type | Required |
| --- | --- | --- |
| deviceId | string | Yes |

#### Body Parameters

Content-Type: `application/json`

- **`variance`** `integer` *required*
  - Allowed values: `1`, `2`, `3`
- **`startDate`** `string<date-time>` *required*\
  Date and time when the permission starts. Must be in format `YYYY-MM-DDTHH:00:00+hh:mm` (hour resolution only). **Note: The hour ('hh') on startDate and the hour ('hh') on endDate must match**
  - Example: `2022-01-01T12:00:00+08:00`
- **`endDate`** `string<date-time>` *required*\
  Date and time when the permission ends. Must be in format `YYYY-MM-DDTHH:00:00+hh:mm` (hour resolution only). **Note: The hour ('hh') on startDate and the hour ('hh') on endDate must match**
  - Example: `2022-05-01T12:00:00+08:00`
- **`accessName`** `string` *required*\
  Name or short description of the access
  - Example: `Maintenance guy`

#### Request Example

```bash
curl -X POST "https://api.igloohome.co/home/devices/{deviceId}/algopin/daily" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "accessName": "value",
    "endDate": "value",
    "startDate": "value",
    "variance": "value"
  }'
```

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/devices/{deviceId}/algopin/daily"
	payload := []byte(`{
		"accessName": "value",
		"endDate": "value",
		"startDate": "value",
		"variance": "value"
	}`)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/devices/{deviceId}/algopin/daily", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "accessName": "value",
    "endDate": "value",
    "startDate": "value",
    "variance": "value"
  })
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/devices/{deviceId}/algopin/daily"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
payload = {
    "accessName": "value",
    "endDate": "value",
    "startDate": "value",
    "variance": "value"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/devices/{deviceId}/algopin/daily",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "accessName" => "value",
        "endDate" => "value",
        "startDate" => "value",
        "variance" => "value"
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val mediaType = "application/json".toMediaType()
val body = """
    {
        "accessName": "value",
        "endDate": "value",
        "startDate": "value",
        "variance": "value"
    }
""".trimIndent().toRequestBody(mediaType)

val request = Request.Builder()
    .url("https://api.igloohome.co/home/devices/{deviceId}/algopin/daily")
    .method("POST", body)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .addHeader("Content-Type", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/devices/{deviceId}/algopin/daily")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = [
    "accessName": "value",
    "endDate": "value",
    "startDate": "value",
    "variance": "value"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`200 OK`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`403 Forbidden, accessToken scope must contain 'igloohomeapi/algopin-daily'`
`404 '{ message: 'not found device' }'`
`409 Conflict. The device's property record is missing a timezone (data integrity guard).`
`415 Unsupported Media Type`
`418 '{ error: 'this device type does not support the feature.' }'. The device SKU does not support AlgoPIN codes.`
`500 Internal Server Error`

**Response body — `200`:**

- **`pin`** `string`
  - Example: `4642226`
- **`pinId`** `string`
  - Example: `CC0035C33E9B103A`

**Response body — `400`:**

- **`error`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`

**Response body — `409`:**

- **`message`** `string`

**Response body — `418`:**

- **`error`** `string`

**Example response — `200`:**

```json
{
  "pin": "7541869",
  "pinId": "EE4421C77G9F512D"
}
```

**Example response — `400`:**

```json
{
  "error": "'accessName' is required"
}
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "not found device"
}
```

**Example response — `409`:**

```json
{
  "message": "timezone is not found on property"
}
```

**Example response — `418`:**

```json
{
  "error": "this device type does not support the feature."
}
```

### Create an Hourly AlgoPIN

`POST` `https://api.igloohome.co/home/devices/{deviceId}/algopin/hourly`

Returns a duration (Hourly) AlgoPIN code.

Allowable Range: 1 to 672 hours

#### Path Parameters

| Parameter | Type | Required |
| --- | --- | --- |
| deviceId | string | Yes |

#### Body Parameters

Content-Type: `application/json`

- **`variance`** `integer` *required*
  - Allowed values: `1`, `2`, `3`
- **`startDate`** `string<date-time>` *required*\
  Date and time when the permission starts. Must be in format `YYYY-MM-DDTHH:00:00+hh:mm` (hour resolution only). May be up to 1 hour in the past.
  - Example: `2022-01-01T14:00:00+08:00`
- **`endDate`** `string<date-time>` *required*\
  Date and time when the permission ends. Must be in format `YYYY-MM-DDTHH:00:00+hh:mm` (hour resolution only). **Maximum Value: startDate + 672 hours**
  - Example: `2022-01-02T12:00:00+08:00`
- **`accessName`** `string` *required*\
  Name or short description of the access
  - Example: `Maintenance guy`

#### Request Example

```bash
curl -X POST "https://api.igloohome.co/home/devices/{deviceId}/algopin/hourly" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "accessName": "value",
    "endDate": "value",
    "startDate": "value",
    "variance": "value"
  }'
```

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/devices/{deviceId}/algopin/hourly"
	payload := []byte(`{
		"accessName": "value",
		"endDate": "value",
		"startDate": "value",
		"variance": "value"
	}`)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/devices/{deviceId}/algopin/hourly", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "accessName": "value",
    "endDate": "value",
    "startDate": "value",
    "variance": "value"
  })
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/devices/{deviceId}/algopin/hourly"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
payload = {
    "accessName": "value",
    "endDate": "value",
    "startDate": "value",
    "variance": "value"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/devices/{deviceId}/algopin/hourly",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "accessName" => "value",
        "endDate" => "value",
        "startDate" => "value",
        "variance" => "value"
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val mediaType = "application/json".toMediaType()
val body = """
    {
        "accessName": "value",
        "endDate": "value",
        "startDate": "value",
        "variance": "value"
    }
""".trimIndent().toRequestBody(mediaType)

val request = Request.Builder()
    .url("https://api.igloohome.co/home/devices/{deviceId}/algopin/hourly")
    .method("POST", body)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .addHeader("Content-Type", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/devices/{deviceId}/algopin/hourly")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = [
    "accessName": "value",
    "endDate": "value",
    "startDate": "value",
    "variance": "value"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`200 OK`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`403 Forbidden, accessToken scope must contain 'igloohomeapi/algopin-hourly'`
`404 '{ message: 'not found device' }'`
`409 Conflict. The device's property record is missing a timezone (data integrity guard).`
`415 Unsupported Media Type`
`418 '{ error: 'this device type does not support the feature.' }'. The device SKU does not support AlgoPIN codes.`
`500 Internal Server Error`

**Response body — `200`:**

- **`pin`** `string`
  - Example: `4642226`
- **`pinId`** `string`
  - Example: `CC0035C33E9B103A`

**Response body — `400`:**

- **`error`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`

**Response body — `409`:**

- **`message`** `string`

**Response body — `418`:**

- **`error`** `string`

**Example response — `200`:**

```json
{
  "pin": "5729314",
  "pinId": "AA9876B22D5E405C"
}
```

**Example response — `400`:**

```json
{
  "error": "'accessName' is required"
}
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "not found device"
}
```

**Example response — `409`:**

```json
{
  "message": "timezone is not found on property"
}
```

**Example response — `418`:**

```json
{
  "error": "this device type does not support the feature."
}
```

### Create a One-Time AlgoPIN

`POST` `https://api.igloohome.co/home/devices/{deviceId}/algopin/onetime`

Returns a one-time AlgoPIN code (OTP).

#### Path Parameters

| Parameter | Type | Required |
| --- | --- | --- |
| deviceId | string | Yes |

#### Body Parameters

Content-Type: `application/json`

- **`variance`** `integer` *required*\
  1–10. Values 6–10 require newer lock firmware; some older locks support them after a firmware update, otherwise they accept 1–5.
- **`startDate`** `string<date-time>` *required*\
  Must be in format `YYYY-MM-DDTHH:00:00+hh:mm` (hour resolution only) and now or later.
  - Example: `2022-01-01T00:00:00+08:00`
- **`accessName`** `string` *required*
  - Example: `Maintenance guy`

#### Request Example

```bash
curl -X POST "https://api.igloohome.co/home/devices/{deviceId}/algopin/onetime" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "accessName": "value",
    "startDate": "value",
    "variance": "value"
  }'
```

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/devices/{deviceId}/algopin/onetime"
	payload := []byte(`{
		"accessName": "value",
		"startDate": "value",
		"variance": "value"
	}`)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/devices/{deviceId}/algopin/onetime", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "accessName": "value",
    "startDate": "value",
    "variance": "value"
  })
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/devices/{deviceId}/algopin/onetime"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
payload = {
    "accessName": "value",
    "startDate": "value",
    "variance": "value"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/devices/{deviceId}/algopin/onetime",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "accessName" => "value",
        "startDate" => "value",
        "variance" => "value"
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val mediaType = "application/json".toMediaType()
val body = """
    {
        "accessName": "value",
        "startDate": "value",
        "variance": "value"
    }
""".trimIndent().toRequestBody(mediaType)

val request = Request.Builder()
    .url("https://api.igloohome.co/home/devices/{deviceId}/algopin/onetime")
    .method("POST", body)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .addHeader("Content-Type", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/devices/{deviceId}/algopin/onetime")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = [
    "accessName": "value",
    "startDate": "value",
    "variance": "value"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`200 OK`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`403 Forbidden, accessToken scope must contain 'igloohomeapi/algopin-onetime'`
`404 '{ message: 'not found device' }'`
`409 Conflict. The device's property record is missing a timezone (data integrity guard).`
`415 Unsupported Media Type`
`418 '{ error: 'this device type does not support the feature.' }'. The device SKU does not support AlgoPIN codes.`
`500 Internal Server Error`

**Response body — `200`:**

- **`pin`** `string`
  - Example: `4642226`
- **`pinId`** `string`
  - Example: `CC0035C33E9B103A`

**Response body — `400`:**

- **`error`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`

**Response body — `409`:**

- **`message`** `string`

**Response body — `418`:**

- **`error`** `string`

**Example response — `200`:**

```json
{
  "pin": "4642226",
  "pinId": "CC0035C33E9B103A"
}
```

**Example response — `400`:**

```json
{
  "error": "'accessName' is required"
}
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "not found device"
}
```

**Example response — `409`:**

```json
{
  "message": "timezone is not found on property"
}
```

**Example response — `418`:**

```json
{
  "error": "this device type does not support the feature."
}
```

### Create a Passage AlgoPIN

`POST` `https://api.igloohome.co/home/devices/{deviceId}/algopin/passage`

Allows unlock with AlgoPIN and keeps the lock unlocked for the duration given in the request body. Supports newer devices with the latest firmware only.

#### Path Parameters

| Parameter | Type | Required |
| --- | --- | --- |
| deviceId | string | Yes |

#### Body Parameters

Content-Type: `application/json`

- **`variance`** `integer` *required*
  - Allowed values: `1`
- **`startDate`** `string<date-time>` *required*\
  Date and time when the permission starts. Must be in format `YYYY-MM-DDTHH:00:00+hh:mm` (hour resolution only). The PIN is valid from `startDate` for `durationHours` hours.
  - Example: `2022-01-01T12:00:00+08:00`
- **`durationHours`** `integer` *required*\
  Must be between 1 and 12 hours
- **`accessName`** `string` *required*\
  Name or short description of the access
  - Example: `Maintenance guy`

#### Request Example

```bash
curl -X POST "https://api.igloohome.co/home/devices/{deviceId}/algopin/passage" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "accessName": "value",
    "durationHours": "value",
    "startDate": "value",
    "variance": "value"
  }'
```

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/devices/{deviceId}/algopin/passage"
	payload := []byte(`{
		"accessName": "value",
		"durationHours": "value",
		"startDate": "value",
		"variance": "value"
	}`)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/devices/{deviceId}/algopin/passage", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "accessName": "value",
    "durationHours": "value",
    "startDate": "value",
    "variance": "value"
  })
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/devices/{deviceId}/algopin/passage"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
payload = {
    "accessName": "value",
    "durationHours": "value",
    "startDate": "value",
    "variance": "value"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/devices/{deviceId}/algopin/passage",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "accessName" => "value",
        "durationHours" => "value",
        "startDate" => "value",
        "variance" => "value"
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val mediaType = "application/json".toMediaType()
val body = """
    {
        "accessName": "value",
        "durationHours": "value",
        "startDate": "value",
        "variance": "value"
    }
""".trimIndent().toRequestBody(mediaType)

val request = Request.Builder()
    .url("https://api.igloohome.co/home/devices/{deviceId}/algopin/passage")
    .method("POST", body)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .addHeader("Content-Type", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/devices/{deviceId}/algopin/passage")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = [
    "accessName": "value",
    "durationHours": "value",
    "startDate": "value",
    "variance": "value"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`200 OK`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`404 '{ message: 'not found device' }'`
`409 Conflict. The device's property record is missing a timezone (data integrity guard).`
`415 Unsupported Media Type`
`422 '{ error: 'this device does not support passage PIN' }'. The device does not support passage AlgoPIN codes.`
`500 Internal Server Error`

**Response body — `200`:**

- **`pin`** `string`
  - Example: `4642226`
- **`pinId`** `string`
  - Example: `CC0035C33E9B103A`

**Response body — `400`:**

- **`error`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`

**Response body — `409`:**

- **`message`** `string`

**Response body — `422`:**

- **`error`** `string`

**Example response — `200`:**

```json
{
  "pin": "7541869",
  "pinId": "EE4421C77G9F512D"
}
```

**Example response — `400`:**

```json
{
  "error": "'accessName' is required"
}
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "not found device"
}
```

**Example response — `409`:**

```json
{
  "message": "timezone is not found on property"
}
```

**Example response — `422`:**

```json
{
  "error": "this device does not support passage PIN"
}
```

### Create a Permanent AlgoPIN

`POST` `https://api.igloohome.co/home/devices/{deviceId}/algopin/permanent`

Returns a permanent AlgoPIN code.

#### Path Parameters

| Parameter | Type | Required |
| --- | --- | --- |
| deviceId | string | Yes |

#### Body Parameters

Content-Type: `application/json`

- **`variance`** `integer` *required*\
  1–10. Values 6–10 require newer lock firmware; some older locks support them after a firmware update, otherwise they accept 1–5.
- **`startDate`** `string<date-time>` *required*\
  Must be in format `YYYY-MM-DDTHH:00:00+hh:mm` (hour resolution only) and now or later.
  - Example: `2022-01-01T00:00:00+08:00`
- **`accessName`** `string` *required*
  - Example: `Maintenance guy`

#### Request Example

```bash
curl -X POST "https://api.igloohome.co/home/devices/{deviceId}/algopin/permanent" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "accessName": "value",
    "startDate": "value",
    "variance": "value"
  }'
```

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/devices/{deviceId}/algopin/permanent"
	payload := []byte(`{
		"accessName": "value",
		"startDate": "value",
		"variance": "value"
	}`)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/devices/{deviceId}/algopin/permanent", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "accessName": "value",
    "startDate": "value",
    "variance": "value"
  })
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/devices/{deviceId}/algopin/permanent"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
payload = {
    "accessName": "value",
    "startDate": "value",
    "variance": "value"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/devices/{deviceId}/algopin/permanent",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "accessName" => "value",
        "startDate" => "value",
        "variance" => "value"
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val mediaType = "application/json".toMediaType()
val body = """
    {
        "accessName": "value",
        "startDate": "value",
        "variance": "value"
    }
""".trimIndent().toRequestBody(mediaType)

val request = Request.Builder()
    .url("https://api.igloohome.co/home/devices/{deviceId}/algopin/permanent")
    .method("POST", body)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .addHeader("Content-Type", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/devices/{deviceId}/algopin/permanent")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = [
    "accessName": "value",
    "startDate": "value",
    "variance": "value"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`200 OK`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`403 Forbidden, accessToken scope must contain 'igloohomeapi/algopin-permanent'`
`404 '{ message: 'not found device' }'`
`409 Conflict. The device's property record is missing a timezone (data integrity guard).`
`415 Unsupported Media Type`
`418 '{ error: 'this device type does not support the feature.' }'. The device SKU does not support AlgoPIN codes.`
`500 Internal Server Error`

**Response body — `200`:**

- **`pin`** `string`
  - Example: `4642226`
- **`pinId`** `string`
  - Example: `CC0035C33E9B103A`

**Response body — `400`:**

- **`error`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`

**Response body — `409`:**

- **`message`** `string`

**Response body — `418`:**

- **`error`** `string`

**Example response — `200`:**

```json
{
  "pin": "8137492",
  "pinId": "DD1246E44F0C214B"
}
```

**Example response — `400`:**

```json
{
  "error": "'accessName' is required"
}
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "not found device"
}
```

**Example response — `409`:**

```json
{
  "message": "timezone is not found on property"
}
```

**Example response — `418`:**

```json
{
  "error": "this device type does not support the feature."
}
```

## eKey

### Generate eKey

`POST` `https://api.igloohome.co/home/devices/{deviceId}/ekey`

Create an eKey.

#### Path Parameters

| Parameter | Type | Required |
| --- | --- | --- |
| deviceId | string | Yes |

#### Body Parameters

Content-Type: `application/json`

- **`startDate`** `string<date-time>` *required*\
  User is able to control the lock starting this date. Seconds must be `:00` (minute resolution).
  - Example: `2021-01-03T12:00:00+08:00`
- **`endDate`** `string<date-time>` *required*\
  User is unable to control the lock starting this date. Seconds must be `:00` (minute resolution), and must be after `startDate`.
  - Example: `2021-11-03T12:00:00+08:00`
- **`permissions`** `array of string` *required*\
  List of permissions to grant on this eKey. Required. There is no default, although the field can look optional.
  - Example: `["UNLOCK"]`

#### Request Example

```bash
curl -X POST "https://api.igloohome.co/home/devices/{deviceId}/ekey" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "endDate": "value",
    "permissions": "value",
    "startDate": "value"
  }'
```

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/devices/{deviceId}/ekey"
	payload := []byte(`{
		"endDate": "value",
		"permissions": "value",
		"startDate": "value"
	}`)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/devices/{deviceId}/ekey", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "endDate": "value",
    "permissions": "value",
    "startDate": "value"
  })
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/devices/{deviceId}/ekey"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
payload = {
    "endDate": "value",
    "permissions": "value",
    "startDate": "value"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/devices/{deviceId}/ekey",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "endDate" => "value",
        "permissions" => "value",
        "startDate" => "value"
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val mediaType = "application/json".toMediaType()
val body = """
    {
        "endDate": "value",
        "permissions": "value",
        "startDate": "value"
    }
""".trimIndent().toRequestBody(mediaType)

val request = Request.Builder()
    .url("https://api.igloohome.co/home/devices/{deviceId}/ekey")
    .method("POST", body)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .addHeader("Content-Type", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/devices/{deviceId}/ekey")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = [
    "endDate": "value",
    "permissions": "value",
    "startDate": "value"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`200 OK`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`403 Forbidden, accessToken scope must contain 'igloohomeapi/create-ekey-access'`
`404 '{ message: 'not found device' }' or '{ message: 'not found property' }'`
`409 Response`
`415 Unsupported Media Type`
`500 Internal Server Error`

**Response body — `200`:**

- **`keyId`** `integer`
- **`bluetoothGuestKey`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`

**Example response — `200`:**

```json
{
  "bluetoothGuestKey": "xNXdtaE5DcjBzbktXZWc1Q3d2SFd0RVU5T2swWjRmQjRkRjdhczlONEE9PQ==",
  "keyId": 12847
}
```

**Example response — `400`:**

```json
"configuration lock issue"
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "not found device"
}
```

**Example response — `409`:**

```json
"invalid.generate.ekey"
```

## iglooKey

### Create iglooKey Token

`POST` `https://api.igloohome.co/home/pass`

Creates a shareable iglooKey access token that supports both online and
offline unlock for one or more devices.

#### Body Parameters

Content-Type: `application/json`

- **`deviceIds`** `array of string` *required*
- **`label`** `string` *required*
- **`endsAt`** `string<date-time>` *required*\
  Must be in the future
- **`startsAt`** `string<date-time>`\
  Must be on or before `endsAt`
- **`activationWindowSeconds`** `integer`\
  If set, the token must be activated within this many seconds of `startsAt` (or now); the resulting deadline must not exceed `endsAt`.
- **`offlineAccessSeconds`** `integer`\
  Grants offline access validity, in seconds (max 24 hours)

#### Request Example

```bash
curl -X POST "https://api.igloohome.co/home/pass" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "activationWindowSeconds": "value",
    "deviceIds": "value",
    "endsAt": "value",
    "label": "value",
    "offlineAccessSeconds": "value",
    "startsAt": "value"
  }'
```

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/pass"
	payload := []byte(`{
		"activationWindowSeconds": "value",
		"deviceIds": "value",
		"endsAt": "value",
		"label": "value",
		"offlineAccessSeconds": "value",
		"startsAt": "value"
	}`)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/pass", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "activationWindowSeconds": "value",
    "deviceIds": "value",
    "endsAt": "value",
    "label": "value",
    "offlineAccessSeconds": "value",
    "startsAt": "value"
  })
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/pass"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
payload = {
    "activationWindowSeconds": "value",
    "deviceIds": "value",
    "endsAt": "value",
    "label": "value",
    "offlineAccessSeconds": "value",
    "startsAt": "value"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/pass",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "activationWindowSeconds" => "value",
        "deviceIds" => "value",
        "endsAt" => "value",
        "label" => "value",
        "offlineAccessSeconds" => "value",
        "startsAt" => "value"
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val mediaType = "application/json".toMediaType()
val body = """
    {
        "activationWindowSeconds": "value",
        "deviceIds": "value",
        "endsAt": "value",
        "label": "value",
        "offlineAccessSeconds": "value",
        "startsAt": "value"
    }
""".trimIndent().toRequestBody(mediaType)

val request = Request.Builder()
    .url("https://api.igloohome.co/home/pass")
    .method("POST", body)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .addHeader("Content-Type", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/pass")!)
request.httpMethod = "POST"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = [
    "activationWindowSeconds": "value",
    "deviceIds": "value",
    "endsAt": "value",
    "label": "value",
    "offlineAccessSeconds": "value",
    "startsAt": "value"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`201 Created`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`403 Forbidden`
`404 Not Found`
`415 Unsupported Media Type`
`422 '{ message: 'device type not supported for iglooKey', excludedIds: string[] }'`
`500 Internal Server Error`
`502 Response`
`503 Response`

**Response body — `201`:**

- **`shareableUrl`** `string`
- **`id`** `string`
- **`type`** `string`\
  Token type, `TOKEN_TYPE_HYBRID`.
- **`endsAt`** `string<date-time>`
- **`createdAt`** `string<date-time>`
- **`startsAt`** `string<date-time>`
- **`activationDeadline`** `string<date-time>`

**Response body — `400`:**

- **`error`** `string`
- **`message`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`
- **`missingIds`** `array of string`

**Example response — `201`:**

```json
{
  "activationDeadline": "2025-09-15T11:00:00Z",
  "createdAt": "2025-09-08T14:30:45Z",
  "endsAt": "2025-12-31T23:59:59Z",
  "id": "lnk_abc123def456ghi789jkl012mno345",
  "shareableUrl": "https://igloodev.app.link/pass?token=lnk_abc123def456ghi789jkl012mno345",
  "startsAt": "2025-09-15T10:00:00Z",
  "type": "TOKEN_TYPE_HYBRID"
}
```

**Example response — `400`:**

```json
{
  "error": "\"endsAt\" must be in the future"
}
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "device not found"
}
```

### Update iglooKey Token

`PATCH` `https://api.igloohome.co/home/pass/{id}`

Updates the validity window (`startsAt`/`endsAt`) of an existing iglooKey token.

#### Path Parameters

| Parameter | Type | Required |
| --- | --- | --- |
| id | string | Yes |

#### Body Parameters

Content-Type: `application/json`

- **`startsAt`** `string<date-time>`\
  Must be in the future
- **`endsAt`** `string<date-time>`\
  Must be in the future and after `startsAt`

#### Request Example

```bash
curl -X PATCH "https://api.igloohome.co/home/pass/{id}" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "endsAt": "value",
    "startsAt": "value"
  }'
```

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/pass/{id}"
	payload := []byte(`{
		"endsAt": "value",
		"startsAt": "value"
	}`)

	req, _ := http.NewRequest("PATCH", url, bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/pass/{id}", {
  method: "PATCH",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "endsAt": "value",
    "startsAt": "value"
  })
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/pass/{id}"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
payload = {
    "endsAt": "value",
    "startsAt": "value"
}
response = requests.patch(url, headers=headers, json=payload)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/pass/{id}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "PATCH",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "endsAt" => "value",
        "startsAt" => "value"
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val mediaType = "application/json".toMediaType()
val body = """
    {
        "endsAt": "value",
        "startsAt": "value"
    }
""".trimIndent().toRequestBody(mediaType)

val request = Request.Builder()
    .url("https://api.igloohome.co/home/pass/{id}")
    .method("PATCH", body)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .addHeader("Content-Type", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/pass/{id}")!)
request.httpMethod = "PATCH"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let payload: [String: Any] = [
    "endsAt": "value",
    "startsAt": "value"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`200 OK`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`403 Forbidden`
`404 Not Found`
`415 Unsupported Media Type`
`500 Internal Server Error`
`502 Response`
`503 '{ message: 'failed to update iglooKey token' }' if the upstream linking service was unreachable.`

**Response body — `200`:**

- **`id`** `string`
- **`type`** `string`\
  Token type, `TOKEN_TYPE_HYBRID`.
- **`endsAt`** `string<date-time>`
- **`startsAt`** `string<date-time>`
- **`activationDeadline`** `string<date-time>`

**Response body — `400`:**

- **`error`** `string`
- **`message`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`
- **`missingIds`** `array of string`

**Example response — `200`:**

```json
{
  "activationDeadline": "2025-09-20T14:00:00Z",
  "endsAt": "2026-01-15T23:59:59Z",
  "id": "lnk_abc123def456ghi789jkl012mno345",
  "startsAt": "2025-09-20T12:00:00Z",
  "type": "TOKEN_TYPE_HYBRID"
}
```

**Example response — `400`:**

```json
{
  "error": "\"endsAt\" must be in the future"
}
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "device not found"
}
```

### Revoke iglooKey Token

`DELETE` `https://api.igloohome.co/home/pass/{id}`

Revokes an existing iglooKey token. No request body.

#### Path Parameters

| Parameter | Type | Required |
| --- | --- | --- |
| id | string | Yes |

#### Request Example

```bash
curl -X DELETE "https://api.igloohome.co/home/pass/{id}" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/json"
```

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.igloohome.co/home/pass/{id}"
	req, _ := http.NewRequest("DELETE", url, nil)
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
	req.Header.Set("Accept", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
```

```javascript
const res = await fetch("https://api.igloohome.co/home/pass/{id}", {
  method: "DELETE",
  headers: {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
  }
});

const data = await res.json();
console.log(data);
```

```python
import requests

url = "https://api.igloohome.co/home/pass/{id}"
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN",
    "Accept": "application/json"
}
response = requests.delete(url, headers=headers)
print(response.json())
```

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.igloohome.co/home/pass/{id}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer YOUR_ACCESS_TOKEN",
        "Accept: application/json"
    ]
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```kotlin
val client = OkHttpClient()

val request = Request.Builder()
    .url("https://api.igloohome.co/home/pass/{id}")
    .method("DELETE", null)
    .addHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN")
    .addHeader("Accept", "application/json")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.igloohome.co/home/pass/{id}")!)
request.httpMethod = "DELETE"
request.setValue("Bearer YOUR_ACCESS_TOKEN", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Accept")

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}
task.resume()
```

#### Responses

`204 No Content`
`400 Bad Request`
`401 Unauthorized, invalid or expired authorization token`
`402 Response`
`403 Forbidden`
`404 Not Found`
`500 Internal Server Error`
`502 '{ message: 'failed to revoke iglooKey token' }' if the upstream linking service returned a server error or an unrecognized status.`
`503 '{ message: 'failed to revoke iglooKey token' }' if the upstream linking service was unreachable.`

**Response body — `400`:**

- **`error`** `string`
- **`message`** `string`

**Response body — `402`:**

- **`error`** `string`

**Response body — `404`:**

- **`message`** `string`
- **`missingIds`** `array of string`

**Example response — `400`:**

```json
{
  "error": "\"endsAt\" must be in the future"
}
```

**Example response — `402`:**

```json
{
  "error": "30 days igloohome API trial has ended"
}
```

**Example response — `404`:**

```json
{
  "message": "device not found"
}
```

