Create SwissQR Bill - Payment Generator API
PDF4me Create SwissQR Bill enables you to generate fully compliant SwissQR Bill PDF documents with embedded QR codes, payment information, and professional formatting. The Swiss QR-bill is the official digital payment standard for Switzerland, introduced in June 2020. This API service creates SwissQR Bill documents that comply with the official Swiss QR-bill standard for digital payment processing in Switzerland. The API receives PDF content and payment information through REST API calls, utilizing Base64 encoding for secure PDF transmission. This solution is ideal for Swiss businesses, financial institutions, payment processors, and accounting systems.
Authenticating Your API Request
To access the PDF4me REST API, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user of the REST API.
Key Features
- Full SwissQR Bill Compliance: Complete adherence to Swiss QR-bill digital payment standard (June 2020) with validation of all required fields and formatting requirements
- Automated PDF Generation: Generate comprehensive SwissQR Bill PDF documents with embedded QR codes, payment information, and professional formatting
- Swiss Banking Standards: Full compliance with Swiss financial regulations, payment processing requirements, and banking infrastructure standards
- Multi-language Support: Support for English, German, French, and Italian languages
- Complete Payment Information: Include payment amount, currency, IBAN, creditor details, debtor information, payment references, and billing information
- Professional Document Formatting: Generate properly formatted SwissQR Bill documents with correct layout, typography, and visual elements ready for digital payment processing
SwissQR Bill Standards
The API generates SwissQR Bill documents that comply with the official Swiss QR-bill standard. SwissQR Bills include structured payment information, creditor details, and embedded QR codes for automated payment processing in Switzerland.
REST API Endpoint
The PDF4me REST API uses standard HTTP methods to interact with resources. All SwissQR Bill generation operations are performed through a single endpoint:
- Method: POST
- Endpoint:
/api/v2/CreateSwissQRBill
REST API Parameters
Complete list of parameters for the Create SwissQR Bill REST API. Parameters are organized by category for better understanding and implementation.
Important: Parameters marked with an asterisk (*) are required and must be provided for the API to function correctly.
Required Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| docContent* | Base64 | PDF file content encoded in Base64 | JVBERi... |
| docName* | String | PDF file name with .pdf extension | invoice.pdf |
| iban* | String | Swiss IBAN for the creditor | CH0200700110003765824 |
| crName* | String | Creditor name or company | Test AG |
| crAddressType* | String | Creditor address type: S (Structured) or K (Combined) | S |
| crStreetOrAddressLine1* | String | Creditor street or address line 1 | Test Strasse |
| crStreetOrAddressLine2* | String | Creditor street number or address line 2 | 1 |
| crPostalCode* | String | Creditor postal code | 8000 |
| crCity* | String | Creditor city | Zurich |
| amount* | String | Payment amount (without leading zeroes) | 1000 |
| currency* | String | Currency: CHF, EUR, or USD | CHF |
| udName* | String | Ultimate debtor name or company | Test Debt AG |
| udAddressType* | String | Ultimate debtor address type: S (Structured) or K (Combined) | S |
| udStreetOrAddressLine1* | String | Ultimate debtor street or address line 1 | Test Deb Strasse |
| udStreetOrAddressLine2* | String | Ultimate debtor street number or address line 2 | 2 |
| udPostalCode* | String | Ultimate debtor postal code | 8000 |
| udCity* | String | Ultimate debtor city | Zurich |
| referenceType* | String | Reference type: QRR (QR reference), NON (No reference), or SCOR (Creditor reference) | NON |
| languageType* | String | Language for the QR bill: English, German, French, or Italian | English |
| seperatorLine* | String | Separator line style: LineWithScissor, DashedLineWithScissor, or SolidLine | LineWithScissor |
| async* | Boolean | Enable asynchronous processing. When true, the API returns a 202 status and provides a polling URL in the Location header | true |
Output
The PDF4me Create SwissQR Bill REST API returns different responses based on the processing mode. The API returns the PDF as a Base64-encoded string in JSON format, not as binary data.
- Success Response
- Asynchronous Processing
- Error Responses
- Response Format Details
Synchronous Processing (Default)
When async is not set or set to false, the API processes the request immediately:
Status Code: 200 OK
Content-Type: application/json
Response Body:
{
"docName": "invoice.pdf",
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg=="
}
Response Fields:
- docName (string): The output PDF file name
- docContent (string): The SwissQR Bill PDF file, encoded as Base64 string
How to Use:
- Extract the
docContentfield from the JSON response - Decode the Base64 string to get the binary PDF data
- Save or process the PDF file as needed
Example (JavaScript):
const response = await fetch(url, options);
const data = await response.json();
const pdfBytes = atob(data.docContent); // Decode Base64
// Save or process pdfBytes
Asynchronous Processing
When async: true is set, the API processes the request asynchronously:
Status Code: 202 Accepted
Response Headers:
Location: https://api.pdf4me.com/api/v2/CreateSwissQrBill/poll/12345-abcde-67890
Polling Process:
- Extract the
Locationheader from the 202 response - Poll the URL using GET requests
- Continue polling until you receive a 200 OK status
- The final response contains the same JSON format with
docNameanddocContent(Base64)
Polling Example:
// Initial request returns 202 with Location header
const response = await fetch(url, options);
const location = response.headers.get('Location');
// Poll until complete
while (true) {
const pollResponse = await fetch(location, { headers: { 'Authorization': 'Basic ' + apiKey } });
if (pollResponse.status === 200) {
const data = await pollResponse.json();
// Process data.docContent (Base64 PDF)
break;
}
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
}
Error Responses
The API returns standard HTTP error codes with error details:
- Invalid request parameters
- Missing required fields
- Invalid Base64 encoding in
docContent - Invalid IBAN format
- Invalid address type (must be S or K)
- Invalid reference type (must be QRR, NON, or SCOR)
- Invalid language type
- Invalid or missing API key
- API key not properly Base64 encoded in Authorization header
- Missing
Authorization: Basicheader
- Server-side processing error
- PDF processing failure
- SwissQR Bill generation failure
Error Response Format:
{
"error": "Error message describing what went wrong"
}
Response Format Details
Important: The API always returns JSON, never binary PDF data directly.
Response Structure:
{
"docName": "string", // Output PDF filename
"docContent": "string" // Base64-encoded PDF content
}
Content-Type Header:
- Success:
application/json - The PDF is embedded as a Base64 string within the JSON response
Why Base64?
- JSON-safe encoding for binary data
- Easy to transmit over HTTP
- Compatible with all programming languages
- Can be directly embedded in JSON without escaping issues
Decoding Base64 to PDF:
JavaScript/Node.js:
const base64 = response.docContent;
const binary = atob(base64); // Browser
// OR
const binary = Buffer.from(base64, 'base64').toString('binary'); // Node.js
Python:
import base64
pdf_bytes = base64.b64decode(response['docContent'])
with open('swissqr_bill.pdf', 'wb') as f:
f.write(pdf_bytes)
C#:
byte[] pdfBytes = Convert.FromBase64String(response.docContent);
File.WriteAllBytes("swissqr_bill.pdf", pdfBytes);
Request Example
Header
Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY
Note:
- Get your API key from the PDF4me Dashboard
- The API key must be Base64 encoded and prefixed with "Basic " in the Authorization header
- Example: If your API key is
abc123, encode it to Base64 and useAuthorization: Basic YWJjMTIz
Payload
Example:
{
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg==",
"docName": "invoice.pdf",
"iban": "CH0200700110003765824",
"crName": "Test AG",
"crAddressType": "S",
"crStreetOrAddressLine1": "Test Strasse",
"crStreetOrAddressLine2": "1",
"crPostalCode": "8000",
"crCity": "Zurich",
"amount": "1000",
"currency": "CHF",
"udName": "Test Debt AG",
"udAddressType": "S",
"udStreetOrAddressLine1": "Test Deb Strasse",
"udStreetOrAddressLine2": "2",
"udPostalCode": "8000",
"udCity": "Zurich",
"referenceType": "NON",
"languageType": "English",
"seperatorLine": "LineWithScissor",
"async": true
}
Code Samples
The PDF4me Create SwissQR Bill REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:
- C#
- Java
- JavaScript
- Python
- Salesforce
- n8n
- Google Script
- AWS Lambda
Google Script Sample
Google Apps Script implementation for Google Workspace integration:
Industry Use Cases & Applications
- Finance & Banking
- Business & Enterprise
- Government & Compliance
Finance & Banking Use Cases
- Invoice Processing: Generate SwissQR Bill documents for automated invoice processing and payment collection
- Swiss Banking Integration: Generate compliant SwissQR Bills for integration with Swiss banking systems
- Banking Applications: Generate SwissQR Bills for Swiss banking applications and payment systems
- Payment Automation: Create SwissQR Bills for streamlined payment workflows and digital payment processing
- Payment Reconciliation: Generate SwissQR Bills for automated payment matching and reconciliation
- Financial Reporting: Create SwissQR Bills for financial reporting and payment tracking
Business & Enterprise Use Cases
- Swiss Business Operations: Generate SwissQR Bills for Swiss companies and financial institutions
- Payment System Integration: Integrate SwissQR Bill generation into existing payment processing systems
- Document Automation: Automate SwissQR Bill generation for large-scale payment processing
- Digital Payment Processing: Create SwissQR Bills for modern digital payment solutions
- Digital Transformation: Modernize payment processing with SwissQR Bill generation
- Business Process Automation: Automate SwissQR Bill generation for enterprise operations
Government & Compliance Use Cases
- Compliance Management: Ensure compliance with Swiss banking regulations and payment standards
- Regulatory Compliance: Generate SwissQR Bills that comply with Swiss financial regulations
- Government Payments: Generate SwissQR Bills for government payment processing
- Financial Compliance: Ensure compliance with Swiss banking and payment standards
SwissQR Bill Standards
The API generates SwissQR Bill documents that comply with the official Swiss QR-bill standard (June 2020). SwissQR Bills include:
- Structured Payment Information: Payment amount, currency, IBAN, and payment references
- Creditor Details: Complete creditor information including name, address, and postal code
- Debtor Information: Ultimate debtor details for payment processing
- Embedded QR Codes: Automated QR codes for digital payment processing
- Professional Formatting: Proper layout, typography, and visual elements ready for banking