Skip to content
📢 Kafinea is a compatible solution for electronic invoicing! Learn more ➔
kafinea logo svg

Kafinea

  • Features
        • Finance
          • Purchases
          • Audits & KPIs
          • Accounting
          • Invoicing
        • Management
          • Documents
          • Project Management
          • Inventory Management
          • Maintenance
        • HR
          • Employees
          • Timesheets
          • Absence Management
          • Recruitment
        • Customer Service
          • Service Contracts
          • Interventions
          • Warranty Tracking
          • Tickets
        • Sales
          • Subscriptions
          • Sales Automation
          • CRM
          • Points of Sale
        • Cross-Features
          • API
          • Extranet
          • Electronic Signature
          • Workflows
  • Use Cases
  • Pricing
  • Login
  • Discover the demo
📢 Kafinea is electronic invoicing compatible! ➔
kafinea logo svg
Kafinea

API

16
  • REST API – Bulk import (upsert)
  • REST API – Authentication
  • REST API – Retrieve a Document’s PDF
  • REST API – File Management
  • REST API – Entity Relationships
  • REST API – Introduction
  • REST API – Taxes, Tax Regions, and Territorial Rules
  • REST API – Requests and Querying
  • REST API – Refresh an online store order
  • REST API – Bulk deletion (trash)
  • REST API – Cost Accounting
  • REST API – Product Kits
  • REST API – Generic and Specific Products
  • REST API – Action links
  • REST API – Approvals
  • REST API – Full Reference (OpenAPI)

Marketing

1
  • Leads

Sales

14
  • Customer purchase orders
  • Customer accounts
  • Customer Quotes
  • Customer credit notes
  • Company Search (Sirene)
  • Margins in quotes
  • Invoicing
    • Classic Invoicing
    • Progress Invoicing
    • Issue an electronic invoice
    • Invoicing Article Consumption
    • Recurring invoicing
  • Payments
    • Customer payments
    • Linking a payment to one or more invoices
  • Price list
    • Price list administrator guide

Purchases

5
  • Supplier invoices
  • Supplier Purchase Orders
  • Suppliers
  • Supplier Credits
  • Receiving an Electronic Invoice

Catalog

8
  • Units of measure
  • Products
  • Services
  • Sourcing Management
  • The Purchase Order Assistant
  • Generic products
  • Product kits
  • Catalog margin analysis

Finance

11
  • Bank Accounts
  • Manual entries
  • SEPA Mandates
  • Third-party bank accounts
  • Bank Transactions
  • Accounting
    • Cash accounting
    • Accounting entries
    • Tools for Checking Your Accounting
    • Accounting
    • Financial statements
    • Fiscal years

Human Resources

5
  • Timesheets
  • Activities
  • Pay Slips
  • Employee Extranet
    • Leave Management
    • The employee portal card

Project management

2
  • Secure assignments using a people list
  • The responder area: view and accept my assignments

Customer Support

1
  • The Client Portal

Inventory management

4
  • Goods receipt notes
  • Delivery Notes
  • Stock movements
  • Inventory Valuation

Cash register

1
  • Cash Registers

Document management

1
  • Electronic signature

Automation

2
  • Forms
  • Workflows

Templates

2
  • Email templates
  • Document templates

Artificial intelligence

4
  • AI Workflows
  • AI Chat
  • AI Text Assistant
  • Connect ChatGPT, Claude, or Gemini to Kafinea (MCP)

Kafinea interface

9
  • Automatic saving
  • Data Import/Export
  • Navigation
  • Records
  • Lists
  • The Layout Manager
  • Links Between Elements
  • Document Lines
  • List views: Kanban, Cards, Calendar, Planning, Gantt, Geographic map, and Analysis

Settings

10
  • Tax Configuration
  • Global search
  • Access Rights
  • User preferences
  • Numbering formats
  • SMTP Settings
  • Permanent locking
  • Catalog popup filtering
  • AI agents
  • Administer the MCP server

Business Guides

2
  • Enable employees to complete their HR record independently
  • Mobilizing thousands of field workers at scale
  • Kafinea
  • Documentation
  • API
  • REST API – Retrieve a Document’s PDF
View Categories

REST API – Retrieve a Document’s PDF

6 minutes

0:00 / 6:22
  • View as Markdown Open this page as plain Markdown (opens in a new tab)
  • Open in ChatGPT Ask questions about this page (opens in a new tab)
  • Open in Claude Ask questions about this page (opens in a new tab)
  • Open in Google AI Studio Ask questions about this page (Google account required) (opens in a new tab)

This page describes how to retrieve, from a third-party application, the PDF of a business document (invoice, credit note, quote, order, delivery note, payslip…) exactly as it is generated by Kafinea, using the print template of your choice.

By default, when the document is an invoice or a credit note and the conditions are met, the returned PDF automatically contains the Factur-X file: no additional parameter is required (see the “Electronic invoicing” section below).

A single operation is required:

Operation Method Description
document_pdf GET Retrieve a document’s PDF

It requires a valid session (see Authentication).

