note.collection.add
Создать базу знаний
Описание
Метод относится к REST 3.0. Особенности вызова и формат ответа новой версии API описаны в обзоре REST 3.0.
Метод note.collection.add создает новую базу знаний и возвращает ее объект.
Параметры
fields
object
обязательный
Объект с полями новой базы знаний. Описание структуры объекта
Параметр fields
name
string
обязательный
Название базы знаний.
Название базы знаний не должно превышать 255 символов
position
integer
необязательный
Позиция базы знаний в общем списке.
По умолчанию: 0
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"name":"Продуктовая документация","position":100}}' \
https://**put_your_bitrix24_address**/rest/api/**put_your_user_id_here**/**put_your_webhook_here**/note.collection.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"name":"Продуктовая документация","position":100},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/api/note.collection.add
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
// Shape of the payload returned in result (match the "response handling" section of the page)
type CollectionAddResult = {
item: {
id: number
name: string
position: number
policyLevel: string
createdBy: number
updatedBy: number
createdAt: string
updatedAt: string
}
}
try {
const response = await $b24.actions.v3.call.make<CollectionAddResult>({
method: 'note.collection.add',
params: {
fields: {
name: 'Продуктовая документация',
position: 100,
},
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info('Collection created:', result.item.id, result.item.name)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function addCollection() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v3.call.make({
method: 'note.collection.add',
params: {
fields: {
name: 'Продуктовая документация',
position: 100,
},
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info('Collection created:', result.item.id, result.item.name)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', addCollection)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
fields = {
"name": "Продуктовая документация",
"position": 100,
}
try:
bitrix_response = client.note.collection.add(
fields=fields,
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Ошибка Bitrix API",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
print(f"Непредвиденная ошибка: {error}")
try {
$response = $b24Service
->core
->call(
'note.collection.add',
[
'fields' => [
'name' => 'Продуктовая документация',
'position' => 100,
],
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error creating collection: ' . $e->getMessage();
}
BX24.callMethod(
'note.collection.add',
{
fields: {
name: 'Продуктовая документация',
position: 100
}
},
function(result){
console.info(result.data());
console.log(result);
}
);
require_once('crest.php');
$result = CRest::call(
'note.collection.add',
[
'fields' => [
'name' => 'Продуктовая документация',
'position' => 100
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "note.collection.add", b24.Params{
"fields": b24.Params{
"name": "Продуктовая документация",
"position": 100,
},
})
if err != nil {
return fmt.Errorf("note.collection.add: %w", err)
}
// Метод заворачивает ответ в объект с ключом "item".
raw, ok := b24.Unwrap(res.Result, "item")
if !ok {
return fmt.Errorf("в ответе нет ключа item")
}
var item struct {
ID b24.ID `json:"id"`
Name string `json:"name"`
Position int `json:"position"`
PolicyLevel string `json:"policyLevel"`
CreatedBy int `json:"createdBy"`
CreatedAt string `json:"createdAt"`
}
if err := json.Unmarshal(raw, &item); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.ID, item.Name)
Ответ
HTTP-статус: 200
{
"result": {
"item": {
"id": 42,
"name": "Продуктовая документация",
"position": 100,
"policyLevel": "view",
"createdBy": 1,
"createdAt": "2026-04-20T12:00:00Z",
"updatedBy": 1,
"updatedAt": "2026-04-20T12:00:00Z"
}
},
"time": {
"start": 1780388120,
"finish": 1780388120.245321,
"duration": 0.24532103538513184,
"processing": 0.1812450885772705,
"date_start": "2026-06-16T11:15:20+03:00",
"date_finish": "2026-06-16T11:15:20+03:00",
"operating_reset_at": 1780388720,
"operating": 0
}
}
Возвращаемые данные
result
object
Объект с результатом создания базы знаний
item
object
Объект созданной базы знаний
id
integer
Идентификатор созданной базы знаний
name
string
Название базы знаний
position
integer
Позиция базы знаний в общем списке
policyLevel
string
Базовая политика доступа базы знаний
createdBy
integer
Идентификатор автора базы знаний
createdAt
datetime
Дата и время создания базы знаний в UTC
updatedBy
integer
Идентификатор последнего редактора базы знаний
updatedAt
datetime
Дата и время последнего изменения базы знаний в UTC
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 400
{
"error": {
"code": "BITRIX_REST_V3_EXCEPTION_VALIDATION_DTOVALIDATIONEXCEPTION",
"message": "Ошибка при валидации объекта",
"validation": [
{
"message": "Не заполнено обязательное поле \"name\"",
"field": "name"
}
]
}
}
| Код | Описание | Значение |
|---|---|---|
Поле |
Описание ошибки | Как исправить |
fields |
Обязательное поле fields не указано |
Добавьте объект fields в тело запроса |

