
## Invoice fields

`GET /v1/invoices/fields`

Returns the description of all invoice fields, including user fields (`ufCrm_*`).

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
curl -X GET https://vibecode.bitrix24.com/v1/invoices/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/invoices/fields', {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { success, data } = await res.json()
console.log('Fields:', Object.keys(data).length)
```

### JavaScript — OAuth application

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

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Read-only | Description |
|------|-----|:---:|---------|
| `id` | number | yes | Invoice ID |
| `title` | string | | Title |
| `stageId` | string | | Stage. Format: `DT31_{categoryId}:{stage}`. Stage list: `GET /v1/statuses?filter[entityId]=SMART_INVOICE_STAGE_{categoryId}` — categoryId depends on the Bitrix24 account. To find it: `GET /v1/invoices?limit=1&select=categoryId` or ask the administrator |
| `categoryId` | number | | Pipeline ID |
| `contactId` | number | | Payer contact ID. Lookup: `GET /v1/contacts` |
| `companyId` | number | | Payer company ID. Lookup: `GET /v1/companies` |
| `mycompanyId` | number | | Own company ID |
| `opportunity` | number | | Amount |
| `currencyId` | string | | Currency. List: `GET /v1/currencies` |
| `assignedById` | number | | Assignee. List: `GET /v1/users` |
| `createdBy` | number | yes | Creator ID |
| `createdTime` | datetime | yes | Creation date |
| `updatedTime` | datetime | yes | Modification date |

User fields (`ufCrm_*`) are returned in the response and are writable.

## Response example

```json
{
  "success": true,
  "data": {
    "fields": {
      "id": { "type": "number", "readonly": true, "label": "Invoice ID", "description": "Unique numeric invoice identifier." },
      "title": { "type": "string", "readonly": false, "label": "Title", "description": "Invoice title." },
      "assignedById": { "type": "number", "readonly": false, "label": "Assigned to", "description": "ID of the responsible user. List: GET /v1/users." }
    },
    "batch": ["create", "update", "delete"]
  }
}
```

3 of many fields are shown. See the full list in the table above.

## Available includes

The `GET /v1/invoices/fields` endpoint returns the list of available includes: `contact`, `company`.

Usage example: [Get invoices](/docs/entities/invoices/get#related-data).

More about includes: [Related data](/docs/includes).

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 403 | `SCOPE_DENIED` | API key lacks the `crm` scope |
| 401 | `TOKEN_MISSING` | API key has no configured tokens |

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

## See also

- [Create invoice](/docs/entities/invoices/create) — creating with fields
- [List invoices](/docs/entities/invoices/list) — filtering by fields
- [Entity API](/docs/entity-api) — general principles