Name change: this operation used to be called mds_document_pdf. Both names work
until November 30, 2026, with exactly the same parameters and response: simply
replace the value of operation in your calls.


document_pdf – Retrieve the PDF #

Generates the PDF of a record and returns it, either base64-encoded in the JSON response, or directly as a PDF file.

GET https://apps.kafinea.com/{instance}/webservice.php

Parameter Type Required Description
operation string yes Must be document_pdf
sessionName string yes Session identifier
id string yes Webservice ID of the record (6x54325), as returned by query or retrieve
templateId string no Webservice ID of the print template (57x1088). If absent, the module’s default template is used
download string no 1 to receive the PDF file directly instead of the JSON response

ID convention: as with all API operations, id and templateId expect the full Webservice ID (6x54325), the one returned by query, retrieve or describe. A raw identifier (54325) is rejected with code INVALID_ID_ATTRIBUTE.

JSON response (default) #

curl "https://apps.kafinea.com/YourKafinea/webservice.php?operation=document_pdf&sessionName=YOUR_SESSION_ID&id=6x54325&templateId=57x1088"
{
  "success": true,
  "result": {
    "id": "6x54325",
    "module": "Invoice",
    "templateId": "57x1088",
    "filename": "Facture - 0053 - 2026-06-29.pdf",
    "mime": "application/pdf",
    "size": 970618,
    "base64": "JVBERi0xLjQKJeLjz9MK..."
  }
}

The base64 field contains the PDF bytes. Decode it to reconstruct the file:

$pdfBytes = base64_decode($response['result']['base64']);
file_put_contents($response['result']['filename'], $pdfBytes);

Direct file download #

With download=1, the response is no longer JSON: the PDF file is returned as is, with the Content-Type: application/pdf and Content-Disposition: attachment headers.

curl -o facture.pdf "https://apps.kafinea.com/YourKafinea/webservice.php?operation=document_pdf&sessionName=YOUR_SESSION_ID&id=6x54325&download=1"

Tip: The download=1 mode avoids the overhead of base64 encoding (about +33% in size): use it when archiving or forwarding the file as is.


Finding a print template’s ID #

The templateId parameter is optional: without it, Kafinea uses the module’s default template. If you want to enforce a specific template, retrieve its ID.

Reminder: Print templates are a full-fledged Kafinea module, so they are accessible via the API’s generic operations (describe, query, retrieve…). No dedicated operation is required.

curl --get "https://apps.kafinea.com/YourKafinea/webservice.php" \
  --data-urlencode "operation=query" \
  --data-urlencode "sessionName=YOUR_SESSION_ID" \
  --data-urlencode "query=SELECT id, templatename, basemodule, active FROM MdsPrintTemplate WHERE basemodule = 'Invoice';"
{
  "success": true,
  "result": [
    { "id": "57x1088", "templatename": "Facture client", "basemodule": "Invoice", "active": "1" },
    { "id": "57x1093", "templatename": "Facture d'avancement client", "basemodule": "Invoice", "active": "1" }
  ]
}

The basemodule field indicates the module the template applies to. The returned ID (57x1088) can be used as is in the templateId parameter.

An empty result means the module has no print template: PDF export is then not possible for that module.


Affected modules #

The operation works for any module with at least one print template, including:

  • business management documents: quotes, customer orders, invoices, credit notes, supplier orders;
  • logistics documents: delivery notes, receiving notes;
  • payslips;
  • any module for which you have created your own print templates.

To check whether a module is eligible, query the print templates associated with that module (see above): if at least one exists, PDF export is available.


Electronic invoicing (Factur-X) #

The returned PDF is identical to the one produced from the interface: it therefore automatically contains, with no parameter to add to your call, the factur-x.xml file when all the conditions below are met.

Condition Detail
Document type Customer invoice or customer credit note
Locking The document must be permanently locked (final document)
Instance configuration The electronic invoicing format must be set to Factur-X

The resulting file is then a PDF/A-3: readable like an ordinary PDF, it embeds as an attachment the standardized XML file that can be processed by the recipient’s accounting system.

Note: An unlocked document is considered a draft: its PDF carries a watermark and does not contain a Factur-X file. This is expected behavior – a non-final invoice has no legal value.

Checking for the presence of the Factur-X file:

curl -o facture.pdf "https://apps.kafinea.com/YourKafinea/webservice.php?operation=document_pdf&sessionName=YOUR_SESSION_ID&id=6x54325&download=1"
strings facture.pdf | grep factur-x.xml

Access rights #

The operation applies the rights of the integration account’s user: if this user does not have permission to view the document, the call is denied. Create a user dedicated to the integration and assign it a profile granting access only to the necessary modules.


Error codes #

Code Meaning
INVALID_ID_ATTRIBUTE id or templateId parameter missing, malformed, or not matching the correct module
ACCESS_DENIED The logged-in user does not have permission to view this document (or the document does not exist)
RECORD_NOT_FOUND The document does not exist (or has been deleted)
PDF_NOT_SUPPORTED The module has no print template
INVALID_TEMPLATE The requested template does not belong to the document’s module
PDF_GENERATION_FAILED PDF generation failed (the message specifies the cause)

