{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/atlar/json-schema/atlar-payment-batch-schema.json",
  "title": "PaymentBatch",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/atlar-direct-debits-api-openapi.yml#/components/schemas/PaymentBatch",
  "type": "object",
  "properties": {
    "id": {
      "description": "ID of the batch.",
      "$ref": "#/$defs/ResourceID"
    },
    "organizationId": {
      "$ref": "#/$defs/OrganizationID"
    },
    "treatment": {
      "$ref": "#/$defs/BatchTreatmentType"
    },
    "input": {
      "description": "Deprecated - use `inputDetails` and `inputContent`.",
      "$ref": "#/$defs/BatchInputMetadata",
      "x-atlar-fields-enum-skip": true
    },
    "inputContent": {
      "$ref": "#/$defs/BatchInputContent"
    },
    "inputDetails": {
      "description": "Summary of the batch input: amount totals per currency (`sums`) and optional date\nrange across requested execution dates.",
      "$ref": "#/$defs/PaymentBatchDetails"
    },
    "results": {
      "description": "Deprecated - use `resultSummary` and `resultDetails`. Summary of processing results.\n\nThe summary is only populated when the batch `status` is `COMPLETED`.\n\nDetailed processing results can be retrieved using\nhttps://docs.atlar.com/v2.0/reference/get_payments-v2beta-credit-transfer-batches-id-results.\n",
      "$ref": "#/$defs/BatchResultsSummary",
      "readOnly": true,
      "x-atlar-fields-enum-skip": true
    },
    "resultSummary": {
      "description": "Counts of how input records were processed (total / succeeded / failed / skipped).\nOnly populated when the batch `status` is `COMPLETED`.",
      "$ref": "#/$defs/BatchResultSummary"
    },
    "resultDetails": {
      "description": "Amount totals per currency for successfully processed payments in the batch.\nOnly populated when the batch `status` is `COMPLETED`. May differ from\n`inputDetails.sums` when records were skipped.",
      "$ref": "#/$defs/PaymentBatchDetails"
    },
    "status": {
      "$ref": "#/$defs/BatchStatus",
      "readOnly": true
    },
    "errors": {
      "$ref": "#/$defs/BatchErrors"
    },
    "approvalSteps": {
      "deprecated": true,
      "x-deprecated-reason": "Batch-level approval steps are no longer populated. Use the approval steps on each payment. This field will be removed in the future.",
      "description": "Batch approval steps, including who approved or rejected (`approver`), step\n`status`, and `requiredRoleIds`.\n\nApproval steps will only be available once the batch\n`status` is `COMPLETED`. I.e. no action must be taken\nbased on the absence of approval steps (empty array).\n",
      "type": "array",
      "items": {
        "$ref": "#/$defs/PaymentApprovalStep"
      },
      "readOnly": true
    },
    "externalId": {
      "$ref": "#/$defs/ExternalID"
    },
    "approvalResults": {
      "description": "Counts of fully approved vs rejected payments in this batch.",
      "$ref": "#/$defs/ApprovalResults"
    },
    "creatorUserId": {
      "$ref": "#/$defs/ResourceID",
      "description": "ID of the user that created the batch.",
      "readOnly": true
    },
    "sourceAccountIds": {
      "type": "array",
      "description": "IDs of the accounts that the payments in this batch are initiated from.",
      "items": {
        "$ref": "#/$defs/ResourceID"
      },
      "uniqueItems": true,
      "readOnly": true,
      "x-omitempty": true
    },
    "metadata": {
      "$ref": "#/$defs/Metadata"
    },
    "etag": {
      "$ref": "#/$defs/ETag"
    },
    "version": {
      "$ref": "#/$defs/ResourceVersion"
    },
    "created": {
      "$ref": "#/$defs/CreatedTimestamp"
    },
    "updated": {
      "$ref": "#/$defs/UpdatedTimestamp"
    }
  },
  "required": [
    "treatment",
    "id",
    "organizationId",
    "etag",
    "status",
    "version",
    "created",
    "updated",
    "input",
    "inputContent",
    "inputDetails",
    "approvalSteps",
    "approvalResults"
  ],
  "$defs": {
    "Amount": {
      "type": "object",
      "properties": {
        "currency": {
          "$ref": "#/$defs/CurrencyCode"
        },
        "stringValue": {
          "description": "A string representation of the amount value. This will be\na decimal number if the currency has decimals. The number\nis not formatted for display purposes (e.g. with locale\nspecific thousand separator) and always contains the dot\n`.` character as decimal separator.",
          "type": "string"
        },
        "value": {
          "description": "The amount value as an integer (int64) represented in\ncurrency minor units (e.g. 15.02 EUR is represented as the\nvalue 1502).",
          "type": "integer",
          "format": "int64"
        }
      },
      "required": [
        "currency",
        "stringValue",
        "value"
      ]
    },
    "ApprovalResults": {
      "type": "object",
      "properties": {
        "approved": {
          "type": "integer",
          "description": "Number of fully approved credit transfers."
        },
        "rejected": {
          "type": "integer",
          "description": "Number of rejected credit transfers."
        }
      },
      "required": [
        "approved",
        "rejected"
      ]
    },
    "ApprovalStatus": {
      "type": "string",
      "description": "The status of the approval step.",
      "enum": [
        "PENDING",
        "APPROVED",
        "REJECTED"
      ]
    },
    "BatchAmountSums": {
      "type": "array",
      "description": "The total amount sum per each currency of resources in this batch.\n\nNote that batch amount sums reported on the batch input metadata\nrefer to the total amount sums of the input records (resources)\nwhile the batch amount sums reported on the batch result refer\nto the total amount sums of the successfully processed records (resources).\nThis means that there may be a difference in the total sum for the input\nvs the result, due to skipped records (resources).\n",
      "items": {
        "$ref": "#/$defs/Amount"
      },
      "readOnly": true
    },
    "BatchErrors": {
      "description": "A list of error details if the batch failed. Only populated once the batch has reached status `COMPLETED`. Only the first 255 errors (if any) will be present in this list. If there are more errors, the complete list can be retrieved using the results endpoint for the batch.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/ErrorDetails"
      },
      "maxItems": 255
    },
    "BatchInputContent": {
      "description": "Metadata describing the input contents that was used to create this batch.",
      "type": "object",
      "readOnly": true,
      "properties": {
        "contentType": {
          "type": "string"
        },
        "recordCount": {
          "type": "integer",
          "description": "Total count of input records (resources) in the input batch.",
          "readOnly": true
        },
        "size": {
          "type": "integer",
          "format": "int64",
          "description": "The size of the input content in bytes.\n\nIf the batch was created by uploading a file using `multipart/form-data` the `contentSize` will be the file size.\n\nIf the batch was created with JSON input this will be the raw JSON size.\n"
        },
        "checksum": {
          "type": "string",
          "description": "A checksum of the batch input contents.\n\nThe checksum digest value will be prefixed by an\nidentifier of the hash algorithm used, e.g. `sha256`. A\ncolon `:` is used as separator between the algorithm\nidentifier and the digest value.\n"
        },
        "filename": {
          "type": "string",
          "description": "The name of the file that was used as input to create the batch.\n\nFilename will only available if the batch input was provided using `multipart/form-data`.\n"
        }
      },
      "required": [
        "recordCount",
        "contentType",
        "size",
        "checksum"
      ]
    },
    "BatchInputMetadata": {
      "description": "Metadata describing the original input that was used to create a payments batch.",
      "type": "object",
      "properties": {
        "recordCount": {
          "type": "integer",
          "description": "Deprecated. Has moved into `content`. Total count of input records (payments) in the input batch.",
          "readOnly": true
        },
        "sums": {
          "$ref": "#/$defs/BatchAmountSums"
        },
        "content": {
          "$ref": "#/$defs/BatchInputContent"
        }
      },
      "required": [
        "recordCount",
        "sums",
        "content"
      ]
    },
    "BatchResultSummary": {
      "description": "Aggregate summary of batch processing results.",
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "description": "Number of input records that were attempted to be processed."
        },
        "succeeded": {
          "type": "integer",
          "description": "Number of input records that resulted in a successfully created resource."
        },
        "failed": {
          "type": "integer",
          "description": "Number of failed records."
        },
        "skipped": {
          "type": "integer",
          "description": "Number of input records that were skipped."
        }
      },
      "required": [
        "total",
        "succeeded",
        "failed",
        "skipped"
      ]
    },
    "BatchResultsSummary": {
      "description": "Aggregate summary of payment batch processing results.",
      "type": "object",
      "properties": {
        "total": {
          "type": "integer",
          "description": "Deprecated. Moved to `processed`. Number of input records that were attempted to be processed."
        },
        "succeeded": {
          "type": "integer",
          "description": "Deprecated. Moved to `processed`. Number of input records that resulted in a successfully created payment."
        },
        "failed": {
          "type": "integer",
          "description": "Deprecated. Moved to `processed`. Number of failed records."
        },
        "skipped": {
          "type": "integer",
          "description": "Deprecated. Moved to `processed`. Number of input records that were skipped."
        },
        "processed": {
          "$ref": "#/$defs/BatchResultSummary"
        },
        "sums": {
          "$ref": "#/$defs/BatchAmountSums"
        }
      },
      "required": [
        "total",
        "succeeded",
        "failed",
        "skipped",
        "processed",
        "sums"
      ]
    },
    "BatchStatus": {
      "type": "string",
      "description": "The status of this batch. The status only refers to the\nprocessing of the input, not the processing or success of\nthe resources themselves.\n\n`COMPLETED` is the only end-state. Failure is indicated by a non-empty list of `errors`.\n",
      "enum": [
        "CREATED",
        "PROCESSING_STARTED",
        "COMPLETED"
      ]
    },
    "BatchTreatmentType": {
      "type": "string",
      "deprecated": true,
      "description": "Deprecated: You can approve or reject on batch and individual level regardless of the treatment type.\n",
      "enum": [
        "INDIVIDUAL_PAYMENTS",
        "BATCH"
      ]
    },
    "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
    },
    "ErrorDetails": {
      "type": "object",
      "description": "Error detail.",
      "properties": {
        "code": {
          "description": "An error code for this error. Not always present.",
          "type": "string"
        },
        "error": {
          "description": "A description of this specific error.",
          "type": "string"
        },
        "field": {
          "description": "The field which has an error. This only set if the error has to do with a specific field, such as for validation errors. Nested fields are concatenated with `.`, as well as indexed fields in lists.",
          "type": "string"
        }
      }
    },
    "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
    },
    "Metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      },
      "description": "Metadata is a `string-string` key-value container that\ncan be used to store information known at the time of resource\ncreation. This can be retrieved later on, for instance when a\npayment or expected transaction is reconciled with the booked\ntransaction on the bank statement.\n\nMetadata can have at most 20 entries. Keys may have a\nmaximum length of 64 chars and values a maximum length of 512\nchars.\n\nBy default, this field is optional. It is possible to make it\nrequired in the Atlar Dashboard by visiting the [Metadata keys\npage](https://app.atlar.com/metadata-keys). Requirement rules\ncan be specified per API resource. Both the Dashboard and the\nAPI will then enforce these rules and give validation errors\nwhen the required fields are not set.",
      "maxProperties": 20,
      "x-omitempty": true
    },
    "OrganizationID": {
      "type": "string",
      "description": "Unique resource identifier for an Organization."
    },
    "PaymentApprovalStep": {
      "type": "object",
      "properties": {
        "id": {
          "description": "The ID of this step. Used when approving/rejecting.",
          "type": "string",
          "readOnly": true
        },
        "approvalChainId": {
          "description": "The ID of the approval chain that triggered this approval step.",
          "type": "string",
          "readOnly": true
        },
        "requiredRoleIds": {
          "type": "array",
          "description": "IDs of the Roles that can approve/reject. Not specified if the step was automatically approved based on an auto-approval chain.",
          "items": {
            "type": "string"
          },
          "maxItems": 10,
          "uniqueItems": true,
          "readOnly": true,
          "x-omitempty": true
        },
        "status": {
          "description": "The status of the approval step. `PENDING` if step is not yet interacted with.",
          "$ref": "#/$defs/ApprovalStatus",
          "readOnly": true
        },
        "approver": {
          "description": "User information about the user who approved/rejected. Omitted if step is not yet approved/rejected.",
          "$ref": "#/$defs/UserAuditInfo",
          "readOnly": true
        },
        "updated": {
          "description": "Timestamp when approved/rejected. Omitted if the step is not yet approved/rejected.",
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "autoApproved": {
          "type": "boolean"
        },
        "allowCreatorApproval": {
          "description": "Allow approval by the user creating this resource if they have the role required for this step. By default, this is not allowed to conform with a four-eyes principle where approval by another person is required.",
          "type": "boolean",
          "readOnly": true
        },
        "sequentialApproval": {
          "type": "boolean",
          "description": "If true, the approval steps for this approval chain, specified by `approvalChainId`, need to be approved in the the order specified by `sequenceNumber`.",
          "readOnly": true
        },
        "sequenceNumber": {
          "type": "integer",
          "description": "The sequence number of this step in the approval chain.",
          "readOnly": true
        }
      },
      "required": [
        "id",
        "status",
        "approvalChainId",
        "autoApproved"
      ]
    },
    "PaymentBatchDetails": {
      "description": "Details summarizing the contents of the batch — primarily amount totals per currency.",
      "type": "object",
      "properties": {
        "sums": {
          "description": "Total amount sum per currency for the payments covered by this details object\n(input records when under `inputDetails`, successfully processed payments when\nunder `resultDetails`).",
          "$ref": "#/$defs/BatchAmountSums"
        }
      },
      "required": [
        "sums"
      ]
    },
    "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
    },
    "UserAuditInfo": {
      "type": "object",
      "description": "User information for audit trail.",
      "properties": {
        "id": {
          "$ref": "#/$defs/ResourceID",
          "description": "User ID"
        },
        "username": {
          "type": "string",
          "readOnly": true
        },
        "name": {
          "type": "string",
          "description": "User given name(s) information. May be a concatenation of firstname, lastname etc.",
          "readOnly": true
        },
        "roleId": {
          "type": "string",
          "description": "Role ID",
          "readOnly": true
        }
      },
      "required": [
        "id",
        "username"
      ]
    }
  }
}