# calendar.section.add

URL: https://chugunov.pro/api-bitrix24/calendar/calendar-section-add/
Проверено на Битрикс24 REST API, обновлено 11.09.2026 (ревизия источника fb39d6c).
Источник: официальная документация Битрикс24 (bitrix-tools/b24-rest-docs, лицензия MIT, © Bitrix). Справочник независимый, официальной документацией не является.

Добавить календарь
Scope: `calendar`
Кто может выполнять метод: любой пользователь

## Описание

Метод добавляет новый календарь.

Система добавит новый календарь только для пользователя, который выполнит метод. Администратор может создавать календари для других пользователей.

## Параметры

- `type` `string` — обязательный. Тип календаря. Возможные значения: 
  - `user` — календарь пользователя 
  - `group` — календарь группы
- `ownerId` `integer` — обязательный. Идентификатор владельца календаря.
  Для `type` со значением `user` установится идентификатор текущего пользователя, если не передать значение в `ownerId`
- `name` `string` — обязательный. Название календаря
- `description` `string` — необязательный. Описание календаря
- `color` `string` — необязательный. Цвет календаря
- `text_color` `string` — необязательный. Цвет текста в календаре
- `export` `object` — необязательный. Объект [параметров экспорта календаря](#export)

### Параметр export

- `ALLOW` `boolean` — необязательный. Разрешить экспорт календаря. Возможные значения:
  - `true` — разрешить
  - `false` — запретить
- `SET` `string` — необязательный. Период, за который производить экспорт. Возможные значения:
  - `all` — за весь период
  - `3_9` — 3 месяца до и 9 после
  - `6_12` — 6 месяцев до и 12 после

## Ответ

HTTP-статус: 200

```json
{
    "result": 190,
    "time": {
        "start": 1733812564.64201,
        "finish": 1733812565.71673,
        "duration": 1.0747201442718506,
        "processing": 0.05963897705078125,
        "date_start": "2024-12-08T06:36:04+00:00",
        "date_finish": "2024-12-08T06:36:05+00:00"
    }
}
```

### Возвращаемые данные

- `result` `integer`. Идентификатор созданного календаря

## Ошибки

HTTP-статус: 400

```json
{
    "error": "",
    "error_description": "Не задан обязательный параметр \"type\" для метода \"calendar.section.add\""
}
```

- — — Не задан обязательный параметр "type" для метода "calendar.section.add". Не передан обязательный параметр `type`
- — — Не задан обязательный параметр "ownerId" для метода "calendar.section.add". Не передан обязательный параметр `ownerId` и параметр `type` не равен `user`
- — — Недопустимое значение параметра "name". Передан неверный формат данных в поле `name`
- — — Недопустимое значение параметра "description". Передан неверный формат данных в поле `description`
- — — Доступ запрещен. Нет прав для создания календаря с переданным `type`
- — — При создании секции произошла ошибка. Другая ошибка

## Примеры запроса

### cURL (Webhook)

```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"type":"user","ownerId":2,"name":"New Section","description":"Description for section","color":"#9cbeee","text_color":"#283000","export":{"ALLOW":false,"SET":"3_9"}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/calendar.section.add
```

### cURL (OAuth)

```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"type":"user","ownerId":2,"name":"New Section","description":"Description for section","color":"#9cbeee","text_color":"#283000","export":{"ALLOW":false,"SET":"3_9"},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/calendar.section.add
```

### JS (TS)

```ts
// 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 CalendarSectionAddResult = number

try {
  const response = await $b24.actions.v2.call.make<CalendarSectionAddResult>({
    method: 'calendar.section.add',
    params: {
      type: 'user',
      ownerId: 2,
      name: 'New Section',
      description: 'Description for section',
      color: '#9cbeee',
      text_color: '#283000',
      export: {
        ALLOW: false,
        SET: '3_9',
      },
    },
    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('Created calendar with ID:', result)
  }
} catch (error) {
  // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
  console.error(error)
}
```

### JS (UMD)

```html
<!-- 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 addCalendarSection() {
    try {
      // Initialize the SDK inside a Bitrix24 frame
      const $b24 = await B24Js.initializeB24Frame()

      const response = await $b24.actions.v2.call.make({
        method: 'calendar.section.add',
        params: {
          type: 'user',
          ownerId: 2,
          name: 'New Section',
          description: 'Description for section',
          color: '#9cbeee',
          text_color: '#283000',
          export: {
            ALLOW: false,
            SET: '3_9',
          },
        },
        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('Created calendar with ID:', result)
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  }

  document.addEventListener('DOMContentLoaded', addCalendarSection)
</script>
```

### Python

```python
from b24pysdk.errors import BitrixAPIError, BitrixSDKException

try:
    bitrix_response = client.calendar.section.add(
        type="user",
        owner_id=2,
        name="New Section",
        description="Description for section",
        color="#9cbeee",
        text_color="#283000",
        export={
            "ALLOW": False,
            "SET": "3_9",
        },
    ).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}")
```

### PHP

```php
try {
    $response = $b24Service
        ->core
        ->call(
            'calendar.section.add',
            [
                'type'        => 'user',
                'ownerId'     => 2,
                'name'        => 'New Section',
                'description' => 'Description for section',
                'color'       => '#9cbeee',
                'text_color'  => '#283000',
                'export'      => [
                    'ALLOW' => false,
                    'SET'   => '3_9',
                ],
            ]
        );

    $result = $response
        ->getResponseData()
        ->getResult();

    echo 'Success: ' . print_r($result, true);
    // Нужная вам логика обработки данных
    processData($result);

} catch (Throwable $e) {
    error_log($e->getMessage());
    echo 'Error adding calendar section: ' . $e->getMessage();
}
```

### BX24.js

```js
BX24.callMethod(
    'calendar.section.add',
    {
        type: 'user',
        ownerId: 2,
        name: 'New Section',
        description: 'Description for section',
        color: '#9cbeee',
        text_color: '#283000',
        export: {
            ALLOW: false,
            SET: '3_9'
        }
    }
);
```

### PHP CRest

```php
require_once('crest.php');

$result = CRest::call(
    'calendar.section.add',
    [
        'type' => 'user',
        'ownerId' => 2,
        'name' => 'New Section',
        'description' => 'Description for section',
        'color' => '#9cbeee',
        'text_color' => '#283000',
        'export' => [
            'ALLOW' => false,
            'SET' => '3_9'
        ]
    ]
);

echo '<PRE>';
print_r($result);
echo '</PRE>';
```

### Go

```go
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "calendar.section.add", b24.Params{
	"type":        "user",
	"ownerId":     2,
	"name":        "New Section",
	"description": "Description for section",
	"color":       "#9cbeee",
	"text_color":  "#283000",
	"export": b24.Params{
		"ALLOW": false,
		"SET":   "3_9",
	},
})
if err != nil {
	return fmt.Errorf("calendar.section.add: %w", err)
}

var newID b24.ID
if err := json.Unmarshal(res.Result, &newID); err != nil {
	return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println("идентификатор:", newID)
```

Оригинал в официальной документации: https://apidocs.bitrix24.ru/api-reference/calendar/calendar-section-add.html
