{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ordogrid/json-schema/ordogrid-client-create-schema.json",
  "title": "ClientCreate",
  "description": "Company clients require name; individual clients require first_name and last_name. A complete address is required.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ordogrid-clients-api-openapi.yml#/components/schemas/ClientCreate",
  "additionalProperties": false,
  "allOf": [
    {
      "else": {
        "properties": {
          "name": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "if": {
        "properties": {
          "type": {
            "const": "individual"
          }
        }
      },
      "then": {
        "properties": {
          "first_name": {
            "minLength": 1,
            "type": "string"
          },
          "last_name": {
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "first_name",
          "last_name"
        ]
      }
    }
  ],
  "properties": {
    "address": {
      "$ref": "#/$defs/AddressInput"
    },
    "billing_address": {
      "anyOf": [
        {
          "$ref": "#/$defs/AddressInput"
        },
        {
          "type": "null"
        }
      ]
    },
    "contact_person": {
      "type": [
        "string",
        "null"
      ]
    },
    "email": {
      "type": [
        "string",
        "null"
      ]
    },
    "first_name": {
      "type": [
        "string",
        "null"
      ]
    },
    "invoice_requires_po": {
      "description": "null means false.",
      "type": [
        "boolean",
        "null"
      ]
    },
    "last_name": {
      "type": [
        "string",
        "null"
      ]
    },
    "name": {
      "type": [
        "string",
        "null"
      ]
    },
    "notes": {
      "type": [
        "string",
        "null"
      ]
    },
    "phone": {
      "type": [
        "string",
        "null"
      ]
    },
    "purchase_order_format": {
      "type": [
        "string",
        "null"
      ]
    },
    "quote_slug": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "enum": [
        "active",
        "archived"
      ],
      "type": "string"
    },
    "type": {
      "enum": [
        "company",
        "individual"
      ],
      "type": "string"
    },
    "vat_number": {
      "type": [
        "string",
        "null"
      ]
    },
    "website": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "type",
    "address"
  ],
  "type": "object",
  "$defs": {
    "AddressInput": {
      "additionalProperties": false,
      "properties": {
        "city": {
          "minLength": 1,
          "type": "string"
        },
        "country": {
          "description": "ISO 3166-1 alpha-2 code, e.g. BE. A country name in French, Dutch, English or German is accepted and stored as its code; an unknown country is a 400 INVALID_COUNTRY.",
          "minLength": 1,
          "type": "string"
        },
        "postal_code": {
          "minLength": 1,
          "type": "string"
        },
        "street": {
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "street",
        "city",
        "postal_code",
        "country"
      ],
      "type": "object"
    }
  }
}