The SAT (Servicio de Administración Tributaria) portal uses a custom image CAPTCHA that blocks automation tools. If you're building accounting software, an ERP integration, or a tax compliance workflow, you need to solve it programmatically. This guide shows you how.
What is the SAT CAPTCHA?
The SAT portal at sat.gob.mx uses a distorted text image CAPTCHA — typically 4–6 alphanumeric characters on a noisy background. It appears on:
- RFC lookup and validation
- CSF (Constancia de Situación Fiscal) downloads
- CFDI verification portal
- SAT ID and e.firma processes
- Tax declaration portals
Standard OCR tools fail on SAT's CAPTCHA due to the distortion and noise. You need an AI model trained specifically on it.
Solving SAT CAPTCHA with Ocilar
Ocilar is the only CAPTCHA solving API with a dedicated model for SAT Mexico. Accuracy: 97%+. Average latency: <70ms.
cURL
curl -X POST https://api.ocilar.com/api/v1/solve/sat \
-H "X-API-Key: sk-your_key" \
-H "Content-Type: application/json" \
-d '{"image":"<base64_string>"}'
# Response
{"text":"2VBF39","confidence":0.98,"latency_ms":69,"credits_used":1} Python — extract base64 from page with Playwright
import asyncio
import base64
from playwright.async_api import async_playwright
from ocilar import OcilarClient
async def solve_sat_captcha():
client = OcilarClient(api_key="sk-your_key")
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
# Navigate to SAT portal
await page.goto("https://www.sat.gob.mx/aplicacion/operacion/66288/consulta-tu-constancia-de-situacion-fiscal")
# Wait for CAPTCHA image to load
await page.wait_for_selector("img[src*='captcha']")
# Extract CAPTCHA image as base64
captcha_img = await page.query_selector("img[src*='captcha']")
captcha_b64 = await page.evaluate("""(img) => {
const canvas = document.createElement('canvas');
canvas.width = img.width;
canvas.height = img.height;
canvas.getContext('2d').drawImage(img, 0, 0);
return canvas.toDataURL('image/png').split(',')[1];
}""", captcha_img)
# Solve with Ocilar
result = client.solve_sat(image_base64=captcha_b64)
print(f"CAPTCHA solved: {result.text}") # e.g. "2VBF39"
# Fill in the form
await page.fill("#captchaInput", result.text)
await page.click("#submitBtn")
await browser.close()
asyncio.run(solve_sat_captcha()) Node.js — with Playwright
import { chromium } from 'playwright'
import { OcilarClient } from '@ocilar/sdk'
const client = new OcilarClient({ apiKey: 'sk-your_key' })
const browser = await chromium.launch({ headless: true })
const page = await browser.newPage()
await page.goto('https://www.sat.gob.mx/...')
await page.waitForSelector("img[src*='captcha']")
// Extract CAPTCHA as base64
const captchaB64 = await page.$eval("img[src*='captcha']", img => {
const canvas = document.createElement('canvas')
canvas.width = img.width
canvas.height = img.height
canvas.getContext('2d').drawImage(img, 0, 0)
return canvas.toDataURL('image/png').split(',')[1]
})
// Solve
const { text } = await client.solveSat({ image: captchaB64 })
console.log(text) // "2VBF39"
await page.fill('#captchaInput', text)
await page.click('#submitBtn')
await browser.close() Common SAT portal workflows to automate
RFC validation
Many accounting and fintech platforms need to validate RFC numbers against the SAT database. The lookup page requires a CAPTCHA on every request.
result = client.solve_sat(image_base64=captcha_b64)
# Fill RFC field + CAPTCHA, then submit
await page.fill("#rfc", "JUAJ850101ABC")
await page.fill("#captcha", result.text)
await page.click("#consultar") CSF (Constancia de Situación Fiscal) download
The CSF document is required for onboarding suppliers, opening bank accounts, and tax filings. Automating its download is a common need for:
- B2B onboarding platforms
- Accounting firms managing many clients
- ERPs that sync supplier tax data
Pricing
SAT Mexico CAPTCHA costs $0.10 per 1,000 solves — the same as IMSS. No other CAPTCHA solving service offers this.
| Service | SAT Mexico support | Price / 1K |
|---|---|---|
| 2Captcha | Generic image only | $0.50 |
| CapSolver | Not supported | — |
| Anti-Captcha | Not supported | — |
| Ocilar | Dedicated SAT model | $0.10 |
FAQ
Does this work for all SAT portal pages?
Yes. The SAT CAPTCHA type is consistent across all pages on sat.gob.mx that require one. The same endpoint handles all of them.
What accuracy can I expect?
97%+ on SAT CAPTCHAs. Failed solves (under 3%) are not charged — you only pay for successful solves.
Is automating SAT portal access legal?
Ocilar solves the CAPTCHA — what you do with that access is your responsibility. Using SAT's portal programmatically to access your own tax information is standard practice for accounting software and ERPs. Ocilar is not affiliated with or endorsed by SAT.
Can I also extract CSF data after solving the CAPTCHA?
Yes. Ocilar also provides a CSF extraction endpoint that parses RFC, fiscal regime, tax address, and activity codes from the downloaded PDF.