# Zones

The zone represents visual representation of a specific area, such as a room, terrace, or any other defined space. It contains the layout, dimensions, and arrangement of objects within that area.

The data model for zone is represented by [`Zone`](/data-models.md#zone) class.

## API methods

## Get zones

<mark style="color:blue;">`GET`</mark> `http://{server-address}/zones`

Returns all zones that matches query parameters. Result is of type [`QueryResult<Zone>`](/data-models.md#queryresult).

#### Query Parameters

| Name              | Type      | Description                                                                                                              |
| ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| Name              | string    | Supports NData syntax.                                                                                                   |
| DefaultFiscalName | string    | Supports NData syntax.                                                                                                   |
| $skip             | int       | Pagination property. Describing number of records to skip from beginning of result collection.                           |
| $take             | int       | Pagination property. Maximum count of items to be returned.                                                              |
| $sort             | string\[] | <p>Comma separated list of property names. Please see NData syntax.<br></p>                                              |
| $count            | bool      | If set to `true`, response will not contain `items` collection. Use to get resource count, not the resources themselves. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successful response" %}

```javascript
{
    "items":
    [
        {
            "name": "Bar",
            "defaultFiscalName": null,
            "items":
            [
                {
                    "name": "B01",
                    "isTable": true,
                    "meta":
                    {
                        "position":
                        {
                            "x": 0.10,
                            "y": 0.10
                        },
                        "width": 0.12,
                        "height": 0.12,
                        "shape": "Rectangle",
                        "rotation": 0,
                        "color": "#cccccc"
                    }
                },
                {
                    "name": "B02",
                    "isTable": true,
                    "meta":
                    {
                        "position":
                        {
                            "x": 0.30,
                            "y": 0.10
                        },
                        "width": 0.12,
                        "height": 0.12,
                        "shape": "Rectangle",
                        "rotation": 0,
                        "color": "#cccccc"
                    }
                }
            ],
            "sortHint": 1,
            "_v": 1
        }
    ],
    "count": 1,
    "totalCount": 1
}
```

{% endtab %}
{% endtabs %}

## Get zone by name

<mark style="color:blue;">`GET`</mark> `http://{server-address}/zones/{name}`

Result is of type [Zone](/data-models.md#zone).

#### Path Parameters

| Name                                   | Type   | Description       |
| -------------------------------------- | ------ | ----------------- |
| name<mark style="color:red;">\*</mark> | string | Unique zone name. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "name": "Bar",
    "defaultFiscalName": null,
    "items":
    [
        {
            "name": "B01",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.10,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        },
        {
            "name": "B02",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.30,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        }
    ],
    "sortHint": 1,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Zone with given name is not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Create zone

<mark style="color:green;">`POST`</mark> `http://{server-address}/zones`

Creates new zone. Result is of type [Zone](/data-models.md#zone).

**Required rights**

Authorized user must have `ZoneCreate` [right ](/user-rights.md)assigned.

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type | Description          |
| ---------------------------------------- | ---- | -------------------- |
| (body)<mark style="color:red;">\*</mark> | Zone | Zone model to create |

{% tabs %}
{% tab title="201: Created " %}

```javascript
{
    "name": "Bar",
    "defaultFiscalName": null,
    "items":
    [
        {
            "name": "B01",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.10,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        },
        {
            "name": "B02",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.30,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        }
    ],
    "sortHint": 1,
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Create or update zone

<mark style="color:orange;">`PUT`</mark> `http://{server-address}/zones/{name}`

Updates existing or creates new zone. Result is of type [Zone](/data-models.md#zone).

**Required rights**

Authorized user must have assigned `ZoneCreate` or `ZoneUpdate` [right](/user-rights.md).

#### Path Parameters

| Name                                   | Type   | Description       |
| -------------------------------------- | ------ | ----------------- |
| name<mark style="color:red;">\*</mark> | string | Unique zone name. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type | Description                     |
| ---------------------------------------- | ---- | ------------------------------- |
| (body)<mark style="color:red;">\*</mark> | Zone | Zone model to create or update. |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "name": "Bar",
    "defaultFiscalName": null,
    "items":
    [
        {
            "name": "B01",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.10,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        },
        {
            "name": "B02",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.30,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        }
    ],
    "sortHint": 1,
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Delete zone by name

<mark style="color:red;">`DELETE`</mark> `http://{server-address}/zones/{name}`

**Required rights**

Authorized user must have `ZoneDelete` [right ](/user-rights.md)assigned.

#### Path Parameters

| Name                                   | Type   | Description       |
| -------------------------------------- | ------ | ----------------- |
| name<mark style="color:red;">\*</mark> | string | Unique zone name. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "name": "Bar",
    "defaultFiscalName": null,
    "items":
    [
        {
            "name": "B01",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.10,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        },
        {
            "name": "B02",
            "isTable": true,
            "meta":
            {
                "position":
                {
                    "x": 0.30,
                    "y": 0.10
                },
                "width": 0.12,
                "height": 0.12,
                "shape": "Rectangle",
                "rotation": 0,
                "color": "#cccccc"
            }
        }
    ],
    "sortHint": 1,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found " %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.portos.sk/api-reference/zones.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
