{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/atlar/json-schema/atlar-entity-schema.json",
  "title": "Entity",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/atlar-entities-api-openapi.yml#/components/schemas/Entity",
  "type": "object",
  "properties": {
    "id": {
      "$ref": "#/$defs/ResourceID"
    },
    "organizationId": {
      "$ref": "#/$defs/OrganizationID"
    },
    "parentId": {
      "description": "This optional field identifies a parent entity, indicating this entity is a subsidiary or branch to the parent. A missing Parent Entity ID implies the entity is without parent company.",
      "type": "string",
      "minLength": 32,
      "maxLength": 64
    },
    "legalName": {
      "type": "string",
      "description": "Legal name of the entity. E.g. your company's legal business name.",
      "readOnly": true
    },
    "alias": {
      "description": "An additional name, an alias, for the entity.",
      "type": "string",
      "maxLength": 255,
      "x-omitempty": true,
      "readOnly": true
    },
    "name": {
      "description": "Name of the entity automatically populated by Atlar. Alias if set, otherwise legal name.",
      "type": "string",
      "maxLength": 255,
      "readOnly": true
    },
    "nationalIdentifier": {
      "$ref": "#/$defs/NationalIdentifier",
      "readOnly": true
    },
    "address": {
      "$ref": "#/$defs/Address",
      "readOnly": true
    },
    "created": {
      "$ref": "#/$defs/CreatedTimestamp"
    },
    "updated": {
      "$ref": "#/$defs/UpdatedTimestamp"
    },
    "version": {
      "$ref": "#/$defs/ResourceVersion"
    }
  },
  "required": [
    "id",
    "organizationId",
    "legalName",
    "name",
    "created",
    "updated",
    "version"
  ],
  "$defs": {
    "Address": {
      "description": "Postal address.",
      "type": "object",
      "properties": {
        "country": {
          "$ref": "#/$defs/CountryCode",
          "x-go-type-skip-optional-pointer": true
        },
        "countrySubdivision": {
          "$ref": "#/$defs/CountrySubdivision",
          "x-go-type-skip-optional-pointer": true
        },
        "city": {
          "type": "string",
          "maxLength": 64
        },
        "postalCode": {
          "type": "string",
          "maxLength": 16
        },
        "streetName": {
          "type": "string",
          "maxLength": 64
        },
        "streetNumber": {
          "type": "string",
          "maxLength": 16
        }
      }
    },
    "CountryCode": {
      "type": "string",
      "description": "Two-letter ISO 3166-1 alpha2 country code.",
      "minLength": 2,
      "maxLength": 2,
      "pattern": "^[A-Z]{2,2}$"
    },
    "CountrySubdivision": {
      "type": "string",
      "description": "Country subdivision code (second part of the ISO 3166-2 code).\nE.g. state code `CA` for the state of California in the USA, `ON` for the province of Ontario in Canada, `NSW` for the state of New South Wales in Australia.\nISO 3166-2 codes can be found on the ISO website, for example, for the USA: https://www.iso.org/obp/ui/#iso:code:3166:US.\nIn the USA the state code is required for domestic payments, in Canada the province code is required for domestic payments.",
      "maxLength": 6,
      "pattern": "^[A-Z]{2,2}-[A-Z0-9]{1,3}$"
    },
    "CreatedTimestamp": {
      "type": "string",
      "format": "date-time",
      "description": "Time at which the resource was created.",
      "readOnly": true
    },
    "MarketCode": {
      "type": "string",
      "description": "Two-letter ISO 3166-1 alpha2 country code.",
      "minLength": 2,
      "maxLength": 2,
      "pattern": "^[A-Z]{2,2}$"
    },
    "NationalIdentifier": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Type of the national identifier.",
          "enum": [
            "CIVIC",
            "COMPANY"
          ]
        },
        "market": {
          "$ref": "#/$defs/MarketCode"
        },
        "number": {
          "type": "string",
          "description": "The identifier itself."
        }
      },
      "required": [
        "type",
        "market",
        "number"
      ]
    },
    "OrganizationID": {
      "type": "string",
      "description": "Unique resource identifier for an Organization."
    },
    "ResourceID": {
      "type": "string",
      "description": "Unique resource identifier.",
      "minLength": 32,
      "maxLength": 64
    },
    "ResourceVersion": {
      "type": "integer",
      "description": "Resource version. Starts at value `1` when the resource is\ncreated and increases by one for each successive update.",
      "minimum": 1,
      "readOnly": true
    },
    "UpdatedTimestamp": {
      "type": "string",
      "format": "date-time",
      "description": "Time at which the resource was last updated.",
      "readOnly": true
    }
  }
}