Example error response:

{
  "success": false,
  "error": {
    "message": "Print template 57x1093 does not belong to module \"Invoice\".",
    "code": "INVALID_TEMPLATE"
  }
}

Frequently asked questions #

How can I get an invoice’s ID from its number?

Use the query operation (see Requests and querying):

SELECT id FROM Invoice WHERE invoice_no = 'FA-2026-0053';

The returned ID (6x54325) can be used directly as the id parameter.

Note: The Webservice ID prefix (the number before the x) is specific to each instance: never hard-code it, always retrieve it via query or describe.

Can I retrieve several PDFs in a single request?

No: one call returns one document. Chain calls using the same session – since generating a PDF is resource-intensive, plan for sequential processing rather than massive parallelization.

The returned PDF has a “Draft” watermark. Why?

The document is not permanently locked. Lock it in Kafinea, then run the call again.

Can I retrieve only the XML file of the electronic invoice?

Yes, the invoice_facturx operation returns the XML alone for a locked invoice:

curl "https://apps.kafinea.com/YourKafinea/webservice.php?operation=invoice_facturx&sessionName=YOUR_SESSION_ID&id=6x54325"

This operation used to be called mds_invoice_facturx: both names work until
November 30, 2026, with identical parameters and response.


Related references 🔗 #

  • Introduction
  • Authentication
  • Requests and querying
  • File management
Index
  • document_pdf – Retrieve the PDF
    • JSON response (default)
    • Direct file download
  • Finding a print template's ID
  • Affected modules
  • Electronic invoicing (Factur-X)
  • Access rights
  • Error codes
  • Frequently asked questions
  • Related references 🔗

An all-in-one software designed for SMEs. Take advantage of the automation capabilities and flexibility of our business management platform to make work easier for all your employees.

RESOURCES

Blog
Brand Guidelines
Distributors
Help
Security

Customer portal
ABOUT

About Us
Contact Us
Cookie Policy
FAQ
Legal Notice
Privacy Policy
Terms of Service

Electronic invoicing compatible solution
French Tech Grand Paris Logo
FINANCE

Accounting
Audits & KPIs
Invoicing
Purchases

MANAGEMENT

Documents
Inventory Management
Maintenance
Project Management

HR

Absence Management
Employees
Recruitment
Timesheets

CUSTOMER SERVICE

Interventions
Service Contracts
Tickets
Warranty Tracking

SALES

CRM
Points of Sale
Sales Automation
Subscriptions

© 2026 Madiasoft - Kafinea

24 rue Louis Blanc, 75010 PARIS, France

+33 1 70 06 05 41

Facebook Linkedin
kafinea logo svg
Gérer le consentement aux cookies
Pour offrir les meilleures expériences, nous utilisons des cookies pour stocker et/ou accéder aux informations des appareils. Le fait de consentir à ces cookies nous permettra de traiter des données telles que le comportement de navigation ou les ID uniques sur ce site. Le fait de ne pas consentir ou de retirer son consentement peut avoir un effet négatif sur certaines caractéristiques et fonctions.
Fonctionnel Always active
Le stockage ou l’accès technique est strictement nécessaire dans la finalité d’intérêt légitime de permettre l’utilisation d’un service spécifique explicitement demandé par l’abonné ou l’internaute, ou dans le seul but d’effectuer la transmission d’une communication sur un réseau de communications électroniques.
Préférences
Le stockage ou l’accès technique est nécessaire dans la finalité d’intérêt légitime de stocker des préférences qui ne sont pas demandées par l’abonné ou la personne utilisant le service.
Statistiques
Le stockage ou l’accès technique qui est utilisé exclusivement à des fins statistiques. Le stockage ou l’accès technique qui est utilisé exclusivement dans des finalités statistiques anonymes. En l’absence d’une assignation à comparaître, d’une conformité volontaire de la part de votre fournisseur d’accès à internet ou d’enregistrements supplémentaires provenant d’une tierce partie, les informations stockées ou extraites à cette seule fin ne peuvent généralement pas être utilisées pour vous identifier.
Marketing
Le stockage ou l’accès technique est nécessaire pour créer des profils d’internautes afin d’envoyer des publicités, ou pour suivre l’internaute sur un site web ou sur plusieurs sites web ayant des finalités marketing similaires.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
Voir les préférences
  • {title}
  • {title}
  • {title}
  • Features
    • Finance
      • Purchases
      • Audits & KPIs
      • Accounting
      • Invoicing
    • Management
      • Documents
      • Interventions
      • Project Management
      • Inventory Management
    • HR
      • Employees
      • Timesheets
      • Absence Management
      • Recruitment
    • Customer Service
      • Service Contracts
      • Warranty Tracking
      • Maintenance
      • Tickets
    • Sales
      • Subscriptions
      • Sales Automation
      • CRM
      • Points of Sale
    • Cross-Features
      • API
      • Extranet
      • Electronic Signature
      • Workflows
  • Use Cases
  • Pricing
  • Login
  • Discover the demo