## Inventory document item fields

`GET /v1/catalog-document-elements/fields`

Returns the schema of all inventory document item fields. Helps build the request body for creating and updating an item.

## Parameters

| Parameter | Type | Default | Description |
|----------|-----|-----------|---------|
| `refresh` (query) | string | `false` | Pass `true` to get the schema bypassing the cache. Example: `?refresh=true` |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/catalog-document-elements/fields" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/catalog-document-elements/fields" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/catalog-document-elements/fields', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
const createOnly = Object.entries(data.fields)
  .filter(([, field]) => field.createOnly)
  .map(([name]) => name)
console.log('Set only on creation:', createOnly)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/catalog-document-elements/fields', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
const createOnly = Object.entries(data.fields)
  .filter(([, field]) => field.createOnly)
  .map(([name]) => name)
console.log('Set only on creation:', createOnly)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.fields` | object | Map of item fields: the key is the field name, the value is its description |
| `data.fields.<field>.type` | string | Value type |
| `data.fields.<field>.readonly` | boolean | `true` — the field is filled by the system and is not accepted on creation or update |
| `data.fields.<field>.createOnly` | boolean | Present with the value `true` on fields that are set only on creation. On update such a field is rejected with `400 READONLY_FIELD` |
| `data.fields.<field>.required` | boolean | Present with the value `true` on fields required on creation |
| `data.fields.<field>.label` | string | Field caption |
| `data.fields.<field>.description` | string | Field description |
| `data.batch` | string[] | Operations available in bulk mode through [Batch](/docs/batch): `create`, `update`, `delete` |
| `meta.warnings` | array | Present only if the field schema could not be fully retrieved from Bitrix24. Contains an object with the code `fields_partial` and a `message` text: the response holds only the fields from the Vibecode schema, and some captions may be missing. Retry the request |

The `label` and `description` values contain the field name itself.

Item fields:

| Field | Type | RO | Description |
|------|-----|:--:|---------|
| `id` | number | yes | Item ID |
| `docId` | number | | Inventory document the item belongs to. Required on creation, set only on creation. List: [`GET /v1/catalog-documents`](/docs/entities/catalog-documents/list) |
| `elementId` | number | | Product. Required on creation, set only on creation. List: [`GET /v1/catalog-products`](/docs/entities/catalog-products/list) |
| `amount` | number | | Product quantity |
| `purchasingPrice` | number | | Purchase price per unit |
| `storeFrom` | number | | Source warehouse. `null` if not set. List: [`GET /v1/warehouses`](/docs/entities/warehouses/list) |
| `storeTo` | number | | Destination warehouse. `null` if not set. List: [`GET /v1/warehouses`](/docs/entities/warehouses/list) |

Which warehouses an item needs depends on the document type — see [inventory document items](/docs/entities/catalog-document-elements).

## Response example

```json
{
  "success": true,
  "data": {
    "fields": {
      "id": {
        "type": "number",
        "readonly": true,
        "label": "id",
        "description": "id"
      },
      "docId": {
        "type": "number",
        "readonly": false,
        "createOnly": true,
        "required": true,
        "label": "docId",
        "description": "docId"
      },
      "elementId": {
        "type": "number",
        "readonly": false,
        "createOnly": true,
        "required": true,
        "label": "elementId",
        "description": "elementId"
      },
      "amount": {
        "type": "number",
        "readonly": false,
        "label": "amount",
        "description": "amount"
      },
      "purchasingPrice": {
        "type": "number",
        "readonly": false,
        "label": "purchasingPrice",
        "description": "purchasingPrice"
      },
      "storeFrom": {
        "type": "number",
        "readonly": false,
        "label": "storeFrom",
        "description": "storeFrom"
      },
      "storeTo": {
        "type": "number",
        "readonly": false,
        "label": "storeTo",
        "description": "storeTo"
      }
    },
    "batch": [
      "create",
      "update",
      "delete"
    ]
  }
}
```

## Error response example

401 — the API key was not passed:

```json
{
  "success": false,
  "error": {
    "code": "MISSING_API_KEY",
    "message": "API key required. Pass via X-Api-Key header."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not passed |
| 401 | `INVALID_API_KEY` | The passed API key was not found |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 403 | `SCOPE_DENIED` | The API key does not have the `catalog` scope |
| 429 | `RATE_LIMITED` | Rate limit exceeded: 300 requests per minute per portal, all API keys of the portal share one limit. The effective value is in the `x-ratelimit-limit` header. Retry after the delay in the `Retry-After` header |

Full list of common API errors — [Errors](/docs/errors).

## See also

- [Create an item](/docs/entities/catalog-document-elements/create)
- [Update an item](/docs/entities/catalog-document-elements/update)
- [Inventory document items](/docs/entities/catalog-document-elements)
- [Inventory document fields](/docs/entities/catalog-documents/fields)
- [Entity reference](/docs/entity-api)
