# API-reference

## Авторизация

<mark style="color:green;">`POST`</mark> `https://cp.pureservers.org/api/auth/login`

#### Headers

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

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| email<mark style="color:red;">\*</mark>    | String | E-mail      |
| password<mark style="color:red;">\*</mark> | String | Пароль      |
| region                                     | String | Всегда "UK" |

{% tabs %}
{% tab title="400: Bad Request Не заполнены поля" %}

```json
"FillFields"
```

{% endtab %}

{% tab title="403: Forbidden Пользователь не существует или заблокирован" %}
Пользователь не существует:

```json
"UserNotExists" || "UserBlocked"
```

{% endtab %}

{% tab title="200: OK Авторизация выполнена" %}
В случае успешной авторизации вы получите текст **LoggedIn** и ответный заголовок **session**, который необходимо сохранить и использовать в дальнейших запросах.
{% endtab %}
{% endtabs %}

## Получить список серверов

<mark style="color:blue;">`GET`</mark> `https://cp.pureservers.org/api/servers/list`

#### Headers

| Name                                      | Type   | Description                          |
| ----------------------------------------- | ------ | ------------------------------------ |
| session<mark style="color:red;">\*</mark> | String | Заголовок полученный при авторизации |

{% tabs %}
{% tab title="200: OK Успешный запрос" %}

```javascript
[{
    num_id: String, // Server ID
    user_id: String, // User ID
    os: String, // Operating System name
    ip: string, // Primary IPv4
    username: String, // Username, for linux: root
    password: String, // Password
    tariff_id: String, // Tariff ID
    expires_at: Date, // Expiration date
    // Current server state
    state: {
        cpu: Number, // CPU load
        ram: Number, // Current RAM load
        max_ram: Number, // Max RAM load
        disk: Number, // Current disk load
        max_disk: Number, // Max disk load
    },
    // Status: String, in array you can see available statuses
    status: ['order_processing', 'installation', 'active', 'expired', 'blocked', 'paused'],
}]
```

{% endtab %}
{% endtabs %}

## Список тарифов

<mark style="color:green;">`POST`</mark> `https://cp.pureservers.org/api/public/tariffs`

#### Request Body

| Name                                       | Type   | Description     |
| ------------------------------------------ | ------ | --------------- |
| currency<mark style="color:red;">\*</mark> | String | Валюта аккаунта |

{% tabs %}
{% tab title="200: OK Успешный запрос" %}

```javascript
[{
    _id: String, // Tariff ID
    visible_name: String, // Visible tariff name
    cpu: Number, // CPU
    ram: Number, // RAM
    disk: Number, // Disk
    network_speed: Number, // Network speed (mbps)
    price: Number // Price in selected currency
}]
```

{% endtab %}
{% endtabs %}

## Заказать сервер

<mark style="color:green;">`POST`</mark> `https://cp.pureservers.org/api/servers/order`

В контенте запроса нужно отправить

#### Headers

| Name                                           | Type   | Description                          |
| ---------------------------------------------- | ------ | ------------------------------------ |
| session<mark style="color:red;">\*</mark>      | String | Заголовок полученный при авторизации |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json                     |

{% tabs %}
{% tab title="400: Bad Request " %}
Возможные ошибки:

NoData - вы не отправили ID тарифа;\
NoIpsAvailable - нет доступных IP-адресов;\
NoOsAvailable - нет доступных ОС на узле;\
FailedToCreateServer - не удалось создать сервер.
{% endtab %}

{% tab title="403: Forbidden " %}
Возможные ошибки:

WhoAreU - пользователь через которого вы авторизованы не существует;\
NotEnoughFunds - недостаточно средств на балансе.<br>
{% endtab %}

{% tab title="404: Not Found " %}
Возможные ошибки:

NoTariff - тариф не существует;\
NoNodes - нет доступных узлов.
{% endtab %}

{% tab title="200: OK " %}
В случае успеха вы получите ObjectId заказанного сервера.
{% 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://docs.pureservers.org/api-reference.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.
