# Manage zones with the Salto Space API
> How to create, read, update, and delete zones in Salto Space 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 zone through the API:

- Create a zone.
- Get one zone or list all zones.
- Update a zone.
- Delete a zone.

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 %}}

A zone groups access points together so that you can grant access to all of them at once.
You reference zones when you assign access rights to users and access levels.
Every zone is identified by an `extZoneId` value, which you provide when you create the zone and use to get, update, or delete it later.

The API uses the same response envelope as the other Space API endpoints.
Every call returns HTTP `200`, and the `Success` field in the response tells you whether the operation succeeded.
Always check the `Success` field rather than relying on the HTTP status code.

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

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

    ```json
    {
      "extZoneId": "UNIQUE_ZONE_ID",
      "name": "ZONE_NAME",
      "description": "ZONE_DESCRIPTION",
      "isFreeAssignment": 0,
      "isLow": 0,
      "freeAssignmentGroup": 1,
      "doors": []
    }
    ```

    - `extZoneId` is the unique identifier of the zone in Salto Space.
    You can provide any string, and you use this value to get, update, or delete the zone later.
    - `name` and `description` set the text shown in Salto Space.
    - `freeAssignmentGroup` must be `1` or greater.
    If you send an invalid value, the API returns `Success: false` with a validation message.
    - `doors` is the list of access points in the zone.
    Each item is an object with an `extDoorId` value.
    Leave the list empty to create a zone with no access points.

    On success, the response returns the `extZoneId` of the new zone as the `Data` value:

    ```json
    {
      "Data": "UNIQUE_ZONE_ID",
      "Success": true,
      "Message": "OK"
    }
    ```

2. After a successful response, confirm that the zone was created in the **Zones** list in Salto Space.

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

{{% info-panel %}}
This example uses only the minimal fields.
See the [Space API reference](https://space.api.saltoidm.app/) for the full list of fields you can set on a zone.
{{% /info-panel %}}

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

To get zones:

- To get a single zone, use the `GET /api/v1/zones/ID` endpoint, where `ID` is the `extZoneId` of the zone.
- To list all zones, use the `GET /api/v1/zones` endpoint.
- To page and filter the results, use the `GET /api/v1/zones/filtered` endpoint.

The `GET /api/v1/zones/ID` endpoint returns the full zone in the `Data` field:

```json
{
  "Data": {
    "ExtZoneId": "UNIQUE_ZONE_ID",
    "Name": "ZONE_NAME",
    "Description": "ZONE_DESCRIPTION",
    "IsFreeAssignment": 0,
    "IsLow": 0,
    "FreeAssignmentGroup": 1,
    "Doors": []
  },
  "Success": true,
  "Message": "OK"
}
```

In Salto Space, double-click a zone in the **Zones** list to open its detail page.
The **Identification** panel shows the **Name**, **Description**, and read-only **Ext ID**, along with the **Low zone** and **Is a GAT NET lockers zone** options and the **Partition** the zone belongs to.

![Zone identification panel in Salto Space.](images/zone-detail.png)
{.border}

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

1. Use the `PUT /api/v1/zones/ID` endpoint, where `ID` is the `extZoneId` of the zone.
Send the full zone in the request body, including the fields you do not change, because the update replaces the existing zone rather than patching individual fields.
The following payload updates the description:

    ```json
    {
      "extZoneId": "UNIQUE_ZONE_ID",
      "name": "ZONE_NAME",
      "description": "NEW_ZONE_DESCRIPTION",
      "isFreeAssignment": 0,
      "isLow": 0,
      "freeAssignmentGroup": 1,
      "doors": []
    }
    ```

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

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

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

1. Use the `DELETE /api/v1/zones/ID` endpoint, where `ID` is the `extZoneId` of the zone.

2. After the zone is deleted, it no longer appears in the **Zones** list in Salto Space.

    ![Zones list in Salto Space after the zone is deleted.](images/zone-deleted.png)
    {.border}

    A later `GET /api/v1/zones/ID` request for the deleted zone returns `Success: false`.
    Check the `Success` field to confirm that the zone no longer exists.

## 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.

