{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/frihet-io/json-schema/frihet-io-client-create-schema.json",
  "title": "ClientCreate",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/frihet-io-clients-api-openapi.yml#/components/schemas/ClientCreate",
  "type": "object",
  "required": [
    "name"
  ],
  "properties": {
    "name": {
      "type": "string",
      "description": "Client name (person or company)"
    },
    "email": {
      "type": "string",
      "format": "email",
      "description": "Contact email"
    },
    "phone": {
      "type": "string",
      "description": "Phone number"
    },
    "taxId": {
      "type": "string",
      "description": "Tax identification number (NIF/CIF/VAT)"
    },
    "address": {
      "$ref": "#/$defs/Address"
    },
    "integrationSource": {
      "type": "string",
      "enum": [
        "hubspot",
        "pipedrive",
        "intercom",
        "mailchimp"
      ],
      "description": "Source integration when the client is imported from an external CRM or marketing tool."
    },
    "nextAction": {
      "$ref": "#/$defs/ClientNextAction"
    }
  },
  "$defs": {
    "Address": {
      "type": "object",
      "description": "Structured address. Canonical fields are `province` and `zip`.\nThe aliases `state` and `postalCode` are also accepted for backward compatibility.\n",
      "properties": {
        "street": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "province": {
          "type": "string",
          "description": "Province or state (canonical field)"
        },
        "zip": {
          "type": "string",
          "description": "Postal/ZIP code (canonical field)"
        },
        "country": {
          "type": "string"
        },
        "state": {
          "type": "string",
          "description": "Alias for `province` (backward compatibility)",
          "deprecated": true
        },
        "postalCode": {
          "type": "string",
          "description": "Alias for `zip` (backward compatibility)",
          "deprecated": true
        }
      }
    },
    "ClientNextAction": {
      "type": "object",
      "required": [
        "title",
        "status"
      ],
      "additionalProperties": false,
      "properties": {
        "title": {
          "type": "string",
          "maxLength": 500,
          "description": "Current next step for this client."
        },
        "dueDate": {
          "type": "string",
          "format": "date",
          "description": "Optional due date for the next action."
        },
        "status": {
          "type": "string",
          "enum": [
            "open",
            "done"
          ],
          "description": "Whether the next action is still open or already completed."
        },
        "source": {
          "type": "string",
          "enum": [
            "manual",
            "api",
            "integration",
            "system"
          ],
          "description": "Origin of the next action."
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "completedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}