# Quick Start

{% hint style="info" %}
**Обратите внимание:**  для работы с новой версией API, необходимо использовать новые токены. Прежний ключ от предыдущей версии здесь работать не будет.
{% endhint %}

## Получить токен доступа

Для получения токена доступа, вам необходимо перейти в Настройка - API&#x20;

{% hint style="info" %}
**Возьмите на заметку:** необходимо обладать правами доступа к разделу API. Каждый сформированный токен хранится в специальном реестре. Если что-то подойдёт не так, в любой момент можно выключить токен, и весь трафик с его использования будет остановлен.&#x20;
{% endhint %}

## Метод авторизации <a href="#authentication" id="authentication"></a>

**Bearer Token** *⚡️ Content-Type  :  application/json*

{% tabs %}
{% tab title="cURL" %}

```
--header 'Authorization: Bearer XXXXXXX.XXXXXXXX.XXXXXXX'
```

{% endtab %}

{% tab title="PHP" %}

```
 CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer XXXXXXX.XXXXXX.XXXXXXXXX'
  )
```

{% endtab %}

{% tab title="Node (Request)" %}

```
'headers': {
    'Authorization': 'Bearer XXXXXXX.XXXXXXX.XXXXXXX'
  }

```

{% endtab %}

{% tab title="TypeScript" %}

```
// Some code
 constructor(private http: HttpClient) { }
  
// Some code
 public GetWelcome() : Observable<any>
 {
      var token = "XXXXXX.XXXXXX.XXXXXX";
      return this.http.get("https://do.myfreshcloud.com/welcome",
      { headers:
        {"Authorization" : `Bearer ${token}`}
      });
 }
 
```

{% endtab %}
{% endtabs %}

## Первый запрос и первый ответ

{% hint style="info" %}
**Обратите внимание:** для проверки запросов можно использовать [PostMan](https://www.postman.com/) или другой удобный для вас инструмент работы с API
{% endhint %}

Для начала давайте получим ответ Welcome!  ⚡️Это запрос должен содержать токен авторизации

## Welcome!&#x20;

<mark style="color:blue;">`GET`</mark> `https://do.freshoffice.ru/welcome/`

#### Headers

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

{% tabs %}
{% tab title="200: OK Объект стандартного ответа внутри" %}

```javascript
{
    "status": "success",
    "error": null,
    "code": null,
    "rows": 1,
    "pages": 1,
    "page": 1,
    "value": "Welcome! And let's continue: https://apidoc.myfreshcloud.com/"
}
```

{% endtab %}

{% tab title="401: Unauthorized Ошибка авторизации" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request GET 'https://do.freshoffice.ru/welcome/first' \
--header 'Authorization: Bearer XXXXXXX.XXXXXXX.XXXXXX'
```

{% endtab %}

{% tab title="PHP" %}

```
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://do.myfreshcloud.com/welcome/first',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer XXXXXX.XXXXXXX.XXXXXX'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}

{% tab title="Node (Request)" %}

```
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://do.myfreshcloud.com/welcome/first',
  'headers': {
    'Authorization': 'Bearer XXXXXX.XXXXXXX.XXXXXX'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endtab %}

{% tab title="TypeScript" %}

```javascript
// Some code
 constructor(private http: HttpClient) { }
  
// Some code
 public GetWelcome() : Observable<any>
 {
      var token = "XXXXXX-XXXXX-XXXXX";
      
      return this.http.get("https://do.myfreshcloud.com/welcome/first",
      { headers:
        {"Authorization" : `Bearer ${token}`}
      });
 }

```

{% endtab %}
{% endtabs %}

## Объект ответа&#x20;

```

{
    "status": "success",
    "error": null,
    "code": null,
    "rows": 1,
    "pages": 1,
    "page": 1,
    "value": "Welcome! And let's continue: https://apidoc.myfreshcloud.com/"
}

//  status - статус выполнения [success] [error]
//  error - текст ошибки, при наличии
//  code - код ошибки при наличии
//  rows - количество строк 
//  pages - количество страниц
//  page - текущая страница
//  value - запрошенные данные, обычно в формате JSON

```


---

# 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://apidoc.myfreshcloud.com/quick-start.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.
