# Manage doors with the Salto Space API
> How to create, read, update, and delete doors and remotely open an online door with the Salto Space API.


The Space API, part of Salto IDM Connect, is a REST API that communicates with your Salto Space installation over the SHIP protocol.
This guide explains how to manage the full lifecycle of a door through the API:

- Create a door.
- Get one door or list all doors.
- Update a door.
- Delete a door.
- Remotely open an online door.

You can use any HTTP client, such as Postman, or your own application.
Each step shows the API request and the result in Salto Space.

{{% info-panel %}}
Before you start, follow the guide to [connect Salto Space to the Space API](https://support.saltosystems.com/idm/connect/space-api/connect-salto-space/).
That guide explains how Salto connects the Space API to your Salto Space installation and issues the API credentials you need.
Then [request an access token](/space/space-api/authentication) for the requests shown here.
{{% /info-panel %}}

## Step 1: Create a door {#step-1-create-a-door}

1. Use the `POST /api/v1/doors` endpoint to create a door.
The following payload shows the minimal fields:

    ```json
    {
      "extDoorId": "UNIQUE_DOOR_ID",
      "name": "DOOR_NAME",
      "description": "DOOR_DESCRIPTION"
    }
    ```

    - `extDoorId` is the unique identifier of the door in Salto Space.
    You can provide any string, and you use this value to get, update, or delete the door later.
    - `name` and `description` set the values shown in Salto Space.

2. After a successful response, confirm that the door was created in Salto Space.
The new door appears in the **Doors** list, which you open from the **Access points** menu.

    ![New door shown in the Doors list in Salto Space.](images/door-created.png)
    {.border}

{{% info-panel %}}
This example uses only the minimal fields.
You can also set scalar settings such as the open time on creation, but assign door functions, locations, and zones with a later update or through the related endpoints instead of on the create request.
See the [Space API reference](https://space.api.saltoidm.app/) for the full list of fields you can set on a door.
{{% /info-panel %}}

## Step 2: Get a door {#step-2-get-a-door}

To get doors:

- To get a single door, use the `GET /api/v1/doors/ID` endpoint, where `ID` is the `extDoorId` of the door.
The response returns the full door, including the fields that Salto Space sets by default, such as the open time, opening mode, and battery status.
- To list all doors, use the `GET /api/v1/doors` endpoint.
- To page and filter the results, use the `GET /api/v1/doors/filtered` endpoint with the `maxCount` and `startingFromExtDoorId` query parameters.

You can double-click a door in the **Doors** list to open its detail page, where the identification, connection type, opening mode, opening time, and calendar are shown.

![Door detail page in Salto Space.](images/door-detail.png)
{.border}

## Step 3: Update a door {#step-3-update-a-door}

1. Use the `PUT /api/v1/doors/ID` endpoint, where `ID` is the `extDoorId` of the door.
Send the complete door: get it with the `GET /api/v1/doors/ID` endpoint, change the values you want, and send the whole object back.
The update doesn't patch individual fields.
Numeric settings that you leave out, such as `openTime` and `openingMode`, reset to `0`, while text fields that you leave out keep their values.
The following payload updates the description and sends the other settings back unchanged:

    ```json
    {
      "extDoorId": "UNIQUE_DOOR_ID",
      "name": "DOOR_NAME",
      "description": "NEW_DOOR_DESCRIPTION",
      "openingMode": 0,
      "openTime": 6,
      "openTimeAda": 20,
      "antiPassBackEnabled": 0,
      "outwardAntiPassBack": 0,
      "auditOnKeys": 0,
      "keypadCode": "0000",
      "timedPeriodsTableId": "1",
      "automaticChangesTableId": "1",
      "gpf1": "",
      "gpf2": "",
      "doorZones": [],
      "doorFunctions": [],
      "doorLocations": []
    }
    ```

2. After a successful response, confirm the change on the door's detail page in Salto Space.

    ![Updated description shown on the door page in Salto Space.](images/door-updated.png)
    {.border}

## Step 4: Delete a door {#step-4-delete-a-door}

1. Use the `DELETE /api/v1/doors/ID` endpoint, where `ID` is the `extDoorId` of the door.

2. After the door is deleted, it is removed from Salto Space and no longer appears in the **Doors** list.

    ![Doors list in Salto Space showing no results for the deleted door.](images/door-deleted.png)
    {.border}

## Step 5: Remotely open an online door {#step-5-remotely-open-an-online-door}

For an online door, you can send a remote open command using the `GET /api/v1/doors/OnlineDoorOpen/ID` endpoint, where `ID` is the `extDoorId` of the door.
On a real online door, this command physically unlocks the door, so use it only against a door you intend to open.

In the response, `Success` refers to the request, not to the door.
The `Data` array has an entry per door with `DoorID`, `ErrorCode`, and `ErrorMessage`, and the door opened only when its entry reports no error.
For example, a door that the system can't reach returns `Success: true` with `ErrorCode: 406` and `ErrorMessage: "Peripheral not initialized"`.

{{% info-panel %}}
A door must be online for the remote open command to take effect.
For an offline door, or a door that cannot currently be reached, the response reports that the door was not opened.
{{% /info-panel %}}

## Handling responses {#handling-responses}

Every endpoint returns HTTP `200`, including when the operation does not succeed.
The create, get, update, and delete endpoints return a `Success` flag and a `Message`, so check the `Success` flag rather than the HTTP status code to determine the outcome.
For example, if you request a door ID that does not exist, the API can return HTTP `200` with `Success` set to `false`.
When you get a door, also check that the `ExtDoorId` in the response matches the ID you requested, because a request for an ID that does not exist can return a different door.

The remote open endpoint is the exception: its `Success` flag is `true` when the API processed the request, and the result for each door is in `Data`, as described in [step 5](#step-5-remotely-open-an-online-door).

## API definition and documentation {#api-definition-and-documentation}

See the [Space API reference](https://space.api.saltoidm.app/) for a full description of the endpoints and entities available through the API.

The Space API uses a limited set of the functionality available in the full SHIP protocol.
Contact `support-id@saltosystems.com` if you need functionality in the API that is not yet available.

