# catalog.document.add

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

Создать документ складского учета
Scope: `catalog`
Кто может выполнять метод: пользователь с правом «Создание и редактирование» на нужный тип документа

## Описание

Метод `catalog.document.add` создает новый документ складского учета.

## Параметры

- `fields` `object` — обязательный. Поля документа ([подробное описание](#fields))

### Параметр fields

- `docType` `char` — обязательный. Тип документа. Возможные значения:
  - `A` — поступление,
  - `S` — оприходование,
  - `M` — перемещение между складами,
  - `R` — возврат,
  - `D` — списание.
  Актуальные типы документов можно получить методом [catalog.enum.getStoreDocumentTypes](https://chugunov.pro/api-bitrix24/catalog/enum/catalog-enum-get-store-document-types/)
- `currency` `crm_currency.CURRENCY` — обязательный. Валюта документа в формате ISO 4217, например `RUB`. Значение нельзя изменить после создания. 
  Чтобы получить список валют с кодами используйте метод [crm.currency.list](https://chugunov.pro/api-bitrix24/crm/currency/crm-currency-list/)
- `responsibleId` `user.id` — обязательный. Идентификатор ответственного
- `siteId` `char` — необязательный. Код сайта, к которому относится документ. По умолчанию — `s1`. 
  Параметр актуален для коробочных Битрикс, для облачных Битрикс значение стандартное — `s1`
- `dateDocument` `datetime` — необязательный. Дата проведения документа в формате ISO 8601
- `title` `string` — необязательный. Название документа
- `commentary` `char` — необязательный. Комментарий к документу
- `total` `double` — необязательный. Общая сумма по товарам документа. Значение рассчитывается автоматически после проведения, но может быть задано вручную
- `docNumber` `string` — необязательный. Внутренний номер документа. Если не передать, генерируется автоматически
- `createdBy` `user.id` — необязательный. Идентификатор пользователя, создавшего документ. Администратор может указать любое значение, по умолчанию заполняется текущим пользователем

## Ответ

```json
{
    "result": {
        "document": {
            "commentary": "Плановое пополнение склада",
            "createdBy": 29,
            "currency": "RUB",
            "dateCreate": "2025-10-30T11:19:38+03:00",
            "dateDocument": null,
            "dateModify": "2025-10-30T11:19:38+03:00",
            "dateStatus": "2025-10-30T11:19:38+03:00",
            "docNumber": "IN-00042",
            "docType": "A",
            "id": 11,
            "modifiedBy": 29,
            "responsibleId": 29,
            "siteId": "s1",
            "status": "N",
            "statusBy": null,
            "title": "Поступление от Поставщик-1",
            "total": null
        }
    },
    "time": {
        "start": 1761805178,
        "finish": 1761805178.991429,
        "duration": 0.9914290904998779,
        "processing": 0,
        "date_start": "2025-10-30T09:19:38+03:00",
        "date_finish": "2025-10-30T09:19:38+03:00",
        "operating_reset_at": 1761805778,
        "operating": 0.2595658302307129
    }
}
```

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

- `result` `object`. Корневой элемент ответа
- `document` `catalog_document`. Объект с данными созданного документа
- `time` `time`. Информация о времени выполнения запроса

## Ошибки

```json
{
    "error": "0",
    "error_description": "DOC_TYPE isn't available"
}
```

- `0` — Недостаточно прав для сохранения документа. У пользователя нет права на создание документа нужного типа
- `0` — DOC_TYPE isn't available. Передан недопустимый тип документа
- `0` — Складской учет недоступен на вашем тарифе. Складской учет недоступен на вашем тарифе
- `0` — -. Иные внутренние ошибки при добавлении документа

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

### cURL (Webhook)

```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"docType":"A","currency":"RUB","responsibleId":29,"docNumber":"IN-00042","title":"Поступление от Поставщик-1","commentary":"Плановое пополнение склада"}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/catalog.document.add
```

### cURL (OAuth)

```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"docType":"A","currency":"RUB","responsibleId":29,"docNumber":"IN-00042","title":"Поступление от Поставщик-1","commentary":"Плановое пополнение склада"},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/catalog.document.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, ISODate } from '@bitrix24/b24jssdk'

declare const $b24: B24Frame

// Shape of the payload returned in result (match the "response handling" section of the page)
type DocumentAddResult = {
  document: {
    commentary: string | null,
    createdBy: number,
    currency: string,
    dateCreate: ISODate | null,
    dateDocument: ISODate | null,
    dateModify: ISODate | null,
    dateStatus: ISODate | null,
    docNumber: string,
    docType: string,
    id: number,
    modifiedBy: number,
    responsibleId: number,
    siteId: string,
    status: string,
    statusBy: number | null,
    title: string | null,
    total: number | null,
  }
}

try {
  const response = await $b24.actions.v2.call.make<DocumentAddResult>({
    method: 'catalog.document.add',
    params: {
      fields: {
        docType: 'A',
        currency: 'RUB',
        responsibleId: 29,
        docNumber: 'IN-00042',
        title: 'Goods receipt from Supplier-1',
        commentary: 'Planned warehouse replenishment',
      },
    },
    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 document with ID:', result.document.id, 'status:', result.document.status)
  }
} 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 addDocument() {
    try {
      // Initialize the SDK inside a Bitrix24 frame
      const $b24 = await B24Js.initializeB24Frame()

      const response = await $b24.actions.v2.call.make({
        method: 'catalog.document.add',
        params: {
          fields: {
            docType: 'A',
            currency: 'RUB',
            responsibleId: 29,
            docNumber: 'IN-00042',
            title: 'Goods receipt from Supplier-1',
            commentary: 'Planned warehouse replenishment',
          },
        },
        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 document with ID:', result.document.id, 'status:', result.document.status)
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  }

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

### Python

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

try:
    bitrix_response = client.catalog.document.add(
        fields={
            "docType": "A",
            "currency": "RUB",
            "responsibleId": 29,
            "docNumber": "IN-00042",
            "title": "Поступление от Поставщик-1",
            "commentary": "Плановое пополнение склада",
        },
    ).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(
        'catalog.document.add',
        [
            'fields' => [
                'docType' => 'A',
                'currency' => 'RUB',
                'responsibleId' => 29,
                'docNumber' => 'IN-00042',
                'title' => 'Поступление от Поставщик-1',
                'commentary' => 'Плановое пополнение склада'
            ]
        ]
    );

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

echo 'Success: ' . print_r($result, true);
processData($result);

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

### BX24.js

```js
BX24.callMethod(
    'catalog.document.add',
    {
        fields: {
            docType: 'A',
            currency: 'RUB',
            responsibleId: 29,
            docNumber: 'IN-00042',
            title: 'Поступление от Поставщик-1',
            commentary: 'Плановое пополнение склада'
        }
    },
    function(result)
    {
        if (result.error())
            console.error(result.error());
        else
            console.log(result.data());
    }
);
```

### PHP CRest

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

$result = CRest::call(
    'catalog.document.add',
    [
        'fields' => [
            'docType' => 'A',
            'currency' => 'RUB',
            'responsibleId' => 29,
            'docNumber' => 'IN-00042',
            'title' => 'Поступление от Поставщик-1',
            'commentary' => 'Плановое пополнение склада'
        ]
    ]
);

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

### Go

```go
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "catalog.document.add", b24.Params{
	"fields": b24.Params{
		"docType":       "A",
		"currency":      "RUB",
		"responsibleId": 29,
		"docNumber":     "IN-00042",
		"title":         "Поступление от Поставщик-1",
		"commentary":    "Плановое пополнение склада",
	},
})
if err != nil {
	return fmt.Errorf("catalog.document.add: %w", err)
}

// Метод заворачивает ответ в объект с ключом "document".
raw, ok := b24.Unwrap(res.Result, "document")
if !ok {
	return fmt.Errorf("в ответе нет ключа document")
}

var item struct {
	Commentary string `json:"commentary"`
	CreatedBy  int    `json:"createdBy"`
	Currency   string `json:"currency"`
	DateCreate string `json:"dateCreate"`
	DateModify string `json:"dateModify"`
	DateStatus string `json:"dateStatus"`
}
if err := json.Unmarshal(raw, &item); err != nil {
	return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.Commentary, item.CreatedBy)
```

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