[POST] .../v1/field/add
Creates a new additional field. All fields created through this method are saved with is_custom = true. Use this method to create a custom additional field for an entity that supports custom fields. The request requires key, name, entity_type and data_type; datatype must be one of string, int, decimal or bool. The key must contain only lowercase Latin letters, digits and underscores; it is saved with the field prefix and must be unique inside the selected entity type. Metadata is optional, empty metadata is stored as null and required controls whether future entity add/edit validation must receive a value for this field. The caller must have additional field add permission and the account tariff must allow additional fields. Missing body, invalid required fields, unsupported data_type, duplicate key, invalid key characters, denied permission, disabled tariff option, action-log errors and database errors are returned as HTTP 200 ErrorResult business errors.
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| data_type | String | Required | Field value data type. Allowed values: string, int, decimal, bool. |
| entity_type | String | Required | Entity the field is linked to. Allowed values: Default, RetailCustomer, Partner, DocPurchase, Item, DocPayment, DocAccountMovement, Task, Lead, Deal, Client, Ticket, User, OperatingCash. |
| key | String | Required | Field key, unique within entitytype, up to 30 characters. The field prefix is added when the value is saved. |
| metadata | String | Optional | Field metadata. Maximum length is 500 characters including escaping. Null or empty input is stored as null. |
| name | String | Required | Field name. Required and limited to 120 characters by current validation. |
| required | Boolean | Optional | Indicates whether the field is required. Default value is false. |
Request Example
{
"key": "color_code",
"name": "Color code",
"entity_type": "Item",
"data_type": "string",
"metadata": "{\u0022mask\u0022:\u0022^[A-Z0-9]\u002B$\u0022}",
"required": true
}
Response Parameters
| Name | Type | Description |
|---|---|---|
| ok | Boolean | Indicates whether the request completed successfully. |
| result | Insert | Created record result. |
Response Example
{
"ok": true,
"result": {
"new_id": 12
}
}