logoalt Hacker News

lestxlast Sunday at 3:21 AM11 repliesview on HN

Brazil runs the largest mandatory e-invoicing system on Earth. Every invoice, every truckload, every retail receipt in a $2T economy passes through government SOAP 1.2 webservices. In 2026.

Want to integrate? The documentation is four PDF manuals totaling over 1,000 pages, spread across different portals, with critical details that are simply not written anywhere. Two examples we paid for in hours of debugging: the freight document (CT-e) and the manifest (MDF-e) implement the same distribution spec with incompatible envelopes (one wraps the payload and requires an author state code, the other rejects that field and wants the state code in the SOAP header). And the SOAP action must travel inside the Content-Type header; send a SOAPAction header like every SOAP tutorial on the internet tells you to, and the server refuses you without explaining why.

So we mapped all 29 webservices across the 4 document models into one Postman collection: ready-to-fire envelopes, per-host mTLS certificate setup documented, and the distribution services validated against the production government endpoints, not just written from the manuals.

Where you can make it better: Brazil has 27 states and several run their own authorizer URLs (Sao Paulo's retail invoices, for one). We cover the shared authorizer plus the national environment; state-specific URL mappings are the top open contribution. The collection is generated from a Python inventory file, so a PR is a 5-line diff, not JSON surgery.

Docs in Portuguese (the devs suffering with this are Brazilian), but I'll answer anything here in English.


Replies

uncle_kostyatoday at 5:41 AM

SOAP 1.2 strikes me as really reasonable - it's a mature format with interop to several languages and has schema validation.

The inconsistencies you describe above are probably due to each org in the government implementing the common spec independently of the others, and introducing differences without even knowing. Documentation is key here, but as with any large system, there can be gaps.

It's really cool that you mapped it all.

And kudos to Brazil for creating a common computerized platform.

show 1 reply
agopaultoday at 8:31 AM

E-invoicing has been mandatory in Italy too for a while. The rollout started in 2014, but it took years to complete. The main integration system is based on the exchange of XML files via SFTP.

So sending an invoice means leaving an XML file in a folder, then polling the server and waiting a few hours to get a response in the form of another XML file in another folder.

You can also integrate via web service, but I think SFTP is still the most popular method, especially for its batching capabilities.

belZaahtoday at 5:51 AM

What’s the rationale of all this? I mean countries have gotten (mostly) rid of black books without such systems. Maintaining such a solution must be horribly expensive and what if it goes down?

kstrausertoday at 4:24 AM

So, first up: why? Why is everything still using SOAP? I'm not talking down on Brazil, by the way. I've worked in American healthcare tech, and at some point you find yourself learning EDI to talk to insurance companies.

show 8 replies
uefifjfj384today at 8:07 AM

Hold up, the alternatives I’m familiar are (UK) involve sending arbitrary documents which are read by humans, or ingressed into matching systems to then be checked by humans, so that key fields can be extracted…

I read every invoice goes through a standard interface an improvement, no?

motbus3today at 6:53 AM

I dealt with Brazil payment system before and if is not bad at all. If could be simpler, but it is a plain 3/5. But Brazil taxes cannot be built not even by PhD 600 GPU Next Gen Hacker AI

nidnoggtoday at 5:31 AM

Why Postman? There are nicer, git friendlier options for something being shown as a git repo primarily.

show 1 reply
juustotoday at 4:27 AM

Great job. Are there any interesting facts or anecdotes you found while perusing content?

rtpgtoday at 4:34 AM

have there been any "here's a nicer wrapper API" services out there? Or is the complexity somewhat upstream of "real" complexity/differences in reporting.

show 1 reply
tclancytoday at 4:29 AM

It’s been a long time since I had to work in SOAP. Does https://soapy.sourceforge.net/ atill work? That would make things easier to automate if so. This is awesome work.

show 1 reply
Scarbutttoday at 5:29 AM

What programming languages have the best ecosystems to interact with SOAP 1.2 ? What's your stack/libs to interact with it?

show 2 replies