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-fields

List 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/:entityType

The custom fields that apply to one kind of record.

Path Parameters

NameTypeDescription
entityType
stringrequired"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/create

Define a custom field.

The field names are `name` and `type` — not `label` and `fieldType`. Groups are managed under `/custom-fields/groups`.

Body Parameters

NameTypeDescription
name
stringrequiredThe field's label. This is the key you see in output.
type
stringrequired"TEXT", "TEXTAREA", "NUMBER", "DATE", "BOOLEAN", "SELECT", "EMAIL", "URL" or "PHONE".
options
stringThe 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
booleanWhether the field must be filled. Defaults to false.
showInDocuments
booleanPrint the field on documents for the record. Defaults to false.
order
numberSort position on the form. Defaults to 0.
groupId
numberPut 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/:id

Update 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

NameTypeDescription
id
numberrequiredThe custom field's numeric id.

Body Parameters

NameTypeDescription
name
stringThe field's label.
type
stringThe field's type.
options
stringJSON string of choices for a SELECT field. Setting it to null while the type is SELECT is rejected.
isRequired
booleanWhether the field must be filled.
showInDocuments
booleanPrint the field on documents.
order
numberSort position.
groupId
numberMove 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/:id

Delete a custom field and every value stored under it.

Path Parameters

NameTypeDescription
id
numberrequiredThe 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/product

Attach 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

NameTypeDescription
customFieldId
numberrequiredThe 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/:productId

One 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

NameTypeDescription
productId
numberrequiredThe 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/values

Set 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

NameTypeDescription
productId
numberrequiredThe product's numeric id.

Body Parameters

NameTypeDescription
customFieldId
numberrequiredWhich field to set.
value
stringrequiredThe 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
}

Last updated