{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/atlar/json-schema/atlar-glentity-schema.json",
  "title": "GLEntity",
  "description": "A GL entity represents a legal entity in your ERP system.\nIt can have a one-to-one relationship with an Atlar Entity.\n",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/atlar-gl-entities-api-openapi.yml#/components/schemas/GLEntity",
  "type": "object",
  "properties": {
    "currency": {
      "$ref": "#/$defs/CurrencyCode",
      "description": "Base currency of the GL entity when known (e.g. subsidiary currency from the ERP)."
    },
    "id": {
      "$ref": "#/$defs/ResourceID"
    },
    "externalId": {
      "$ref": "#/$defs/ExternalID"
    },
    "organizationId": {
      "$ref": "#/$defs/OrganizationID"
    },
    "entityId": {
      "$ref": "#/$defs/ResourceID",
      "description": "The Atlar entity resource id that correlates to this GL entity."
    },
    "thirdPartyId": {
      "description": "ID of the associated third-party, e.g. the ERP in which the entity is held.",
      "type": "string",
      "readOnly": true
    },
    "associatedConnections": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AssociatedConnection"
      },
      "x-omitempty": true
    },
    "name": {
      "type": "string",
      "description": "The name of the GL entity.",
      "minLength": 1,
      "maxLength": 64
    },
    "version": {
      "$ref": "#/$defs/ResourceVersion"
    },
    "etag": {
      "$ref": "#/$defs/ETag"
    },
    "created": {
      "$ref": "#/$defs/CreatedTimestamp"
    },
    "updated": {
      "$ref": "#/$defs/UpdatedTimestamp"
    }
  },
  "required": [
    "id",
    "externalId",
    "organizationId",
    "name",
    "version",
    "etag",
    "created",
    "updated"
  ],
  "$defs": {
    "AssociatedConnection": {
      "type": "object",
      "properties": {
        "connectionId": {
          "type": "string"
        }
      },
      "required": [
        "connectionId"
      ]
    },
    "CreatedTimestamp": {
      "type": "string",
      "format": "date-time",
      "description": "Time at which the resource was created.",
      "readOnly": true
    },
    "CurrencyCode": {
      "type": "string",
      "description": "Three-letter ISO 4217 currency code.",
      "minLength": 3,
      "maxLength": 3,
      "pattern": "^[A-Z]{3,3}$"
    },
    "ETag": {
      "type": "string",
      "description": "[ETag](https://en.wikipedia.org/wiki/HTTP_ETag) based on the\nresource version. This can be passed along in `If-Match` HTTP\nheader when updating a resource to perform a conditional\nupdate.",
      "pattern": "^version:\\d{1,4}$",
      "readOnly": true
    },
    "ExternalID": {
      "type": "string",
      "pattern": "^[a-zA-Z0-9._\\-+=]{1,64}$",
      "description": "External ID is optional to use, but if used, the Atlar platform will persist it, index it, as well as require it to be unique across all resources. It is possible to retrieve a resource using the external ID using the prefix `external:`.",
      "x-omitempty": true
    },
    "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
    }
  }
}