{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/4chems-com/json-schema/4chems-com-tenant-create-in-schema.json",
  "title": "TenantCreateIn",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/4chems-com-tenants-api-openapi.yml#/components/schemas/TenantCreateIn",
  "properties": {
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]{0,30}$",
      "title": "Slug"
    },
    "name": {
      "type": "string",
      "maxLength": 200,
      "minLength": 1,
      "title": "Name"
    },
    "initial_admin_email": {
      "type": "string",
      "format": "email",
      "title": "Initial Admin Email"
    },
    "attestation": {
      "$ref": "#/$defs/AttestationIn"
    },
    "legal_entity": {
      "$ref": "#/$defs/LegalEntityIn"
    },
    "allow_duplicate_domain": {
      "type": "boolean",
      "title": "Allow Duplicate Domain",
      "default": false
    }
  },
  "type": "object",
  "required": [
    "slug",
    "name",
    "initial_admin_email",
    "attestation",
    "legal_entity"
  ],
  "$defs": {
    "AttestationIn": {
      "properties": {
        "attested": {
          "type": "boolean",
          "title": "Attested"
        },
        "email": {
          "type": "string",
          "format": "email",
          "title": "Email"
        }
      },
      "type": "object",
      "required": [
        "attested",
        "email"
      ],
      "title": "AttestationIn",
      "description": "Attestation checkbox (NFR-006 pt 8). Stored with timestamp on the tenant row."
    },
    "LegalEntityIn": {
      "properties": {
        "country": {
          "type": "string",
          "pattern": "^[A-Z]{2}$",
          "title": "Country"
        },
        "legal_entity_type": {
          "type": "string",
          "pattern": "^[A-Z]{2,3}_[A-Z0-9][A-Z0-9_]*$",
          "title": "Legal Entity Type"
        },
        "other_label": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 80,
              "minLength": 2
            },
            {
              "type": "null"
            }
          ],
          "title": "Other Label"
        },
        "name": {
          "type": "string",
          "maxLength": 200,
          "minLength": 1,
          "title": "Name"
        }
      },
      "type": "object",
      "required": [
        "country",
        "legal_entity_type",
        "name"
      ],
      "title": "LegalEntityIn",
      "description": "Composite legal-entity input validated against the country catalog.\n\nRules:\n- *country* must be a supported market (validated at field level via SupportedCountry,\n  caught in the model validator against the loaded catalog).\n- *legal_entity_type* must appear in that country's catalog file.\n- When *legal_entity_type* is ``<CC>_OTHER``, *other_label* is required (2-80 chars).\n- For any other type, *other_label* must be absent."
    }
  }
}