# Companies

Suppliers and purchasers are commonly referred to as companies, and within the companies database, there exists an additional record marked as "*default*" that represents the merchant, owner or the cash register system.

Company is represented by [`Company`](/data-models.md#company) class.

## API methods

## Get companies

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

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

#### Query Parameters

| Name         | Type        | Description                                                                                                              |
| ------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------ |
| id           | string      | Supports NData syntax.                                                                                                   |
| crn          | 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. |
| discountRate | decimal     | Supports NData syn                                                                                                       |
| name         | string      | Supports NData syntax.                                                                                                   |
| isDefault    | bool        | Supports NData syntax.                                                                                                   |
| isActive     | bool        | Supports NData syntax.                                                                                                   |
| isTaxPayer   | bool        | Supports NData syntax.                                                                                                   |
| type         | CompanyType | Supports NData syntax.                                                                                                   |
| taxId        | string      | Supports NData syntax.                                                                                                   |
| vatId        | string      | Supports NData syntax.                                                                                                   |
| dueDays      | int         | Supports NData syntax.                                                                                                   |
| search       | string      | Supports NData syntax.                                                                                                   |

#### 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":
    [
        {
            "id": "62db00718d4c4f2c700bbc5b",
            "isActive": true,
            "name": "My supplier",
            "crn": "123",
            "vatId": "SK1020304050",
            "taxId": "1020304050",
            "isTaxPayer": true,
            "register": "reg v OR OS Bratislava I, vl.č. 12345/B",
            "dueDays": 0,
            "type": "Supplier",
            "discountRate": 0.0,
            "isDefault": false,
            "addresses":
            [
                {
                    "street": "Hlavná 4",
                    "city": "Bratislava",
                    "zipCode": "81101",
                    "country": "Slovensko",
                    "type": "Office"
                },
                {
                    "street": "Dodacia 11",
                    "city": "Bratislava",
                    "zipCode": "81102",
                    "country": "Slovensko",
                    "type": "Shipping"
                }
            ],
            "bankAccounts":
            [
                {
                    "bankCountry": "Slovensko",
                    "bankName": "Tatra banka, a.s.",
                    "iban": "SK0011000000000000000000",
                    "number": null,
                    "swift": "TATRSKBXXXX",
                    "isDefault": true
                }
            ],
            "contacts":
            [
                {
                    "fax": null,
                    "phone": null,
                    "mobile": "+421 900 123 123",
                    "email": "john.doe@suppliercompany.portos",
                    "isDefault": true,
                    "name": "John",
                    "surname": "Doe",
                    "note": null
                }
            ],
            "_v": 1
        }
    ],
    "count": 1,
    "totalCount": 1
}
```

{% endtab %}
{% endtabs %}

## Get company

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

Result is of type [Company](/data-models.md#company).

#### Path Parameters

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

#### Headers

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

{% tabs %}
{% tab title="200: OK Resource found." %}

```javascript
{
    "id": "62db00718d4c4f2c700bbc5b",
    "isActive": true,
    "name": "My supplier",
    "crn": "123",
    "vatId": "SK1020304050",
    "taxId": "1020304050",
    "isTaxPayer": true,
    "register": "reg v OR OS Bratislava I, vl.č. 12345/B",
    "dueDays": 0,
    "type": "Supplier",
    "discountRate": 0.0,
    "isDefault": false,
    "addresses":
    [
        {
            "street": "Hlavná 4",
            "city": "Bratislava",
            "zipCode": "81101",
            "country": "Slovensko",
            "type": "Office"
        },
        {
            "street": "Dodacia 11",
            "city": "Bratislava",
            "zipCode": "81102",
            "country": "Slovensko",
            "type": "Shipping"
        }
    ],
    "bankAccounts":
    [
        {
            "bankCountry": "Slovensko",
            "bankName": "Tatra banka, a.s.",
            "iban": "SK0011000000000000000000",
            "number": null,
            "swift": "TATRSKBXXXX",
            "isDefault": true
        }
    ],
    "contacts":
    [
        {
            "fax": null,
            "phone": null,
            "mobile": "+421 900 123 123",
            "email": "john.doe@suppliercompany.portos",
            "isDefault": true,
            "name": "John",
            "surname": "Doe",
            "note": null
        }
    ],
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

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

{% endtab %}
{% endtabs %}

## Create company

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

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

**Required rights**

Authorized user must have `CompanyCreate` [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> | Company | Model to create. |

{% tabs %}
{% tab title="201: Created Successfuly created." %}

```javascript
{
    "id": "62db00718d4c4f2c700bbc5b",
    "isActive": true,
    "name": "My supplier",
    "crn": "123",
    "vatId": "SK1020304050",
    "taxId": "1020304050",
    "isTaxPayer": true,
    "register": "reg v OR OS Bratislava I, vl.č. 12345/B",
    "dueDays": 0,
    "type": "Supplier",
    "discountRate": 0.0,
    "isDefault": false,
    "addresses":
    [
        {
            "street": "Hlavná 4",
            "city": "Bratislava",
            "zipCode": "81101",
            "country": "Slovensko",
            "type": "Office"
        },
        {
            "street": "Dodacia 11",
            "city": "Bratislava",
            "zipCode": "81102",
            "country": "Slovensko",
            "type": "Shipping"
        }
    ],
    "bankAccounts":
    [
        {
            "bankCountry": "Slovensko",
            "bankName": "Tatra banka, a.s.",
            "iban": "SK0011000000000000000000",
            "number": null,
            "swift": "TATRSKBXXXX",
            "isDefault": true
        }
    ],
    "contacts":
    [
        {
            "fax": null,
            "phone": null,
            "mobile": "+421 900 123 123",
            "email": "john.doe@suppliercompany.portos",
            "isDefault": true,
            "name": "John",
            "surname": "Doe",
            "note": null
        }
    ],
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Create or update company

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

Creates new or updates existing company. Result is of type [Company](/data-models.md#company).

**Required rights**

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

#### Path Parameters

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

#### 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> | Company | Model to create or update. |

{% tabs %}
{% tab title="200: OK Successfuly created or updated." %}

```javascript
{
    "id": "62db00718d4c4f2c700bbc5b",
    "isActive": true,
    "name": "My supplier",
    "crn": "123",
    "vatId": "SK1020304050",
    "taxId": "1020304050",
    "isTaxPayer": true,
    "register": "reg v OR OS Bratislava I, vl.č. 12345/B",
    "dueDays": 0,
    "type": "Supplier",
    "discountRate": 0.0,
    "isDefault": false,
    "addresses":
    [
        {
            "street": "Hlavná 4",
            "city": "Bratislava",
            "zipCode": "81101",
            "country": "Slovensko",
            "type": "Office"
        },
        {
            "street": "Dodacia 11",
            "city": "Bratislava",
            "zipCode": "81102",
            "country": "Slovensko",
            "type": "Shipping"
        }
    ],
    "bankAccounts":
    [
        {
            "bankCountry": "Slovensko",
            "bankName": "Tatra banka, a.s.",
            "iban": "SK0011000000000000000000",
            "number": null,
            "swift": "TATRSKBXXXX",
            "isDefault": true
        }
    ],
    "contacts":
    [
        {
            "fax": null,
            "phone": null,
            "mobile": "+421 900 123 123",
            "email": "john.doe@suppliercompany.portos",
            "isDefault": true,
            "name": "John",
            "surname": "Doe",
            "note": null
        }
    ],
    "_v": 2
}
```

{% endtab %}
{% endtabs %}

## Delete company

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

**Required rights**

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

#### Path Parameters

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

#### Headers

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

{% tabs %}
{% tab title="200: OK Successfuly deleted." %}

```javascript
{
    "id": "62db00718d4c4f2c700bbc5b",
    "isActive": true,
    "name": "My supplier",
    "crn": "123",
    "vatId": "SK1020304050",
    "taxId": "1020304050",
    "isTaxPayer": true,
    "register": "reg v OR OS Bratislava I, vl.č. 12345/B",
    "dueDays": 0,
    "type": "Supplier",
    "discountRate": 0.0,
    "isDefault": false,
    "addresses":
    [
        {
            "street": "Hlavná 4",
            "city": "Bratislava",
            "zipCode": "81101",
            "country": "Slovensko",
            "type": "Office"
        },
        {
            "street": "Dodacia 11",
            "city": "Bratislava",
            "zipCode": "81102",
            "country": "Slovensko",
            "type": "Shipping"
        }
    ],
    "bankAccounts":
    [
        {
            "bankCountry": "Slovensko",
            "bankName": "Tatra banka, a.s.",
            "iban": "SK0011000000000000000000",
            "number": null,
            "swift": "TATRSKBXXXX",
            "isDefault": true
        }
    ],
    "contacts":
    [
        {
            "fax": null,
            "phone": null,
            "mobile": "+421 900 123 123",
            "email": "john.doe@suppliercompany.portos",
            "isDefault": true,
            "name": "John",
            "surname": "Doe",
            "note": null
        }
    ],
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was 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/companies.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.
