{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ledger.abivia.com/api/json/balance-return.schema.json",
  "title": "Balance Response",
  "description": "A Ledger Account Balance as returned by the JSON API.",
  "type": "object",
  "oneOf": [
    {
      "$ref": "https://ledger.abivia.com/api/json/error-response.schema.json"
    },
    {
      "properties": {
        "time": {
          "description": "The time the request was processed.",
          "type": "string",
          "pattern": "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}Z"
        },
        "balance": {
          "type": "object",
          "properties": {
            "account": {
              "description": "A reference to the Account.",
              "type": "object",
              "properties": {
                "code": {
                  "description": "Account code used for reporting.",
                  "type": "string"
                },
                "uuid": {
                  "description": "UUID of the account.",
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "amount": {
              "description": "The current account balance.",
              "type": "string",
              "pattern": "[+\\-]?[0-9]+(\\.[0-9]*)?"
            },
            "currency": {
              "description": "The currency this balance represents.",
              "type": "string"
            },
            "domain": {
              "code": {
                "description": "The domain identifier.",
                "type": "string",
                "pattern": "^[^ \t\r\n*]*$"
              },
              "uuid": {
                "description": "UUID of the domain.",
                "type": "string",
                "format": "uuid"
              }
            }
          }
        }
      },
      "required": ["time", "balance"]
    }
  ]
}
