How to Connect an Epson Fiscal Printer to a Web Management System
How an Epson fiscal printer connects to a web management system through a SOAP request to fpmate.cgi: XML format, responses, errors and timeouts, from Epson's official guide.

- 1.The FpMate CGI service
- 2.The address and the request
- 3.A receipt, line by line
- 4.The response and what to save
- 5.The daily closing
- 6.Voids and refunds
- 7.Errors, timeouts and documents left open
- A timeout does not undo what has already been printed
- A document without a closing stays open
- A wrong value stops it halfway
- 8.From the browser or from the server
- 9.A plan for the first day
- 10.Frequently asked questions
- 11.Where to start
- 12.Rate this article
- 13.Related Articles
- 14.Looking for a Software Engineer?
An Italian Epson fiscal printer connects to a web management system with an HTTP request: the server sends an XML document, wrapped in a SOAP message, to http://[printer IP]/cgi-bin/fpmate.cgi. The printer issues the commercial document and replies with the receipt number, the amount, the date and the number of the daily closing. Of all the manufacturers I looked at, Epson is the only one that publishes a complete specification of this service.
I base this on the developer guide from Epson Italia, the ePOS Fiscal Print Solution Development Guide, revision T of 5 July 2021, 87 pages. For the other two brands there are sister articles: how to connect an RCH fiscal printer and how to connect a Custom fiscal printer.
Epson Italia is among the manufacturers in the list of approved telematic cash registers kept by the Agenzia delle Entrate, with the FP-81 II RT model. The telematic cash register, or RT, is the printer that issues receipts valid for tax purposes and sends the daily takings to the tax authority. Systems that bypass the register, the so-called speed-up devices, have ended up in the tax authority's sights: I wrote about it in the tax authority blocks receipt speed-up devices.
The FpMate CGI service
Inside the printer there is a web service that Epson calls FpMate CGI. It receives a document in an XML format that the guide calls Fiscal ePOS-Print, processes it and replies with another document. To use it you need no drivers, and no PC or server next to the printer. The protocol is SOAP over HTTP, and the guide says HTTPS is supported as well.
Two things set it apart from the other two brands. The first: the response carries the Access-Control-Allow-Origin: * header, so a web page can call the printer straight from the browser, without going through the server. The second: the typical scenario in the guide is a web page, hosted on an internet server, on an intranet or on the printer itself, that uses a browser-side JavaScript library to talk to the printer. A management system calling from the server is still possible, as one option among others.
| Custom | RCH | Epson | |
|---|---|---|---|
| Format | XML with an element for each step | Text commands inside an XML | XML in a SOAP message |
| Amounts | Whole cents | Whole cents | Decimals with comma or period |
| Documentation | Not public for the model I used | Not public | Public developer guide |
| Call from the browser | Certificate and mixed content problems | Not tried | Open CORS header, the certificate issue remains |
The format row deserves a remark. The commercial document elements in the Epson guide, printerFiscalReceipt, beginFiscalReceipt, printRecItem, printRecTotal, endFiscalReceipt, have the same names as the ones I had derived in the Custom article from an open source library and from my own tests. The vocabulary is the same, but the values are not: Epson wants amounts as decimals and cash is payment type 0, while in the Custom example amounts were whole cents and cash was 1. Anyone who already has a bridge for one brand can't reuse it for the other by just swapping the address.
The address and the request
The base address is http://[host]/cgi-bin/fpmate.cgi, where the host is the IP address or the name of the printer. Two parameters can be added at the end. devid picks the target printer when the fiscal printer forwards to another one, a kitchen printer for example: empty or local_printer means the same printer you are writing to. timeout says in milliseconds how long to wait for the fiscal firmware, with a default of 10 seconds.
The request is a POST with a SOAP message: the document's XML goes inside the body. The first example in the guide is the status request, which prints nothing.
POST /cgi-bin/fpmate.cgi?devid=local_printer&timeout=10000 HTTP/1.1
Content-Type: text/xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<printerCommand>
<queryPrinterStatus operator="1" statusType="0" />
</printerCommand>
</s:Body>
</s:Envelope>
The response has the same SOAP envelope and, inside it, a response element with three attributes: success (true or false), code (empty, except on error) and status (a number that follows, as far as possible, the status codes of Epson printers). If the command carries extra data, there is also an addInfo element with the list of returned fields.
With statusType="1" the same request asks for the status of the telematic cash register, not just of the printer. It is the first command to try: if it replies with success="true", the address, the network and the service are all fine.
A receipt, line by line
A commercial document has a fixed structure: you open it, add the sales, add the payments, close it. The operator attributes identify the operator.
<printerFiscalReceipt>
<beginFiscalReceipt operator="1" />
<printRecItem operator="1" description="Ricotta cannolo" quantity="2" unitPrice="4,50" department="1" justification="1" />
<printRecItem operator="1" description="Water 1 litre" quantity="1" unitPrice="1,20" department="2" justification="1" />
<printRecTotal operator="1" description="Cash" payment="10,20" paymentType="0" index="1" justification="2" />
<endFiscalReceipt operator="1" />
</printerFiscalReceipt>
The guide sets five rules for every document: it must be opened, it must have at least one sale or refund line, the total cannot be negative, the payment must be completed and the document must be closed. Extra header lines go before beginFiscalReceipt, because they are loaded into memory in advance.
The numbers have precise rules:
- quantity accepts up to three decimals and goes up to 9999.999; both the comma and the period work as the decimal separator and thousands separators are not used
- the unit price goes from 0.00 to 9999999.99; the service rounds down if there are more than two decimals
- the department (
department) carries the VAT rate, which is programmed on the printer, as with the other brands - unit price and payment amount can be zero, quantity cannot, and the amount of a discount or a surcharge must be greater than zero
There are seven payment types: 0 cash, 1 check, 2 credit or card, 3 voucher, 4 multiple vouchers, 5 unpaid and 6 discount to pay. The index attribute selects a specific totalizer and, for unpaid, it indicates the subtype, for example goods, services or invoice to be issued. Several printRecTotal lines allow a split payment, half in cash and half with another method, until the total is reached. If you take payments with an external POS, for example SumUp or Satispay, you record the electronic payment on the printer as type 2: the commercial document is still issued by the telematic cash register.
To write the amounts from PHP, one detail matters: the thousands separator is forbidden, and the number_format function with default parameters adds one.
$importo = number_format($prezzo, 2, ',', '');
The response and what to save
After endFiscalReceipt the printer replies with the data of the document it issued.
<response success="true" code="" status="2">
<addInfo>
<elementList>lastCommand,printerStatus,fiscalReceiptNumber,fiscalReceiptAmount,fiscalReceiptDate,fiscalReceiptTime</elementList>
<lastCommand>74</lastCommand>
<printerStatus>00010</printerStatus>
<fiscalReceiptNumber>2</fiscalReceiptNumber>
<fiscalReceiptAmount>10,20</fiscalReceiptAmount>
<fiscalReceiptDate>26/01/2021</fiscalReceiptDate>
<fiscalReceiptTime>12:13</fiscalReceiptTime>
</addInfo>
</response>
The text of the guide also lists zRepNumber, the progressive number of the day's closing, among the response data; it does not appear in the example shown, so the code has to handle its absence. The fields to save are the document number (the day's progressive, without the Z prefix), the amount, the date, the time and, if present, the closing number: with these you can find the receipt on paper. With the RCH the pair was lastZ and lastDocF, here it is fiscalReceiptNumber together with zRepNumber.
printerStatus is a five-digit code that the guide describes in a separate chapter. For the management system it is enough to remember that success says whether the operation went through, and status with printerStatus help work out why it did not.
The daily closing
For the Z closing there are three commands, one per request: printXReport prints the financial report, printZReport the fiscal closing and printXZReport first the one and right after it the other. The transmission of the data to the Agenzia delle Entrate starts on its own. That is why in the guide these commands have a longer timeout, 6 seconds for the Z and 12 for the X with the Z, and can take a timeout attribute of their own.
<printerFiscalReport>
<printZReport operator="1" timeout="20000" />
</printerFiscalReport>
The response reports the number of the closing issued and the day's cumulative takings, zRepNumber and dailyAmount (in the guide's example, 11 and 332.33). A closing is not something to launch from just any job: it is done by a person who knows the day is over, or by an automation agreed with the accountant.
Voids and refunds
On a telematic cash register a receipt can't be deleted; you void it or refund it with another document. The guide prefers a method that puts a keyword in the document together with the references of the original receipt: VOID for a void and REFUND for a refund, followed by the closing number, the document number, the date in day month year format and the fiscal serial number of the printer. In the example below the serial number is made up.
<printerFiscalReceipt>
<printRecMessage operator="1" message="VOID 0279 0010 08012021 99XXX000000" messageType="4" />
</printerFiscalReceipt>
If the original receipt is in the printer's electronic journal, the void document is printed and closed on its own, and the XML lines that follow are ignored. A goods refund is opened the same way, with the word REFUND, and then continues like a normal document. Two printer settings change the allowed commands: the flags SET 14/58 (refund) and 14/59 (void) choose between the mode with the commands of the old credit notes and the mode with the commands of commercial documents, and printRecRefund requires flag 14/58 to be on. The guide treats the old wordings RESO MERCE and ANNULLAMENTO as obsolete.
Another thing worth knowing: some commands first require a password login, and these are the ones that read the electronic journal or reprint the last document. The guide shows the login as a low-level directIO command (code 4038), with the password followed by spaces up to a fixed length of 100 characters.
Errors, timeouts and documents left open
Where the guide does best is the error table. With success="false" the code field explains what went wrong.
| Code | Meaning in the guide |
|---|---|
PARSER_ERROR |
Malformed XML |
INCOMPLETE FILE |
Minimum elements missing, for example endFiscalReceipt |
EPTR_REC_EMPTY |
Cover open, printer offline or paper roll finished |
PRINTER ERROR |
Error from the native fiscal protocol, with its code in the status (for example a discount with a zero amount) |
FP_NO_ANSWER |
The fiscal firmware did not reply within the timeout |
LAN_ERROR, LAN_TIME_OUT |
Timeout in the communication with a secondary printer |
NO_DATA |
Empty POST request |
Three of these cases are traps for a management system, and the guide says so plainly.
A timeout does not undo what has already been printed
When the time runs out, the operation is cancelled, but according to the guide the XML lines processed before may already have gone through. In other words: a request that times out can leave a receipt half done or already complete, and the management system has no way of knowing. Sending the request again blindly can print twice. After a timeout you ask for the status, you check the last document, and only a person decides. It is the same lesson as in the RCH article, here backed by the specification.
A document without a closing stays open
If endFiscalReceipt is missing, the commercial document stays open and the response is INCOMPLETE FILE. If the closing tag of printerFiscalReceipt is missing, the parsing error arrives right away. If the payment does not cover the total, it is endFiscalReceipt that replies with an error. To get out of a stuck state there is resetPrinter, which brings the printer back to the registration state and cancels the open commercial documents.
A wrong value stops it halfway
With a wrong attribute, the printer processes and prints up to the line with the error and only then returns the error. A fiscal document can therefore come out partial. That is why amounts, quantities and descriptions are checked in the management system before sending, and the printer is not left with the job of rejecting them.
From the browser or from the server
The open CORS header makes the call from the browser possible, but the same two obstacles as in the Custom article remain. An HTTPS page calling an HTTP address is stopped as mixed content, so you need HTTPS on the printer, and the certificate the printer generates by itself is self-signed. The Odoo documentation on Epson printers describes the procedure: open the printer's address, accept the warning, generate the certificate once, export it and import it on the device. Regenerating it makes you lose access from the devices that used the previous one. The same page warns that with recent versions of Chromium the certificate would no longer be needed, and that the recommended method is the local network access permission.
Other management systems rely on the same service. The Microsoft Dynamics 365 Commerce integration sample uses the EpsonFPMate service with the Fiscal ePOS-Print API for the FP-90III, only in telematic cash register mode. The fiskaltrust documentation warns that these printers ship with self-signed certificates and that, when connecting by IP address, you may need to turn off SSL verification: a choice to confine to an internal network, never to copy into production on the internet.
From the server you avoid all this, but the server has to reach the printer: same network, VPN or another protected route, as with the RCH. Odoo, which calls the printer from the checkout device, requires the device and the printer to be on the same local network.
For the configuration on the register, the Odoo documentation for Italy says to enable HTTPS with the EpsonFPWizard software or from the keypad (Web Server: SSL entry) and to use simulation mode for testing. According to that page the switch to production cannot be undone: once done, you do not go back to simulation. It is good to know before choosing the day to switch.
A plan for the first day
To get started with an Epson I would work in this order:
- with the printer in simulation, a
queryPrinterStatusrequest withstatusType="1"to see whether network, service and protocol respond - a test receipt with a single line and cash, and reading the fields of the response
- the department-to-rate map checked with one product per rate
- a deliberately wrong request, to see how the error reaches the management system
- the Z closing and, last, the void of a test document
Limits to know
- I have not tried an Epson printer. Everything I write about its behavior comes from the developer guide, revision T of July 2021: a more recent revision, or a different firmware, can change the details. Before going to production, repeat the tests on a real unit.
- The guide states the rules for data and errors, but does not say how the service behaves with several simultaneous requests. With the other brands that limit existed: with Epson it has to be measured.
- The information on the certificate and on the printer configuration comes from the Odoo documentation, a third party that uses the printer, and I summarized it without testing it: for the settings of your own model you need the Epson manual or the technician who put it into service.
- Fiscal obligations (daily closing, transmission of the takings, voids and refunds) stay with the merchant. A wrong void cannot be erased: talk to the accountant before going live.
Frequently asked questions
Can I call the Epson printer directly from the browser?
Yes: the response has the header that allows cross-domain calls. Still, the self-signed certificate, the mixed content with HTTPS pages and Chrome's local network permission remain. For payments that start with nobody in front of the screen, calling from the server is more reliable.
What is the difference from Custom and RCH?
The XML element names are the same as Custom's, but Epson uses decimal amounts and cash is type 0. The RCH has a text-command format and amounts in cents. The only one with a public specification is Epson. For the other manufacturers you work with the documentation the reseller provides.
How do I avoid printing the same receipt twice?
With one row per sale in the management system, created before the call and updated after the response, with a uniqueness constraint. After a timeout you don't send the request again on your own: you ask for the status and check the last document.
What happens if the paper runs out or the cover is open?
The response has success="false" and the code EPTR_REC_EMPTY. The sale in the management system stays saved, and the receipt still to be issued has to be repeated once the problem is fixed, after checking that it did not come out.
Do I need a PC next to the printer?
No. The service is in the printer and the network is enough. A bridge like the one for Custom is only needed if the server cannot reach the printer.
Where to start
Download the guide and read chapter 2, two pages, then send the status request. If success="true" comes back, the rest is craft: the following chapters are a table of elements and attributes to consult as you go. If it does not come back, every hour spent on receipts is wasted.
Enjoyed the article?
Open the discussion on X
Related Articles

How to Connect an RCH Fiscal Printer to a Web Management System

How to Connect a Custom Fiscal Printer to a Web Management System

What is a domain name and how to choose the right one, .com or .it

Firebase Authentication, how to add email, Google, Apple and SMS login

IDE vs CLI vs TUI vs ADE, how AI coding tools differ

Laravel for Java doesn't exist, but Rust and Go versions have arrived
Stay updated
🌐 3k readers worldwide, every SaturdaySubscribe to the newsletter to receive new articles directly in your inbox.
