holidaysapiclean-codetechnical-debtsaas

Why Hardcoding Brazilian Holidays Will Break Your SaaS (The 5,570 Municipalities Problem)

Photo of João Bini
João Bini
6 min read

If you are a software architect or backend developer building SaaS platforms, ERP systems, or logistics software that operates in Brazil, you or your team have almost certainly written this exact piece of technical debt:

holidays.py
python
# DO NOT DO THIS IN PRODUCTION
holidays_2026 = [
"2026-01-01", # New Year
"2026-04-21", # Tiradentes
"2026-05-01", # Labor Day
# ... what about Carnival? Corpus Christi? State and municipal holidays?
]

It looks innocent at first. You copy a static array of 10 national holidays into a configuration file, deploy to production, and move on to your next sprint. But in Brazil, this pattern is a ticking time bomb that causes silent bugs, failed SLAs, illegal invoice penalties, and customer churn.

In this article, we explain why hardcoding holiday arrays breaks enterprise SaaS platforms, explore the mathematical complexity of Brazilian municipal calendars, and show how to replace static files with dynamic, real-time API validation.

The 3 Reasons Why Static Holiday Arrays Fail

1. The Easter Algorithm & Floating Holidays

In Brazil, several critical business holidays change dates every single year because they depend on the lunar calendar calculation of Easter Sunday:

  • Carnival: Exactly 47 days before Easter Sunday.
  • Good Friday: Exactly 2 days before Easter Sunday.
  • Corpus Christi: Exactly 60 days after Easter Sunday.

If your backend cron jobs rely on last year's static dates, your billing system will attempt to settle invoices on Carnival Monday or pause operations on the wrong week.

2. The 5,570 Municipalities Problem

National holidays represent less than 1% of the actual public holidays celebrated in Brazil. Each of the 26 states plus the Federal District has statutory regional holidays (e.g., July 9 in São Paulo or November 20 in various states), and every single one of the 5,570 municipalities can declare up to four civic and religious holidays.

If your SaaS manages logistics, delivery SLAs, or field service scheduling, treating São Paulo, Rio de Janeiro, and Campinas as having identical working days guarantees missed delivery deadlines and frustrated customers.

3. Legislative Volatility

Brazilian municipal and state legislatures frequently modify holiday laws, move city anniversary dates, or create new statutory holidays with short notice. Static arrays in git repositories inevitably fall out of sync with real-world legal compliance.

The Solution: Dynamic Real-Time API Validation

Modern enterprise engineering replaces static arrays with stateless, real-time validation against a specialized holiday API. Here is how clean, maintainable backend validation looks in Python:

business_days.py
python
import requests
from datetime import date
def is_business_day(check_date: date, ibge_code: str = "3550308"):
# Real-time validation against the Feriados API
resp = requests.get(
f"https://api.feriadosapi.com/v1/feriados/verificar?data={check_date}&ibge={ibge_code}",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
if resp.status_code == 200:
data = resp.json()
if data.get('is_feriado', False):
print(f"Holiday detected: {data['feriado']['nome']} ({data['feriado']['tipo']})")
return False
return check_date.weekday() < 5

When querying a municipal date (for example, January 25 in São Paulo using IBGE code 3550308— Brazil's standardized 7-digit municipality census identifier, equivalent to US FIPS codes), the API returns structured JSON confirming the exact local observance:

json
{
"data": "2026-01-25",
"is_feriado": true,
"feriado": {
"data": "2026-01-25",
"nome": "Aniversário de São Paulo",
"tipo": "MUNICIPAL",
"codigo_ibge": "3550308"
}
}
💡 Cache with Confidence: To optimize latency and API consumption, you can safely cache Feriados API responses in Redis or Memcached using a 24-hour or 7-day TTL, ensuring sub-millisecond validation without sacrificing accuracy.

Stop managing static holiday arrays and eliminate calendar technical debt today. Get your free Feriados API token and make your SaaS platform 100% compliant with Brazilian calendars.

João Bini
Written by

João BiniFounder of Feriados API

Entrepreneur, developer, and specialist in Brazilian geographic and tax data intelligence. Helps companies and developers eliminate labor liabilities and scheduling errors using technology and automation.

Tired of handling holidays manually?

Get your Feriados API key and integrate Brazilian national, state, and municipal holidays in minutes. Free tier available.

Get free API key