---
source: https://carbone.io/examples/sepa-xml-credit-transfer/
title: "SEPA XML Generator: pain.001 Credit Transfer Files | Carbone"
description: "Generate SEPA XML files from ERP payment runs with the Carbone API: an XML template writes the pain.001.001.09 credit transfer file, control sums included."
generated_at: "2026-11-17"
---

# SEPA credit transfer file

Supplier payments from your ERP, as a pain.001 XML file

[![SEPA credit transfer file: XML generated from an XML template and JSON data](/examples/sepa-xml-credit-transfer/thumb-result.webp)](/examples/sepa-xml-credit-transfer/result.xml "Download the generated document")

[Download template](/examples/sepa-xml-credit-transfer/template.xml)

[Sample data](/examples/sepa-xml-credit-transfer/data.json)

[Download the generated XML](/examples/sepa-xml-credit-transfer/result.xml)

- **Template:** XML
- **Export as:** XML
- **Carbone:** 5.18+

Features

-   [Loop](/documentation/design/repetitions/with-arrays.md)
-   [Nested loop](/documentation/design/repetitions/with-arrays.md)
-   [Aggregation](/documentation/design/computation/aggregation.md)
-   [Condition](/documentation/design/conditions/overview.md)
-   [Alias](/documentation/design/substitutions/aliases.md)
-   [Date](/documentation/design/formatters/date.md)
-   [Number format](/documentation/design/formatters/number.md)

## Generate SEPA XML files from your ERP

