## Получить словарь полей генерации

`GET /v1/sites/ai/fields`

Получает определения полей ответа генерации.

## Параметры

| Параметр | Тип | Обяз. | По умолчанию | Описание |
|---|---|---|---|---|
| `select[]` (query) | array<string> | Нет | Все свойства | Свойства определений полей, например `name`, `type`, `title`. Это свойства каждого определения, а не имена полей ответа генерации |

## Примеры

### curl — личный ключ

```bash
curl -X GET "https://vibecode.bitrix24.tech/v1/sites/ai/fields" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth-приложение

```bash
curl -X GET "https://vibecode.bitrix24.tech/v1/sites/ai/fields" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — личный ключ

```javascript
const res = await fetch("https://vibecode.bitrix24.tech/v1/sites/ai/fields", {
  "method": "GET",
  "headers": {
    "X-Api-Key": "YOUR_API_KEY"
  }
});
const result = await res.json();
console.log(result);
```

### JavaScript — OAuth-приложение

```javascript
const res = await fetch("https://vibecode.bitrix24.tech/v1/sites/ai/fields", {
  "method": "GET",
  "headers": {
    "X-Api-Key": "YOUR_APP_KEY",
    "Authorization": "Bearer USER_SESSION_TOKEN"
  }
});
const result = await res.json();
console.log(result);
```

## Поля ответа

| Поле | Тип | Описание |
|---|---|---|
| `success` | boolean | `true` при успехе |
| `data` | array | Определения полей генерации |
| `data[].name` | string | Имя поля |
| `data[].type` | string | Тип значения |
| `data[].title` | string | Название поля |
| `data[].description` | string \| null | Описание поля или null |
| `data[].validationRules` | array | Правила проверки |
| `data[].requiredGroups` | array \| null | Группы обязательности или null |
| `data[].filterable` | boolean | Доступность фильтрации |
| `data[].sortable` | boolean | Доступность сортировки |
| `data[].editable` | boolean | Доступность изменения |
| `data[].editableGroups` | array \| null | Группы изменения или null |
| `data[].multiple` | boolean | Множественное значение |
| `data[].elementType` | string \| null | Тип элемента или null |

## Пример ответа

```json
{
  "success": true,
  "data": [
    {
      "name": "id",
      "type": "int",
      "title": "Site generation identifier",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    },
    {
      "name": "status",
      "type": "string",
      "title": "Generation status: running, completed or failed",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    },
    {
      "name": "siteId",
      "type": "int",
      "title": "Generated site identifier, 0 until the site is created",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    },
    {
      "name": "pageId",
      "type": "int",
      "title": "Generated page identifier, 0 until the page is created",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    },
    {
      "name": "draftSiteId",
      "type": "int",
      "title": "Draft site identifier of a failed generation that got as far as creating one, 0 otherwise",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    },
    {
      "name": "draftPageId",
      "type": "int",
      "title": "Draft page identifier of a failed generation that got as far as creating one, 0 otherwise",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    },
    {
      "name": "message",
      "type": "string",
      "title": "Human readable generation state, a text for the user - branch on status, not on it",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    },
    {
      "name": "error",
      "type": "string",
      "title": "Human readable failure reason, null unless the status is failed",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    },
    {
      "name": "errorDetails",
      "type": "string",
      "title": "Exact wording of the request limit that stopped the generation, null when something else did",
      "description": null,
      "validationRules": [],
      "requiredGroups": null,
      "filterable": false,
      "sortable": false,
      "editable": false,
      "editableGroups": null,
      "multiple": false,
      "elementType": null
    }
  ]
}
```

## Пример ответа при ошибке

Запрос `GET /v1/sites/ai/fields?select[]=FAKE_UNKNOWN_FIELD` выбирает неизвестное свойство определения поля. Битрикс24 возвращает эту ошибку. Неизвестное имя поля в `GET /v1/sites/ai/fields/FAKE_UNKNOWN_FIELD` — другой случай: он возвращает `ENTITY_NOT_FOUND` (404).

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Неизвестное поле `FAKE_UNKNOWN_FIELD` для сущности `DtoFieldDto`",
    "b24Code": "BITRIX_REST_V3_EXCEPTION_UNKNOWNDTOPROPERTYEXCEPTION"
  }
}
```

## Ошибки

| HTTP | Код | Описание |
|---|---|---|
| 422 | `BITRIX_ERROR` | Битрикс24 отказал в запросе |
| 401 | `MISSING_API_KEY` | Не передан заголовок `X-Api-Key` |
| 401 | `INVALID_API_KEY` | Платформа не знает переданную строку ключа |
| 401 | `TOKEN_MISSING` | Ключ приложения `vibe_app_*` передан без заголовка `Authorization: Bearer` с токеном сессии |
| 401 | `TOKEN_MISSING` | У личного ключа `vibe_api_*` нет вебхука портала. Причина приходит в `error.details` |
| 403 | `SCOPE_DENIED` | Ключу не выдан скоуп landing |

[Общие ошибки](/docs/errors).

## Смотрите также

- [Генерация сайта с ИИ](../ai.md)
