Create Company Field Definition
Create a field definition that only this company sees. Superadmin only.
Works while CUSTOM_FIELDS_ENABLED is off for the company, so fields can be prepared before
the flag flips; an unknown company answers 404. The body is one variant per type and
carries exactly the attributes that type has; an unknown or frozen key answers 422. The
definition is always map-backed. label is required and needs one language written by hand
(is_auto_translated: false with non-empty text); the company's other languages are filled
by translation. That language must be one the deployment enables (LANGUAGES_ENABLED);
further hand-written languages outside that set are kept but never used as a translation
source. A regex must compile and must not be empty. select and multi_select need a
non-empty options list of {key, label, archived}: keys match
^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$, are unique and never change; every option label follows
the label source rule. entity_type: routine definitions cannot be required yet.
422 types: editable_by_unsupported (editable_by: customer), group_unknown (a group
outside the entity type's sections; for machines one of machine, contact,
additional_info, for routines routine), label_source_missing (a label, or an option
label at ["body","options",<i>,"label"], with no non-empty hand-written language the
deployment enables), regex_invalid, option_key_duplicate, option_missing (a restore
that drops a stored option key), required_unsupported_entity (required: true on a
routine definition). A label whose languages are all auto-translated and hold text answers
value_error.
409 types (FieldDefinitionConflict.type): field_exists (a live definition of this
company has the id), field_id_collision (a global definition, archived ones included, has
the id), field_archived_exists (an archived definition of this company has the id),
definition_unreadable (the stored row cannot be read by this build). The body of a 409 is
{"detail": <FieldDefinitionConflict>}.
To bring an archived definition back, repeat the request that answered
field_archived_exists with restore: true. That 409 carries the archived definition and
entities_with_value, the number of machines still holding a value for it. A restore
replaces the stored label and attributes with the body's, keeps the stored storage, and
requires the same type (else 409 field_type_mismatch); attributes the body leaves out
take their create defaults, so copy the attributes to keep from the archived definition
of the 409 into the create body, together with a label and restore: true. Its read-only
keys (id, owner_name, storage, key, archived, last_updated) answer 422
extra_forbidden. The company read lists the definition again. With no stored row,
restore: true creates normally.