API Integration for Developers

Use our API to convert PDF invoices to the ZUGFeRD format (PDF/A-3 with XML).
Ideal for automated invoice processing in ERP, DMS, or web systems.

🔐 Request API Token now

📦 Example: PHP Integration (CLI)

<?php
  $token = 'YOUR_TOKEN_HERE'; // API token
  $apiUrl = 'https://konverter.zugferd-rechnungen.de/api/pdf2zugferd.php';

  $inputFile = 'invoice.pdf';
  $outputFile = 'ZUGFeRD_invoice.pdf';

  // Check input file
  if (!file_exists($inputFile)) {
      exit("❌ Error: Input file '{$inputFile}' not found.\n");
  }

  $cfile = new CURLFile(realpath($inputFile), 'application/pdf', basename($inputFile));
  $postFields = [
      'file' => $cfile,
      'token' => $token,
      'dscheck' => 'yes', //Agree to transmission and privacy policy
      'desiredFilename' => $outputFile
  ];

  $ch = curl_init($apiUrl);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);

  $response = curl_exec($ch);
  $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  $body = substr($response, $headerSize);
  $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
  curl_close($ch);

  if (str_contains($contentType, 'application/pdf')) {
      file_put_contents($outputFile, $body);
      echo "✅ Saved: {$outputFile}\n";
  } else {
      echo "❌ Error:\n" . $body;
  }
?>

🌐 Example: JavaScript (HTML Form with Fetch)

<form id="uploadForm">
    <input type="file" name="file" accept="application/pdf" required>
    <input type="text" name="desiredFilename" value="ZUGFeRD_Invoice.pdf">
    <button type="submit">Upload</button>
  </form>

  <script>
  document.getElementById('uploadForm').addEventListener('submit', async function(e) {
    e.preventDefault();
    const form = e.target;
    const fileInput = form.file;
    const file = fileInput.files[0];

    if (!file) {
      alert('❌ Please select a PDF file.');
      return;
    }

    if (file.type !== 'application/pdf') {
      alert('❌ Only PDF files are allowed.');
      return;
    }

    const filename = form.desiredFilename.value || 'ZUGFeRD_Invoice.pdf';

    const formData = new FormData();
    formData.append('file', file);
    formData.append('token', 'YOUR_TOKEN_HERE');
    formData.append('dscheck', 'yes'); //Agree to transmission and privacy policy
    formData.append('desiredFilename', filename);

    try {
      const res = await fetch('https://konverter.zugferd-rechnungen.de/api/pdf2zugferd.php', {
        method: 'POST',
        body: formData
      });

      if (!res.ok || !res.headers.get('Content-Type')?.includes('application/pdf')) {
        const text = await res.text();
        throw new Error(text);
      }

      const blob = await res.blob();
      const url = URL.createObjectURL(blob);

      const a = document.createElement('a');
      a.href = url;
      a.download = filename;
      a.click();
      URL.revokeObjectURL(url);
    } catch (err) {
      alert('❌ Error during upload or conversion:\n' + err.message);
    }
  });
  </script>

Important Note: Including a token in JavaScript source code is a security risk, especially in publicly accessible browser code.
Any user can see the token, so always secure the token server-side, for example via PHP.

← Back to homepage