What is a SAT code?
In Mexico, every invoice (CFDI) must include a product/service code from the official SAT catalog. These codes identify what’s being invoiced and determine tax treatment. The SAT catalog (c_ClaveProdServ) contains thousands of codes with specific attributes:
SAT codes indicate whether VAT (IVA) and excise tax (IEPS) should be included. This is critical for proper tax calculation and compliance.
How SAT search works
Natural language input
Instead of browsing through thousands of codes, you describe your activity in plain Spanish:- “Venta de calzado deportivo”
- “Servicios de limpieza de oficinas”
- “Diseño gráfico publicitario”
AI-enhanced search
The search process involves:- User query analysis - GPT-4o-mini interprets your natural language description
- Search term extraction - AI identifies relevant keywords and synonyms
- Similarity matching - Vector similarity search against SAT catalog
- Ranking and filtering - Results ordered by relevance
- Confidence scoring - AI assigns confidence level (high/medium/low)
The AI explanation appears in the results card, helping you understand why specific codes were suggested and how they relate to your query.
Plan limits
AI-enhanced searches are limited by subscription plan:Plan tiers
- FREE - Limited AI searches per month, basic features
- BASIC - More AI searches, AI explanations enabled
- PREMIUM - High search limit, all features unlocked
- ENTERPRISE - Unlimited searches (aiSearchesLimit: null)
Using the search interface
Search bar
The main search bar (/dashboard/sat-search) includes:
- Text input for natural language queries
- Real-time search counter showing remaining searches
- AI badge indicating GPT-4o-mini powered search
- Disabled state when limit reached
Suggestions
Before searching, common suggestion chips help you get started:Results display
Search results show:- Clave SAT - The numeric code (e.g., 80141600)
- Descripción - Official SAT description
- IVA trasladado - Whether VAT applies (Sí/No/Opcional)
- IEPS trasladado - Whether excise tax applies
- Vigencia - Validity period (start and end dates)
AI explanation card
When AI explanations are enabled (BASIC plan and above), you’ll see:- IA (GPT-4o-mini) badge - Shows AI is active
- Confidence badge - Color-coded confidence level
- Green (high) - AI is very confident in the results
- Yellow (medium) - Results are likely correct
- Gray (low) - Manual verification recommended
- Analysis text - Explains reasoning behind results
Search state management
The search component uses React state:- Check if AI searches remaining > 0
- If limit reached, show upgrade modal
- If available, call
searchSATWithAI(query)server action - Display results with AI explanation
- Update remaining count
Server action
Search is powered by a server action:- Subscription limit checking
- AI query analysis
- Database similarity search
- Usage tracking
- Error handling
The SAT search uses PostgreSQL’s vector similarity features (pgvector) for efficient semantic search across thousands of product codes.
Limit reached handling
When you’ve used all AI searches:- Current plan badge
- Feature description
- Recommended upgrade plan
- Direct link to subscription management
Result pagination
Results are paginated to improve performance:- Navigate with previous/next buttons
- Click page numbers to jump
- Pagination respects plan’s maxResults setting
Edge cases
No results
If the AI finds no matching codes:Invalid vigencia
Some SAT codes have expiration dates (fecha_fin_vigencia). Check the vigencia field to ensure the code is currently valid.
Special requirements
Thecomplemento_que_debe_incluir field indicates if the code requires a specific invoice complement (special XML sections). This is important for certain industries.
Related features
API endpoints
The SAT search uses these API routes:- GET /api/sat/stats - Returns plan limits and usage
- POST /api/sat/search - Performs AI-enhanced search
- GET /api/sat/similarity - Finds similar codes
- GET /api/sat/regimenes-fiscales - Returns tax regime catalog
Technical implementation
Key files:app/dashboard/sat-search/page.tsx- Main search pageapp/dashboard/sat-search/components/SATSearchContent.tsx- Search UI logicapp/dashboard/sat-search/components/SATSearchBar.tsx- Search input componentapp/dashboard/sat-search/components/SATSearchResults.tsx- Results displayapp/dashboard/sat-search/actions.ts- Server actions for searchlib/types/sat.ts- TypeScript types for SAT datalib/api/sat.client.ts- Client-side API calls