Do you have example code in my programming language?

Published on · Updated on

Do you have example code?

Yes. The API is a standard HTTP service: any language that can send a JSON POST request with HTTP Basic authentication can use it. There’s no SDK to install.

Two things to keep in mind, whatever the language:

  • Authentication: the API key is the username and the password is left blank.
  • Response: the SEPA XML arrives Base64-encoded in the file field; you just decode it.

The API reference also generates ready-to-copy snippets in several languages (curl, Python, Node.js, PHP, Ruby and more).

Python example

import base64
import requests

r = requests.post(
    "https://api.generatesepa.com/api/v2/sdd",
    auth=("YOUR_API_KEY", ""),
    json={
        "name": "Acme Services Ltd",
        "iban": "IE29AIBK93115212345678",
        "sepa_identifier": "IE84ZZZ123456",
        "debits": [{
            "name": "John Smith",
            "iban": "IE64IRCE92050112345678",
            "amount": 2599,  # in cents
            "date": "2026-12-05",
            "description": "December subscription",
            "reference": "INV-2026-120",
            "mandate_reference": "MNDT-000123",
            "mandate_signature": "2026-01-15",
        }],
    },
)
if r.status_code != 201:
    raise SystemExit(r.json())
with open("direct-debits.xml", "wb") as f:
    f.write(base64.b64decode(r.json()["file"]))

Node.js example (18 or later)

const auth = Buffer.from("YOUR_API_KEY:").toString("base64");
const res = await fetch("https://api.generatesepa.com/api/v2/sct", {
  method: "POST",
  headers: { "Authorization": `Basic ${auth}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    name: "Acme Services Ltd",
    iban: "IE29AIBK93115212345678",
    payments: [{
      name: "Murphy Supplies Ltd",
      iban: "IE64IRCE92050112345678",
      amount: 125000, // in cents
      date: "2026-12-05",
      description: "Invoice F-2026-311",
      reference: "PAY-311",
    }],
  }),
});
const data = await res.json();
if (res.status !== 201) throw new Error(JSON.stringify(data));
const xml = Buffer.from(data.file, "base64").toString("utf8");

Conclusion

Adapt one of these examples to your language: a POST request, Basic authentication and a Base64 decode are all it takes.


Frequently Asked Questions

Do I need to install a library?
No. Any HTTP client that can send JSON with Basic authentication works: requests in Python, fetch in Node.js, cURL or Guzzle in PHP, Net::HTTP in Ruby.
How do I get the XML file?
The response contains the Base64-encoded file in the file field. Decode it and save it with the .xml extension before uploading it to your bank.
Compatible with Lambda/Cloud Run?
Yes. The API is a standard HTTP endpoint with no particular infrastructure requirements.

Read the API documentation

Try it now β†’
Was this article helpful?

Related articles