{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ledger.abivia.com/api/json/create.schema.json",
  "title": "Create Request",
  "description": "A create ledger request",
  "type": "object",
  "properties": {
    "accounts": {
      "type": "array"
    },
    "balances": {
      "description": "A List of opening balances.",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "description": "The account code. Must be an account defined by the templates or the accounts property.",
            "type": "string"
          },
          "amount": {
            "description": "The opening balance amount.",
            "type": "string",
            "pattern": "[+\\-]?[0-9]+(\\.[0-9]*)?"
          },
          "currency": {
            "description": "A currency code (as defined in the currencies property).",
            "type": "string"
          }
        },
        "required": ["amount", "code", "currency"]
      }
    },
    "currencies": {
      "description": "The currencies available to the ledger.",
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "code": {
            "description": "The currency identifier. The identifier is converted to uppercase.",
            "type": "string"
          },
          "decimals": {
            "description": "The number of decimal places to use with this currency.",
            "type": "integer"
          }
        },
        "required": ["code", "decimals"]
      }
    },
    "date": {
      "description": "An alias for transDate. If both are provided, transDate is used.",
      "type": "string"
    },
    "domains": {
      "description": "Zero or more domains (business units). If none is provided a default domain will be created.",
      "type": "array",
      "items": {
        "$ref": "https://ledger.abivia.com/api/json/domain.schema.json"
      }
    },
    "extra": {
      "description": "Arbitrary data for use by the application.",
      "type": "string"
    },
    "journals": {
      "description": "Zero or more (sub)journals.",
      "type": "array",
      "items": {
        "$ref": "https://ledger.abivia.com/api/json/journal.schema.json"
      }
    },
    "name": {
      "description": "The ledger name, language is assumed to be the current system locale.",
      "type": "string"
    },
    "names": {
      "description": "The ledger name in one or more languages.",
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "https://ledger.abivia.com/api/json/name.schema.json"
      }
    },
    "rules": {
      "description": "Ledger rule set.",
      "type": "object",
      "properties": {
        "account": {
          "description": "Rules pertaining to accounts.",
          "type": "object",
          "properties": {
            "codeFormat": {
              "description": "A regular expression that specifies the acceptable pattern for ledger account codes.",
              "type": "string",
              "default": "/[a-z0-9]+/i"
            },
            "postToCategory": {
              "description": "If true, journal entries can be posted to category accounts.",
              "type": "boolean",
              "default": false
            }
          }
        },
        "entry": {
          "description": "Rules pertaining to journal entries.",
          "type": "object",
          "properties": {
            "reviewed": {
              "description": "If set, all entries will be marked as reviewed when they are added.",
              "type": "boolean",
              "default": false
            }
          },
          "language": {
            "description": "Rules associated with language strings.",
            "type": "object",
            "properties": {
              "default": {
                "description": "The language code to be used when none is provided."
              }
            }
          },
          "pageSize": {
            "description": "The nominal number of items to return on a query that can be paged.",
            "type": "integer",
            "default": 100
          }
        }
      }
    },
    "template": {
      "description": "The name of a preset Chart of Accounts template to use.",
      "type": "string"
    },
    "transDate": {
      "description": "The journal opening date. If not provided, the current system time is used. Any date format that can be parsed by Carbon is acceptable.",
      "type": "string"
    }
  },
  "required": ["currencies"]
}