Accounts payable teams pay their suppliers in payment runs: the ERP proposes the invoices that fall due, a treasurer approves the run, and the ERP writes a SEPA credit transfer file to upload to the bank through EBICS, a host-to-host link or online banking. ERP treasury modules, AP automation platforms and treasury management systems produce these files every week, often every day. The file is the pain.001 message of [ISO 20022](https://www.iso20022.org/), in XML: [Regulation (EU) No 260/2012](https://eur-lex.europa.eu/eli/reg/2012/260/oj) requires the ISO 20022 XML format when a company other than a microenterprise sends its credit transfers bundled in a file, and the [EPC SEPA Credit Transfer rulebook](https://www.europeanpaymentscouncil.eu/sites/default/files/kb/file/2024-11/EPC125-05%202025%20SCT%20Rulebook%20version%201.0.pdf) obliges a bank that accepts payment files to accept this format when its customer asks.

Your ERP sends the approved payments to the Carbone API as JSON and gets back a pain.001.001.09 file that follows the [EPC Customer-to-PSP implementation guidelines](https://www.europeanpaymentscouncil.eu/sites/default/files/kb/file/2024-11/EPC132-08%20SCT%20C2PSP%20IG%202025%20V1.0.pdf) in force since 5 October 2025. In this example, Northwind Antriebstechnik GmbH, a fictional drive systems manufacturer in Mannheim, pays 7 suppliers in 7 SEPA countries, in two blocks: 4 payments on 17 November 2026 and 3 on 20 November. The suppliers and their IBANs are fictional: each IBAN has valid check digits, on a bank code that no bank uses.

In this example, you will:

-   Count the transactions and add up the control sums of the file and of each block with aggregators
-   Repeat the payment blocks and their transactions with nested loops
-   Print the dates and the amounts in the formats of the schema
-   Convert the names and the addresses to the SEPA character set with an alias
-   Add the BIC and the structured creditor reference only when the data has them

## pain.001 file structure

| Block | Repeated | Main elements |
| --- | --- | --- |
| `GrpHdr` group header | Once | `MsgId` file reference, `CreDtTm` creation date and time, `NbOfTxs` number of transactions, `CtrlSum` total amount, `InitgPty` the company that sends the file |
| `PmtInf` payment information | Once per execution date and debit account | `PmtInfId`, `PmtMtd` `TRF`, `BtchBookg`, `NbOfTxs` and `CtrlSum` of the block, service level `SEPA`, `ReqdExctnDt` execution date, the debtor `Dbtr`, its IBAN `DbtrAcct`, the BIC of its bank `DbtrAgt`, charges `SLEV` |
| `CdtTrfTxInf` credit transfer transaction | Once per payment | `EndToEndId` payment reference, `InstdAmt` amount in euros, the supplier `Cdtr` and its address, its IBAN `CdtrAcct`, the BIC of its bank `CdtrAgt` when needed, the remittance information `RmtInf` |

Banks check `NbOfTxs` and `CtrlSum` against the transactions, in the group header and in each block, and can reject a file that does not match.

## SEPA credit transfer example

### Template

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09">{o.lang=en-us}{o.timezone=Europe/Berlin}{#sepa($text, $max) = $text:unaccent:replace('ß', 'ss'):substr(0, $max)}
  <CstmrCdtTrfInitn>
    <GrpHdr>
      <MsgId>{d.messageId}</MsgId>
      <CreDtTm>{d.createdAt:formatD('YYYY-MM-DDTHH:mm:ssZ')}</CreDtTm>
      <NbOfTxs>{d.batches[].payments[].amount:aggCount}</NbOfTxs>
      <CtrlSum>{d.batches[].payments[].amount:aggSum:formatN(2):replace(',', '')}</CtrlSum>
      <InitgPty>
        <Nm>{$sepa(d.debtor.name, 70):replace('&amp;', '+')}</Nm>
      </InitgPty>
    </GrpHdr>{d.batches[i]}
    <PmtInf>
      <PmtInfId>{d.batches[i].id}</PmtInfId>
      <PmtMtd>TRF</PmtMtd>
      <BtchBookg>{d.batches[i].batchBooking}</BtchBookg>
      <NbOfTxs>{d.batches[i].payments[].amount:aggCount}</NbOfTxs>
      <CtrlSum>{d.batches[i].payments[].amount:aggSum:formatN(2):replace(',', '')}</CtrlSum>
      <PmtTpInf>
        <SvcLvl>
          <Cd>SEPA</Cd>
        </SvcLvl>
        <CtgyPurp>
          <Cd>SUPP</Cd>
        </CtgyPurp>
      </PmtTpInf>
      <ReqdExctnDt>
        <Dt>{d.batches[i].executionDate:formatD('YYYY-MM-DD')}</Dt>
      </ReqdExctnDt>
      <Dbtr>
        <Nm>{$sepa(d.debtor.name, 70):replace('&amp;', '+')}</Nm>
        <PstlAdr>
          <StrtNm>{$sepa(d.debtor.street, 70)}</StrtNm>
          <BldgNb>{d.debtor.buildingNumber}</BldgNb>
          <PstCd>{d.debtor.postCode}</PstCd>
          <TwnNm>{$sepa(d.debtor.town, 35)}</TwnNm>
          <Ctry>{d.debtor.country}</Ctry>
        </PstlAdr>
      </Dbtr>
      <DbtrAcct>
        <Id>
          <IBAN>{d.debtor.iban}</IBAN>
        </Id>
      </DbtrAcct>
      <DbtrAgt>
        <FinInstnId>
          <BICFI>{d.debtor.bic}</BICFI>
        </FinInstnId>
      </DbtrAgt>
      <ChrgBr>SLEV</ChrgBr>{d.batches[i].payments[i]}
      <CdtTrfTxInf>
        <PmtId>
          <EndToEndId>{d.batches[i].payments[i].endToEndId}</EndToEndId>
        </PmtId>
        <Amt>
          <InstdAmt Ccy="EUR">{d.batches[i].payments[i].amount:formatN(2):replace(',', '')}</InstdAmt>
        </Amt>{d.batches[i].payments[i].supplier.bic:ifNEM:showBegin}
        <CdtrAgt>
          <FinInstnId>
            <BICFI>{d.batches[i].payments[i].supplier.bic}</BICFI>
          </FinInstnId>
        </CdtrAgt>{d.batches[i].payments[i].supplier.bic:showEnd}
        <Cdtr>
          <Nm>{$sepa(d.batches[i].payments[i].supplier.name, 70):replace('&amp;', '+')}</Nm>
          <PstlAdr>
            <StrtNm>{$sepa(d.batches[i].payments[i].supplier.street, 70)}</StrtNm>
            <BldgNb>{d.batches[i].payments[i].supplier.buildingNumber}</BldgNb>
            <PstCd>{d.batches[i].payments[i].supplier.postCode}</PstCd>
            <TwnNm>{$sepa(d.batches[i].payments[i].supplier.town, 35)}</TwnNm>
            <Ctry>{d.batches[i].payments[i].supplier.country}</Ctry>
          </PstlAdr>
        </Cdtr>
        <CdtrAcct>
          <Id>
            <IBAN>{d.batches[i].payments[i].supplier.iban}</IBAN>
          </Id>
        </CdtrAcct>
        <RmtInf>{d.batches[i].payments[i].creditorReference:ifNEM:showBegin}
          <Strd>
            <CdtrRefInf>
              <Tp>
                <CdOrPrtry>
                  <Cd>SCOR</Cd>
                </CdOrPrtry>
                <Issr>ISO</Issr>
              </Tp>
              <Ref>{d.batches[i].payments[i].creditorReference}</Ref>
            </CdtrRefInf>
          </Strd>{d.batches[i].payments[i].creditorReference:showEnd}{d.batches[i].payments[i].creditorReference:ifEM:showBegin}
          <Ustrd>Inv. {d.batches[i].payments[i].invoices[].number:aggStr(', ')}, cust. no. {d.batches[i].payments[i].customerNumber}</Ustrd>{d.batches[i].payments[i].creditorReference:showEnd}
        </RmtInf>
      </CdtTrfTxInf>{d.batches[i].payments[i+1]}
    </PmtInf>{d.batches[i+1]}
  </CstmrCdtTrfInitn>
</Document>
```

### JSON data

```json
{
  "messageId": "NWD-SCT-20261116-01",
  "createdAt": "2026-11-16T09:42:15Z",
  "debtor": { "name": "Northwind Antriebstechnik GmbH", "street": "Industriestraße", "buildingNumber": "18", "postCode": "68169", "town": "Mannheim", "country": "DE", "iban": "DE26670314770205417800", "bic": "WDGBDE6MXXX" },
  "batches": [
    {
      "id": "NWD-SCT-20261116-01-P1",
      "executionDate": "2026-11-17",
      "batchBooking": true,
      "payments": [
        {
          "endToEndId": "PAY-2026-04811", "amount": 24555.50, "customerNumber": "40417",
          "supplier": { "name": "Fabrikam Präzisionsteile GmbH", "street": "Marburger Straße", "buildingNumber": "112", "postCode": "35396", "town": "Gießen", "country": "DE", "iban": "DE64513204174720118365" },
          "invoices": [ { "number": "26-11873", "amount": 18420.00 }, { "number": "26-11902", "amount": 6135.50 } ]
        },
        {
          "endToEndId": "PAY-2026-04812", "amount": 9876.40, "customerNumber": "K-20931",
          "supplier": { "name": "Litware Kunststofftechnik GmbH", "street": "Wiener Straße", "buildingNumber": "131", "postCode": "4020", "town": "Linz", "country": "AT", "iban": "AT801584000428196703" },
          "invoices": [ { "number": "LW-2026-0388", "amount": 9876.40 } ]
        },
        {
          "endToEndId": "PAY-2026-04813", "amount": 3214.75, "customerNumber": "77120", "creditorReference": "RF24PV26004417",
          "supplier": { "name": "Proseware Verpakkingen B.V.", "street": "Havensingel", "buildingNumber": "52", "postCode": "5211 TX", "town": "'s-Hertogenbosch", "country": "NL", "iban": "NL42VKBN4417260133" },
          "invoices": [ { "number": "PV26004417", "amount": 3214.75 } ]
        },
        {
          "endToEndId": "PAY-2026-04814", "amount": 12480.00, "customerNumber": "NW-1180",
          "supplier": { "name": "Trey Research AG", "street": "Zürcherstrasse", "buildingNumber": "65", "postCode": "8400", "town": "Winterthur", "country": "CH", "iban": "CH0208411000427613902", "bic": "WGVECHZZXXX" },
          "invoices": [ { "number": "TR-26-5521", "amount": 12480.00 } ]
        }
      ]
    },
    {
      "id": "NWD-SCT-20261116-01-P2",
      "executionDate": "2026-11-20",
      "batchBooking": true,
      "payments": [
        {
          "endToEndId": "PAY-2026-04815", "amount": 4682.30, "customerNumber": "C0582",
          "supplier": { "name": "Wingtip Transports & Logistique SA", "street": "Rue de l'Académie", "buildingNumber": "42", "postCode": "4000", "town": "Liège", "country": "BE", "iban": "BE36716045821381" },
          "invoices": [ { "number": "F2026-10457", "amount": 4682.30 } ]
        },
        {
          "endToEndId": "PAY-2026-04816", "amount": 7950.00, "customerNumber": "30566", "creditorReference": "RF951183023",
          "supplier": { "name": "Adatum Sensors Oy", "street": "Hatanpään valtatie", "buildingNumber": "24", "postCode": "33100", "town": "Tampere", "country": "FI", "iban": "FI6677603904182572" },
          "invoices": [ { "number": "118302", "amount": 7950.00 } ]
        },
        {
          "endToEndId": "PAY-2026-04817", "amount": 15307.85, "customerNumber": "430219",
          "supplier": { "name": "Fundiciones Coho España S.L.", "street": "Calle Ribera de Deusto", "buildingNumber": "27", "postCode": "48014", "town": "Bilbao", "country": "ES", "iban": "ES4606184810382730418865" },
          "invoices": [ { "number": "FC-2026/0912", "amount": 15307.85 } ]
        }
      ]
    }
  ]
}
```

### Generated pain.001 file

An excerpt: the group header, the start of the first block, and its third and fourth transactions.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09">
  <CstmrCdtTrfInitn>
    <GrpHdr>
      <MsgId>NWD-SCT-20261116-01</MsgId>
      <CreDtTm>2026-11-16T10:42:15+01:00</CreDtTm>
      <NbOfTxs>7</NbOfTxs>
      <CtrlSum>78066.80</CtrlSum>
      <InitgPty>
        <Nm>Northwind Antriebstechnik GmbH</Nm>
      </InitgPty>
    </GrpHdr>
    <PmtInf>
      <PmtInfId>NWD-SCT-20261116-01-P1</PmtInfId>
      <PmtMtd>TRF</PmtMtd>
      <BtchBookg>true</BtchBookg>
      <NbOfTxs>4</NbOfTxs>
      <CtrlSum>50126.65</CtrlSum>
      ...
      <CdtTrfTxInf>
        <PmtId>
          <EndToEndId>PAY-2026-04813</EndToEndId>
        </PmtId>
        <Amt>
          <InstdAmt Ccy="EUR">3214.75</InstdAmt>
        </Amt>
        <Cdtr>
          <Nm>Proseware Verpakkingen B.V.</Nm>
          <PstlAdr>
            <StrtNm>Havensingel</StrtNm>
            <BldgNb>52</BldgNb>
            <PstCd>5211 TX</PstCd>
            <TwnNm>'s-Hertogenbosch</TwnNm>
            <Ctry>NL</Ctry>
          </PstlAdr>
        </Cdtr>
        <CdtrAcct>
          <Id>
            <IBAN>NL42VKBN4417260133</IBAN>
          </Id>
        </CdtrAcct>
        <RmtInf>
          <Strd>
            <CdtrRefInf>
              <Tp>
                <CdOrPrtry>
                  <Cd>SCOR</Cd>
                </CdOrPrtry>
                <Issr>ISO</Issr>
              </Tp>
              <Ref>RF24PV26004417</Ref>
            </CdtrRefInf>
          </Strd>
        </RmtInf>
      </CdtTrfTxInf>
      <CdtTrfTxInf>
        <PmtId>
          <EndToEndId>PAY-2026-04814</EndToEndId>
        </PmtId>
        <Amt>
          <InstdAmt Ccy="EUR">12480.00</InstdAmt>
        </Amt>
        <CdtrAgt>
          <FinInstnId>
            <BICFI>WGVECHZZXXX</BICFI>
          </FinInstnId>
        </CdtrAgt>
        <Cdtr>
          <Nm>Trey Research AG</Nm>
          <PstlAdr>
            <StrtNm>Zurcherstrasse</StrtNm>
            <BldgNb>65</BldgNb>
            <PstCd>8400</PstCd>
            <TwnNm>Winterthur</TwnNm>
            <Ctry>CH</Ctry>
          </PstlAdr>
        </Cdtr>
        <CdtrAcct>
          <Id>
            <IBAN>CH0208411000427613902</IBAN>
          </Id>
        </CdtrAcct>
        <RmtInf>
          <Ustrd>Inv. TR-26-5521, cust. no. NW-1180</Ustrd>
        </RmtInf>
      </CdtTrfTxInf>
      ...
```

## How to create a SEPA XML file

### 1\. Fill the group header

-   `{d.messageId}` prints the file reference. It must be unique for your bank, so a file sent twice can be detected.
-   `{d.createdAt:formatD('YYYY-MM-DDTHH:mm:ssZ')}` prints the creation time as an ISO 8601 date and time. `{o.timezone=Europe/Berlin}` on the second line turns `2026-11-16T09:42:15Z` into `2026-11-16T10:42:15+01:00`. See the [date formatters](/documentation/design/formatters/date.md).
-   `{d.batches[].payments[].amount:aggCount}` counts the transactions of the whole file: `7`.
-   `{d.batches[].payments[].amount:aggSum:formatN(2):replace(',', '')}` adds up their amounts: `78066.80`. `{o.lang=en-us}` makes `:formatN(2)` write two decimals after a dot, and `:replace(',', '')` removes the thousands separators. See the [XML numbers and dates](/documentation/design/template-formats/xml.md#numbers-and-dates).

### 2\. Repeat the blocks and the transactions

A `PmtInf` block has one execution date and one debit account, so the ERP groups the payments by date: `d.batches` holds the blocks, and `payments` the transactions of each block.

-   `{d.batches[i]}` at the end of the `</GrpHdr>` line and `{d.batches[i+1]}` at the end of the `</PmtInf>` line repeat the block.
-   `{d.batches[i].payments[i]}` after `<ChrgBr>SLEV</ChrgBr>` and `{d.batches[i].payments[i+1]}` after `</CdtTrfTxInf>` repeat the transaction inside it, as a [nested loop](/documentation/design/repetitions/with-arrays.md#nested-arrays).
-   A loop repeats the text between its `[i]` and `[i+1]` tags, so the file keeps its indentation, without empty lines.

Inside the block, the aggregators count its own transactions: `{d.batches[i].payments[].amount:aggCount}` prints `4`, then `3`, and `{d.batches[i].payments[].amount:aggSum:formatN(2):replace(',', '')}` prints `50126.65`, then `27940.15`. Together they make 78,066.80, the `CtrlSum` of the header. Learn more about [aggregators](/documentation/design/computation/aggregation.md#learn-with-aggsum-partitionby-aggregator-with-nested-arrays).

`{d.batches[i].executionDate:formatD('YYYY-MM-DD')}` prints `2026-11-17`, and `BtchBookg` `true` asks the bank for one debit per block on the account statement. The codes `SEPA`, `SUPP` (supplier payment) and `SLEV` (each party pays the charges of its own bank) are typed in the template.

### 3\. Convert the text to the SEPA character set

SEPA banks must support the Latin character set: a to z, A to Z, 0 to 9, the space and `/ - ? : ( ) . , ' +`. The alias on the second line removes the accents, writes `ss` for `ß`, and cuts the text at its maximum length:

```text
{#sepa($text, $max) = $text:unaccent:replace('ß', 'ss'):substr(0, $max)}
```

-   `{$sepa(d.batches[i].payments[i].supplier.town, 35)}` prints `Liege` for Liège and `Giessen` for Gießen. Names and streets are cut at 70 characters, towns at 35.
-   The names also get `:replace('&amp;', '+')`: `Wingtip Transports & Logistique SA` becomes `Wingtip Transports + Logistique SA`, the replacement recommended by the EPC in [EPC217-08](https://www.europeanpaymentscouncil.eu/sites/default/files/KB/files/EPC217-08%20Draft%20Best%20Practices%20SEPA%20Requirements%20for%20Character%20Set%20v1.1.pdf). In an XML template, `&` is written `&amp;`.
-   The addresses are structured, with the town `TwnNm` and the country `Ctry`: from 22 November 2026, the EPC guidelines allow only structured and hybrid addresses.

Learn more about [parametrized aliases](/documentation/design/substitutions/aliases.md#parametrized-alias).

### 4\. Add the BIC only when the bank needs it

Within the EEA, the IBAN is enough. For a supplier whose bank is in a non-EEA SEPA country, such as Switzerland, your bank can ask for the BIC when it cannot find it from the IBAN. The [conditional block](/documentation/design/conditions/conditional-blocks.md#showbegin-showend) from `{d.batches[i].payments[i].supplier.bic:ifNEM:showBegin}` to `:showEnd` writes `CdtrAgt` only for the suppliers that have a BIC in the data: here, `WGVECHZZXXX` for Trey Research AG in Winterthur.

### 5\. Choose the remittance information

The supplier matches the payment to its invoices with the remittance information: either `Strd` or `Ustrd`, up to 140 characters.

-   When the invoice carries an RF creditor reference ([ISO 11649](https://www.iso.org/standard/50649.html)), the block from `{d.batches[i].payments[i].creditorReference:ifNEM:showBegin}` to `:showEnd` keeps `Strd`, with the code `SCOR`, the issuer `ISO` and the reference `RF24PV26004417` for Proseware Verpakkingen.
-   Otherwise, the block from `{d.batches[i].payments[i].creditorReference:ifEM:showBegin}` to `:showEnd` keeps `Ustrd`. `{d.batches[i].payments[i].invoices[].number:aggStr(', ')}` lists the invoices of the payment: `Inv. 26-11873, 26-11902, cust. no. 40417` pays two Fabrikam invoices in one transfer. See [:aggStr](/documentation/design/computation/aggregation.md#aggstr-separator-partitionby).

### 6\. Check the file before it goes to the bank

Before going live, validate a few files with the XSD of pain.001.001.09, published by [ISO 20022](https://www.iso20022.org/), and with the rules of your bank. The file of this example validates against the official schema, and against the SEPA schema of the German banking industry, GBIC\_5, published on [ebics.de](https://www.ebics.de/de/datenformate).

Since 9 October 2025, banks in the euro area check the payee name against the IBAN before they execute a transfer ([Verification of Payee](https://eur-lex.europa.eu/eli/reg/2024/886/oj)). They also check the transfers of a file, unless your company opts out: send the name of the account holder in `Cdtr/Nm`.

## Related Examples

- [NACHA ACH file](/examples/nacha-ach-file/index.md): TXT template to ACH.
- [13-week cash flow forecast](/examples/cash-flow-forecast-13-week/index.md): XLSX template to XLSX.
- [Factur-X invoice](/examples/factur-x/index.md): DOCX template to PDF.

## Related topics

- [Monthly management report](/examples/monthly-management-report/index.md)
- [Bank statement with page subtotals](/examples/bank-statement-simple/index.md)
- [Quarterly board pack](/examples/quarterly-board-pack/index.md)
- [Accounts receivable aging report](/examples/accounts-receivable-aging-report/index.md)
- [Checking account statement](/examples/bank-statement-expert/index.md)
- [cXML purchase order](/examples/cxml-purchase-order/index.md)
