{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/emporix/main/json-schema/emporix-customer-schema.json",
  "title": "Customer",
  "description": "Customer profile.",
  "x-generated": "2026-10-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/emporix-customer-management-openapi.yml#/components/schemas/Customer",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Customer unique identifier generated when the customer profile is created."
    },
    "customerNumber": {
      "type": "string",
      "description": "Customer unique number generated when the customer profile is created."
    },
    "title": {
      "type": "string"
    },
    "firstName": {
      "type": "string"
    },
    "middleName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    },
    "contactEmail": {
      "type": "string"
    },
    "contactPhone": {
      "type": "string"
    },
    "company": {
      "type": "string"
    },
    "preferredLanguage": {
      "type": "string",
      "default": "en_US",
      "description": "Customer preferred language."
    },
    "preferredCurrency": {
      "type": "string",
      "default": "USD",
      "minLength": 3,
      "maxLength": 3,
      "description": "Customer's preferred currency, compliant with the ISO 4217 standard."
    },
    "preferredSite": {
      "type": "string",
      "default": "main",
      "description": "Customer preferred site."
    },
    "accounts": {
      "type": "array",
      "description": "List of accounts associated with the customer profile.",
      "items": {
        "$ref": "#/$defs/AccountId"
      }
    },
    "addresses": {
      "type": "array",
      "description": "List of customer addresses.",
      "items": {
        "$ref": "#/$defs/Address"
      }
    },
    "defaultAddress": {
      "$ref": "#/$defs/Address"
    },
    "businessModel": {
      "type": "string",
      "enum": [
        "B2B",
        "B2C"
      ],
      "description": "Property indicating business model of customer. When customer is assigned to any company then it is `B2B`. Otherwise it is `B2C`."
    },
    "b2b": {
      "$ref": "#/$defs/B2BGet"
    },
    "mixins": {
      "type": "object",
      "description": "Customer account additional properties.",
      "additionalProperties": true
    },
    "metadata": {
      "$ref": "#/$defs/DefaultDtoMetadata"
    },
    "lastLogin": {
      "type": "string",
      "description": "Customer last login date. ",
      "format": "date-time"
    }
  },
  "$defs": {
    "AccountId": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Customer email address."
        },
        "providerId": {
          "type": "string",
          "description": "Customer account unique identifier generated by an external identity provider.\n\n**Note**: This field is only applicable if the user has been registered through social login."
        }
      }
    },
    "Address": {
      "type": "object",
      "description": "Customer address information.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Customer address' unique identifier generated when the address is added to the customer account."
        },
        "contactName": {
          "type": "string"
        },
        "companyName": {
          "type": "string"
        },
        "street": {
          "type": "string"
        },
        "streetNumber": {
          "type": "string"
        },
        "streetAppendix": {
          "type": "string"
        },
        "extraLine1": {
          "type": "string"
        },
        "extraLine2": {
          "type": "string"
        },
        "extraLine3": {
          "type": "string"
        },
        "extraLine4": {
          "type": "string"
        },
        "zipCode": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "country": {
          "type": "string",
          "maxLength": 2,
          "minLength": 2
        },
        "state": {
          "type": "string"
        },
        "contactPhone": {
          "type": "string"
        },
        "isDefault": {
          "type": "boolean",
          "default": false,
          "description": "Flag indicating whether the address is the customer default address."
        },
        "tags": {
          "type": "array",
          "description": "",
          "items": {
            "type": "string"
          }
        },
        "metadata": {
          "$ref": "#/$defs/DefaultDtoMetadata"
        },
        "mixins": {
          "type": "object",
          "description": "Customer address' additional properties.",
          "additionalProperties": true
        }
      },
      "required": [
        "contactName"
      ]
    },
    "B2BGet": {
      "type": "object",
      "description": "Additional properties for B2B customer. If the `companyRegistrationId` property is provided, an additional validation for customer details executes - `firstName`, `lastName` and `company` values have to be provided.",
      "properties": {
        "companyRegistrationId": {
          "type": "string",
          "description": "Registration number of the company."
        },
        "legalEntities": {
          "type": "array",
          "items": {
            "properties": {
              "id": {
                "type": "string",
                "description": "ID of legal entity."
              },
              "name": {
                "type": "string",
                "description": "Name of legal entity."
              },
              "contactAssignmentId": {
                "type": "string",
                "description": "ID of contact assignment."
              }
            }
          }
        }
      }
    },
    "BasicMetadataDto": {
      "title": "DefaultDtoMetadata",
      "type": "object",
      "properties": {
        "mixins": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "description": "Links to mixin schemas."
    },
    "DefaultDtoMetadata": {
      "title": "DefaultDtoMetadata",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/BasicMetadataDto"
        },
        {
          "type": "object",
          "properties": {
            "version": {
              "type": "integer"
            }
          }
        }
      ]
    }
  }
}