Custom Fields
Extra fields on clients, vendors, products and contacts. A field is defined once, attached to one or more entity types, and then given a value per record.
Use cases: Use this to carry your own identifiers and attributes through Glance — a customer number from your ERP, a product's shelf life, a contact's preferred channel.
GET
/custom-fieldsList every custom field defined for the company.
`entityTypes` says which kinds of record the field applies to. A field that belongs to a group takes the group's entity type rather than its own.
Request
curl -X GET "https://api.glance.co.il/custom-fields" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"Response
Response
{
"customFields": [
{
"id": 31,
"name": "מספר לקוח אצלנו",
"type": "TEXT",
"options": null,
"isRequired": false,
"showInDocuments": true,
"order": 0,
"groupId": null,
"entityTypes": [
"ENTITIES"
],
"productGroupIds": [],
"creator": {
"id": 12,
"firstName": "מיכל",
"lastName": "לוי",
"email": "michal@example.co.il"
}
}
]
}GET
/custom-fields/type/:entityTypeThe custom fields that apply to one kind of record.
Path Parameters
| Name | Type | Description | |
|---|---|---|---|
entityType | string | required | "ENTITIES" (clients and vendors), "PRODUCTS" or "CONTACTS". These three are the whole set. |
Request
curl -X GET "https://api.glance.co.il/custom-fields/type/:entityType" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"Response
Response
{
"customFields": [
{
"id": 31,
"name": "מספר לקוח אצלנו",
"type": "TEXT",
"isRequired": false,
"showInDocuments": true,
"order": 0,
"groupId": null,
"entityTypes": [
"ENTITIES"
]
}
]
}POST
/custom-fields/createDefine a custom field.
The field names are `name` and `type` — not `label` and `fieldType`. Groups are managed under `/custom-fields/groups`.
Body Parameters
| Name | Type | Description | |
|---|---|---|---|
name | string | required | The field's label. This is the key you see in output. |
type | string | required | "TEXT", "TEXTAREA", "NUMBER", "DATE", "BOOLEAN", "SELECT", "EMAIL", "URL" or "PHONE". |
options | string | The choices for a "SELECT" field, as a **JSON string** rather than an array. Required for SELECT and meaningless otherwise. | |
entityTypes | string[] | Which kinds of record the field applies to: "ENTITIES", "PRODUCTS", "CONTACTS". Defaults to an empty list, which attaches it to nothing. | |
isRequired | boolean | Whether the field must be filled. Defaults to false. | |
showInDocuments | boolean | Print the field on documents for the record. Defaults to false. | |
order | number | Sort position on the form. Defaults to 0. | |
groupId | number | Put the field in a custom-field group. A grouped field takes the group's entity type instead of its own. |
Request
curl -X POST "https://api.glance.co.il/custom-fields/create" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "example_name",
"type": "example_type",
"options": "example_options",
"entityTypes": "example_entityTypes",
"isRequired": true,
"showInDocuments": true,
"order": 0,
"groupId": 0
}'Response
Response
{
"success": true,
"customFieldId": 31
}PUT
/custom-fields/edit/:idUpdate a custom field's definition. All fields optional.
`entityTypes` cannot be changed here — attach the field to another kind of record with the attach endpoints instead. A body with nothing to update answers `{ success: true, message: "No fields to update" }`.
Path Parameters
| Name | Type | Description | |
|---|---|---|---|
id | number | required | The custom field's numeric id. |
Body Parameters
| Name | Type | Description | |
|---|---|---|---|
name | string | The field's label. | |
type | string | The field's type. | |
options | string | JSON string of choices for a SELECT field. Setting it to null while the type is SELECT is rejected. | |
isRequired | boolean | Whether the field must be filled. | |
showInDocuments | boolean | Print the field on documents. | |
order | number | Sort position. | |
groupId | number | Move the field into a group; `null` takes it out. |
Request
curl -X PUT "https://api.glance.co.il/custom-fields/edit/:id" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "example_name",
"type": "example_type",
"options": "example_options",
"isRequired": true,
"showInDocuments": true,
"order": 0,
"groupId": 0
}'Response
Response
{
"success": true
}DELETE
/custom-fields/delete/:idDelete a custom field and every value stored under it.
Path Parameters
| Name | Type | Description | |
|---|---|---|---|
id | number | required | The custom field's numeric id. |
Request
curl -X DELETE "https://api.glance.co.il/custom-fields/delete/:id" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"Response
Response
{
"success": true
}POST
/custom-fields/attach/productAttach an existing custom field to a kind of record, so it appears on every record of that kind.
Three routes, one per kind: `/custom-fields/attach/product`, `/custom-fields/attach/entity` and `/custom-fields/attach/contact`. Each has its own permission.
Body Parameters
| Name | Type | Description | |
|---|---|---|---|
customFieldId | number | required | The field to attach. |
Request
curl -X POST "https://api.glance.co.il/custom-fields/attach/product" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customFieldId": 0
}'Response
Response
{
"success": true,
"relationId": 208
}GET
/custom-fields/products/:productIdOne product's custom fields, with the values it carries.
Every field defined for products is listed, with `value: null` where the product has none — so this doubles as the form definition. Values are always strings, whatever the field's `type`. `GET /custom-fields/entities/:entityId` and `GET /custom-fields/contacts/:contactId` do the same for clients/vendors and contacts.
Path Parameters
| Name | Type | Description | |
|---|---|---|---|
productId | number | required | The product's numeric id. |
Request
curl -X GET "https://api.glance.co.il/custom-fields/products/:productId" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"Response
Response
{
"customFields": [
{
"id": 44,
"name": "חיי מדף",
"type": "NUMBER",
"isRequired": false,
"showInDocuments": false,
"order": 0,
"groupId": null,
"entityTypes": [
"PRODUCTS"
],
"value": "24"
}
]
}POST
/custom-fields/products/:productId/valuesSet one custom field's value on a product.
One field per call: there is no `values` array. `POST /custom-fields/entities/:entityId/values` and `POST /custom-fields/contacts/:contactId/values` are the same for clients/vendors and contacts.
Path Parameters
| Name | Type | Description | |
|---|---|---|---|
productId | number | required | The product's numeric id. |
Body Parameters
| Name | Type | Description | |
|---|---|---|---|
customFieldId | number | required | Which field to set. |
value | string | required | The value, always as a string — a number, date or boolean is sent as its text form. |
Request
curl -X POST "https://api.glance.co.il/custom-fields/products/:productId/values" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customFieldId": 0,
"value": "example_value"
}'Response
Response
{
"success": true
}