{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/atlar/json-schema/atlar-glaccount-schema.json",
  "title": "GLAccount",
  "description": "A GL account represents a general ledger account in your ERP system.\nIt can belong to one or many GL entities.\nWhen the account is of type BANK, it can have a one-to-one relationship with an Atlar financial-data account.\n",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/atlar-gl-accounts-api-openapi.yml#/components/schemas/GLAccount",
  "type": "object",
  "properties": {
    "id": {
      "$ref": "#/$defs/ResourceID"
    },
    "externalId": {
      "$ref": "#/$defs/ExternalID"
    },
    "organizationId": {
      "$ref": "#/$defs/OrganizationID"
    },
    "thirdPartyId": {
      "description": "ID of the associated third-party, e.g. the ERP in which the account is held.",
      "type": "string",
      "readOnly": true
    },
    "associatedConnections": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AssociatedConnection"
      },
      "x-omitempty": true
    },
    "accountId": {
      "x-atlar-internal-comment": "When introducing this field the API was meant to be used internally. If this ever changes,\nwe should think twice if it should be here or not. For future readers see the following link\nhttps://github.com/atlar-tech/atlar-platform/pull/6657#discussion_r1504183494",
      "$ref": "#/$defs/ResourceID",
      "description": "The Atlar account resource id that correlates to this general ledger account."
    },
    "glEntityIds": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The Atlar general ledger entity ids that this general ledger account is associated with."
    },
    "name": {
      "type": "string",
      "description": "The name of the general ledger account.",
      "minLength": 1,
      "maxLength": 64
    },
    "number": {
      "type": "string",
      "description": "The number of the general ledger account.",
      "minLength": 1,
      "maxLength": 255
    },
    "currency": {
      "$ref": "#/$defs/CurrencyCode",
      "description": "The currency of the general ledger account."
    },
    "type": {
      "$ref": "#/$defs/GLAccountType"
    },
    "displayType": {
      "type": "string",
      "description": "The general ledger account types are not uniform across other third-party systems.\nSo instead, we accept the raw type from the third-party system that we can display to the user.\n",
      "minLength": 1,
      "maxLength": 64
    },
    "ignored": {
      "type": "boolean",
      "description": "Whether the account is ignored in the accounting system."
    },
    "inactive": {
      "type": "boolean",
      "description": "Whether the GL account is inactive in the customer's ERP."
    },
    "version": {
      "$ref": "#/$defs/ResourceVersion"
    },
    "etag": {
      "$ref": "#/$defs/ETag"
    },
    "created": {
      "$ref": "#/$defs/CreatedTimestamp"
    },
    "updated": {
      "$ref": "#/$defs/UpdatedTimestamp"
    }
  },
  "required": [
    "id",
    "externalId",
    "organizationId",
    "name",
    "displayType",
    "glEntityIds",
    "ignored",
    "inactive",
    "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
    },
    "GLAccountType": {
      "type": "string",
      "description": "The general ledger account types are not uniform across other third-party systems.\nHowever, it is useful to have a consistent type for the general ledger account. For example,\nto suggest accounts one can match with a bank account.\n",
      "enum": [
        "UNSPECIFIED",
        "BANK",
        "ACCOUNTS_PAYABLE",
        "ACCOUNTS_RECEIVABLE"
      ]
    },
    "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
    }
  }
}