Python API reference

The importable surface, documented from the docstrings the 100 percent docstring gate enforces.

SWIFT MT101 -> ISO 20022 pain.001 loader for the pain001 suite.

SWIFT MT101 (Request for Transfer) is the legacy message an account owner sends to instruct one or more credit transfers, and that ISO 20022 pain.001 (Customer Credit Transfer Initiation) replaces under the CBPR+ migration. This package bridges that gap: pass an MT101 text payload to parse_mt101() and get back the flat records that the pain001 library validates against the pain.001.001.09 schema and turns into pain.001 XML. An MT101 can carry several transactions, so one record is returned per transaction.

pain001_loader_mt101.parse_mt101(text)[source]

Parse an MT101 payload into pain.001 flat records.

An MT101 carries one or more credit-transfer instructions (repeating sequence B), so the returned list holds one record per transaction. Each record’s keys are the fields the pain001 library validates against the pain.001.001.09 schema. nb_of_txs and ctrl_sum describe the whole message and are repeated on every record.

Parameters:

text (str) – The MT101 payload as a string. A raw {4:...-} block-4 envelope, trailing whitespace and CRLF/LF differences are tolerated.

Returns:

A list of parsed flat records, one per sequence-B transaction. Keys whose source MT101 field is absent are omitted rather than guessed.

Raises:

ValueError – If a mandatory field is missing or malformed. The mandatory fields are :20: (sender’s reference), :30: (requested execution date), at least one transaction, and per transaction :21: (reference), :32B: (currency/amount) and a named beneficiary (:59: / :59A: / :59F:). The error message names the offending field.

Return type:

list[dict[str, Any]]

SWIFT MT101 -> ISO 20022 pain.001 flat-record loader.

SWIFT MT101 (Request for Transfer) is the legacy message an account owner sends to instruct one or more credit transfers from its account, and that ISO 20022 pain.001 (Customer Credit Transfer Initiation) replaces under the CBPR+ / SWIFT MX migration. This loader bridges that gap: pass an MT101 text payload and get back the flat records that the pain001 library validates against the pain.001.001.09 JSON schema and turns into pain.001 XML.

Unlike an MT103 (a single transfer), an MT101 carries a general sequence A plus one or more repeating sequence B transaction blocks, so parse_mt101() returns one record per transaction. Sequence-A ordering-customer / account-servicing-institution fields apply to every transaction unless a sequence-B block overrides them.

The MT101 grammar handled here is the mandatory + common-denominator subset needed to populate a schema-valid pain.001 record:

  • :20: Sender’s Reference (seq A) -> id + payment_information_id

  • :30: Requested Execution Date (seq A, YYMMDD) -> date and requested_execution_date (YYYY-MM-DD)

  • :21: Transaction Reference (seq B) -> payment_id

  • :32B: Currency + Amount (seq B) -> currency + payment_amount (SWIFT comma-decimal; note :32B: has no value date, unlike MT103 :32A:)

  • :50a: (H/G/F/K, seq A or B) Ordering Customer -> debtor_name / debtor_account_IBAN (and initiator_name)

  • :52a: (A/C/D, seq A or B) Account Servicing Institution -> debtor_agent_BIC

  • :57a: (A/C/D, seq B) Account With Institution -> creditor_agent_BIC

  • :59a: (—/A/F, seq B) Beneficiary -> creditor_name / creditor_account_IBAN

  • :70: Remittance Information (seq B, optional) -> remittance_information

  • :71A: Details of Charges (seq B) -> charge_bearer (OUR -> DEBT, BEN -> CRED, SHA -> SHAR)

The pain.001 schema requires several fields that MT101 does not carry; these are synthesised (documented so callers can override):

  • payment_method is always "TRF" (an MT101 requests credit transfers).

  • batch_booking defaults to False.

  • service_level_code defaults to "SEPA" (the schema enum admits only SEPA / URNS); override for non-SEPA payments.

  • charge_bearer defaults to "SLEV" when :71A: is absent or carries an unrecognised code (the schema requires a charge bearer).

  • remittance_information defaults to "NOTPROVIDED" when :70: is absent (the schema requires a non-empty value).

  • nb_of_txs is the count of sequence-B blocks and ctrl_sum is the sum of every transaction amount; both are repeated on every record, as in a pain.001 group header.

  • date (message creation date) reuses :30: because MT101 has no separate creation timestamp.

  • initiator_name reuses the ordering-customer name.

Out of scope (deliberately – this is the correct core mapping, not every optional MT101 field):

  • :23E: instruction codes and :25: / :28D: authorisation / sequence-number fields.

  • :33B: instructed currency/amount, :36: exchange rate and :21F: FX deal reference (FX legs).

  • :56a: intermediary and :51A: sending institutions.

  • :77B: regulatory reporting and :25A: charges account.

  • The SWIFT application header (blocks 1/2); this loader reads block 4 only (it will unwrap a {4:...-} envelope if present).

For a record to be schema-valid the ordering customer must supply a name and an IBAN account (:50a:), the account-servicing and account-with institutions must supply BICs (:52a: / :57a:) and the beneficiary account must be an IBAN (:59a:); a well-formed MT101 carries all of these. When such an optional source is absent the corresponding key is omitted rather than guessed – the loader never crashes on unexpected input. Only :20:, :30: and, per transaction, :21:, :32B: and a named beneficiary are treated as hard requirements that raise ValueError.

pain001_loader_mt101.loader.parse_mt101(text)[source]

Parse an MT101 payload into pain.001 flat records.

An MT101 carries one or more credit-transfer instructions (repeating sequence B), so the returned list holds one record per transaction. Each record’s keys are the fields the pain001 library validates against the pain.001.001.09 schema. nb_of_txs and ctrl_sum describe the whole message and are repeated on every record.

Parameters:

text (str) – The MT101 payload as a string. A raw {4:...-} block-4 envelope, trailing whitespace and CRLF/LF differences are tolerated.

Returns:

A list of parsed flat records, one per sequence-B transaction. Keys whose source MT101 field is absent are omitted rather than guessed.

Raises:

ValueError – If a mandatory field is missing or malformed. The mandatory fields are :20: (sender’s reference), :30: (requested execution date), at least one transaction, and per transaction :21: (reference), :32B: (currency/amount) and a named beneficiary (:59: / :59A: / :59F:). The error message names the offending field.

Return type:

list[dict[str, Any]]