{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/popp/json-schema/popp-create-custom-field-request-schema.json",
  "title": "CreateCustomFieldRequest",
  "description": "Request body for creating a custom field.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/popp-custom-fields-beta-api-openapi.yml#/components/schemas/CreateCustomFieldRequest",
  "type": "object",
  "properties": {
    "fieldKey": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "title": "Field Key",
      "description": "Your stable key for the field. Must be unique among the organization's active fields."
    },
    "label": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "title": "Label",
      "description": "Human-readable display name for the field."
    },
    "type": {
      "type": "string",
      "enum": [
        "TEXT",
        "TEXT_ARRAY",
        "NUMBER",
        "DATE",
        "BOOLEAN"
      ],
      "title": "Type",
      "description": "The field's data type. Cannot be changed after creation."
    },
    "hasFixedOptions": {
      "type": "boolean",
      "title": "Has Fixed Options",
      "description": "When true, `allowedValues` is required and non-empty (a dropdown). When false, `allowedValues` must be empty or omitted."
    },
    "allowedValues": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "title": "Allowed Values",
      "description": "The permitted values. Required and non-empty when `hasFixedOptions` is true; must be empty or omitted otherwise."
    },
    "displayAs": {
      "type": "string",
      "enum": [
        "DATE",
        "AGE"
      ],
      "title": "Display As",
      "description": "How the value is displayed. `AGE` shows a `DATE` field as a whole-number age in years, derived from the stored date on the day it is read; it is rejected on any other type. Defaults to `DATE`."
    }
  },
  "required": [
    "fieldKey",
    "label",
    "type",
    "hasFixedOptions"
  ],
  "additionalProperties": false
}