API

The project provides both a REST API and a CLI for operational payment message workflows.

Installation

Install the package from PyPI. Python 3.9.2 or higher is required.

bash
python -m pip install pacs008

REST API

Start the built-in FastAPI server to expose HTTP endpoints for validation and generation.

Start the server

bash
uvicorn pacs008.api.app:app --reload --host 0.0.0.0 --port 8000

Endpoints

EndpointDescription
GET /healthHealth check — returns service status
POST /validateValidate payment data against the schema without generating XML
POST /generateGenerate XML synchronously and return the file
POST /generate/asyncSubmit an asynchronous generation job
GET /status/{job_id}Poll job status by ID
GET /download/{job_id}Download the generated XML once the job completes
DELETE /jobs/{job_id}Cancel a pending or running job
GET /docsInteractive Swagger UI for exploring and testing all endpoints

Validation example

Submit payment data for validation before generating XML.

bash
curl -X POST http://localhost:8000/api/validate \
  -H "Content-Type: application/json" \
  -d '{
    "message_type": "pacs.008.001.13",
    "data": [{
      "msg_id": "MSG-2026-001",
      "creation_date_time": "2026-01-15T10:30:00",
      "nb_of_txs": "1",
      "settlement_method": "CLRG",
      "interbank_settlement_date": "2026-01-15",
      "end_to_end_id": "E2E-INV-2026-001",
      "interbank_settlement_amount": "25000.00",
      "interbank_settlement_currency": "EUR",
      "charge_bearer": "SHAR",
      "debtor_name": "Acme Corp GmbH",
      "debtor_agent_bic": "DEUTDEFF",
      "creditor_agent_bic": "COBADEFF",
      "creditor_name": "Widget Industries SA"
    }]
  }'

Synchronous generation example

Generate a pacs.008.001.13 XML file from a JSON payload.

bash
curl -X POST http://localhost:8000/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "message_type": "pacs.008.001.13",
    "template": "pacs008/templates/pacs.008.001.13/template.xml",
    "schema": "pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd",
    "data": [{
      "msg_id": "MSG-2026-001",
      "creation_date_time": "2026-01-15T10:30:00",
      "nb_of_txs": "1",
      "settlement_method": "CLRG",
      "interbank_settlement_date": "2026-01-15",
      "end_to_end_id": "E2E-INV-2026-001",
      "tx_id": "TX-001",
      "interbank_settlement_amount": "25000.00",
      "interbank_settlement_currency": "EUR",
      "charge_bearer": "SHAR",
      "debtor_name": "Acme Corp GmbH",
      "debtor_agent_bic": "DEUTDEFF",
      "creditor_agent_bic": "COBADEFF",
      "creditor_name": "Widget Industries SA"
    }]
  }' --output pacs008_output.xml

Asynchronous generation

For larger files or pipeline use, submit an async job and poll for completion.

bash
# Submit the job
JOB=$(curl -s -X POST http://localhost:8000/api/generate/async \
  -H "Content-Type: application/json" \
  -d '{"message_type":"pacs.008.001.13","data":[...]}')

JOB_ID=$(echo $JOB | jq -r '.job_id')

# Poll for completion
curl http://localhost:8000/api/status/$JOB_ID

# Download the result
curl http://localhost:8000/api/download/$JOB_ID --output result.xml

CLI

The command-line interface accepts a data file, a message version, a template, and a schema. It validates the input and writes the generated XML to the output directory.

Basic usage

bash
pacs008 -t <message_type> \
  -m <template_file> \
  -s <schema_file> \
  -d <data_file>

Example

bash
pacs008 -t pacs.008.001.13 \
  -m pacs008/templates/pacs.008.001.13/template.xml \
  -s pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd \
  -d payments.csv

Dry-run mode

Use --dry-run to validate input data without generating XML. The exit code indicates whether validation passed (0) or failed (1).

bash
pacs008 -t pacs.008.001.13 \
  -m pacs008/templates/pacs.008.001.13/template.xml \
  -s pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd \
  -d payments.csv \
  --dry-run

Add --verbose for detailed output during generation.


Python API

Use the library directly in Python scripts or services.

Generate XML from a list of payment records

python
from pacs008 import generate_xml_string

payments = [{
    "msg_id": "MSG-2026-001",
    "creation_date_time": "2026-01-15T10:30:00",
    "nb_of_txs": "1",
    "settlement_method": "CLRG",
    "interbank_settlement_date": "2026-01-15",
    "end_to_end_id": "E2E-INV-2026-001",
    "tx_id": "TX-001",
    "interbank_settlement_amount": "25000.00",
    "interbank_settlement_currency": "EUR",
    "charge_bearer": "SHAR",
    "debtor_name": "Acme Corp GmbH",
    "debtor_agent_bic": "DEUTDEFF",
    "creditor_agent_bic": "COBADEFF",
    "creditor_name": "Widget Industries SA",
}]

xml = generate_xml_string(
    payments,
    "pacs.008.001.13",
    "pacs008/templates/pacs.008.001.13/template.xml",
    "pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd",
)
print(xml)

SWIFT compliance check

Validate and cleanse data against SWIFT character-set and field-length rules before generation.

python
from pacs008.compliance import cleanse_data_with_report

raw = [{"debtor_name": "Müller & Söhne™", "msg_id": "X" * 50}]
clean, report = cleanse_data_with_report(raw)
print(report.summary())

Docker

Run the API in a container using the bundled Dockerfile.

bash
docker build -t pacs008:latest .
docker run -p 8000:8000 pacs008:latest

IBAN and BIC validation

Validate financial identifiers independently of XML generation.

python
from pacs008.validation import validate_iban, validate_bic

is_valid, error = validate_iban("DE89370400440532013000", strict=False)
is_valid, error = validate_bic("DEUTDEFF", strict=False)

Streaming

Load large datasets in configurable chunks to limit memory usage.

python
from pacs008.data.loader import load_payment_data_streaming

for chunk in load_payment_data_streaming("large_payments.csv", chunk_size=500):
    print(f"Processing {len(chunk)} records")

Validation service

Run the full pre-generation validation pipeline programmatically.

python
from pacs008.validation import ValidationService, ValidationConfig

service = ValidationService()
report = service.validate_all(ValidationConfig(
    xml_message_type="pacs.008.001.13",
    xml_template_file_path="pacs008/templates/pacs.008.001.13/template.xml",
    xsd_schema_file_path="pacs008/templates/pacs.008.001.13/pacs.008.001.13.xsd",
    data_file_path="payments.csv",
))
print(report.is_valid, report.errors)

Required data fields

Every payment record must include the following fields. Version-specific fields are noted where applicable.

FieldDescriptionConstraint
msg_idMessage identifierMax 35 characters
creation_date_timeCreation timestampISO 8601 format
nb_of_txsNumber of transactionsPositive integer
settlement_methodSettlement methodCLRG, INDA, COVE, or INGA
end_to_end_idEnd-to-end identifierMax 35 characters
interbank_settlement_amountInterbank settlement amountDecimal, e.g. 25000.00
interbank_settlement_currencySettlement currencyISO 4217 code
charge_bearerCharge bearerDEBT, CRED, SHAR, or SLEV
debtor_nameDebtor nameMax 140 characters
debtor_agent_bicDebtor agent BIC8 or 11 characters
creditor_agent_bicCreditor agent BIC8 or 11 characters
creditor_nameCreditor nameMax 140 characters

Version-specific fields

FieldDescriptionConstraint
uetrUnique end-to-end transaction referenceUUID format — available from v08
mandate_idMandate identifierAvailable from v10
expiry_date_timeMessage expiry timestampAvailable in v13

Last updated: