# Creating Door Lock CRUD Endpoints

## Overview

Door Lock CRUD endpoints Seam to list door locks owned by a Door Lock Owner and trigger the door lock to open a door.

### Listing Door Locks

After a Door Lock Owner logs in, Seam lists all the door locks they own and allows them to enable delivery on them. Your API should return a JSON list of door locks.

## List all locks owned by Lock Owner

<mark style="color:blue;">`GET`</mark> `https://devicecloud.example.com/locks`

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<access\_token> |

{% tabs %}
{% tab title="200: OK List of Locks in JSON" %}

```javascript
{
    "locks": [
        {
            "lock_id": "3043fde0-3c6d-4913-981f-2607f05fe74e",
            // Optional, but recommended
            "name": "Office Front Door",
            "model": "example_model",
            "address": "123 Amy Lane, CA, 94110, United States"
        },
        {
            "lock_id": "1c33d4cf-e178-4c06-8a9a-aadd6dc5a804",
            // Optional, but recommended
            "name": "Back Door",
            "model": "example_model",
            "address": "999 Louis Lane, CA, 94110, United States"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### Getting a Lock

Seam may request door lock information to display information about the lock to the connecting user.

## Get information about a single lock

<mark style="color:blue;">`GET`</mark> `https://devicecloud.example.com/locks/<LOCK_ID>`

#### Query Parameters

| Name                                       | Type   | Description         |
| ------------------------------------------ | ------ | ------------------- |
| LOCK\_ID<mark style="color:red;">\*</mark> | String | Identifier for Lock |

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<access\_token> |

{% tabs %}
{% tab title="200: OK A single lock JSON object" %}

```javascript
{
  "lock_id": "3043fde0-3c6d-4913-981f-2607f05fe74e",
  // Optional, but recommended
  "name": "Office Front Door",
  "model": "example_model",
  "address": "123 Amy Lane, CA, 94110, United States"
}
```

{% endtab %}
{% endtabs %}

### Unlocking a Door Lock

Seam unlocks doors to let in delivery people. If a door is disconnected or you're unable to unlock the door, return HTTP status code `500` with some details (see example below)

## Temporary unlock the door for a delivery person

<mark style="color:green;">`POST`</mark> `https://devicecloud.example.com/locks/<LOCK_ID>/unlock`

#### Headers

| Name                                            | Type   | Description             |
| ----------------------------------------------- | ------ | ----------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<access\_token> |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json        |

{% tabs %}
{% tab title="200: OK Door successfully unlocked" %}

```javascript
{
    "ok": true
}
```

{% endtab %}

{% tab title="500: Internal Server Error Something went wrong unlocking the door." %}

```javascript
{
    "error_id": "INTERCOM_DISCONNECTED",
    "error_message": "Intercom is disconnected"
}
```

{% endtab %}
{% endtabs %}

### Other Door Lock Features

You may want to include additional features for your lock, such as configuring settings that are useful for delivery or apartment management. If you add additional endpoints, you should keep a similar URL format `/locks/<LOCK_ID>/<SOME_PROPERTY_OR_FUNCTION>`
