Skip to main content
1

Create an Account

Register for a new account by providing your email and password.
curl -X POST https://api.contafy.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "your-secure-password",
    "nombre": "Juan",
    "apellido": "Pérez",
    "telefono": "+52 55 1234 5678"
  }'
Password must be at least 8 characters long. After registration, you’ll receive a verification email.
Response:
{
  "message": "Usuario registrado correctamente. Por favor verifica tu email.",
  "user": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "email": "[email protected]",
    "nombre": "Juan",
    "apellido": "Pérez",
    "telefono": "+52 55 1234 5678",
    "email_verified": false
  }
}
2

Login and Get Access Token

Authenticate with your credentials to receive JWT tokens.
curl -X POST https://api.contafy.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "your-secure-password"
  }'
Response:
{
  "message": "Login exitoso",
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "email": "[email protected]",
    "nombre": "Juan",
    "apellido": "Pérez",
    "telefono": "+52 55 1234 5678",
    "email_verified": true
  }
}
Save both accessToken and refreshToken. The access token expires in 15 minutes, while the refresh token lasts 7 days.
3

Create Your First Profile

Create a fiscal profile to process invoices. Each profile represents a Mexican RFC (tax ID).
curl -X POST https://api.contafy.com/api/profiles \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
    "nombre": "Mi Empresa SA de CV",
    "rfc": "ABC123456789",
    "tipo_persona": "MORAL",
    "regimenes_fiscales": ["601"]
  }'
Response:
{
  "message": "Perfil creado correctamente",
  "profile": {
    "id": "987e6543-e21b-12d3-a456-426614174000",
    "nombre": "Mi Empresa SA de CV",
    "rfc": "ABC123456789",
    "tipo_persona": "MORAL",
    "regimenes_fiscales": ["601"],
    "user_id": "123e4567-e89b-12d3-a456-426614174000",
    "frozen": false
  }
}
RFC Format: Must match the Mexican tax ID format (3-4 letters + 6 digits + 3 characters)Tipo Persona: Choose FISICA for individuals or MORAL for companiesRegímenes Fiscales: Array of SAT fiscal regime codes (e.g., “601”, “612”)
4

Upload Your First Invoice

Process a Mexican CFDI invoice by uploading the XML file.
curl -X POST https://api.contafy.com/api/invoices/upload \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -F "xml=@/path/to/invoice.xml" \
  -F "profileId=987e6543-e21b-12d3-a456-426614174000"
Response:
{
  "message": "Factura guardada correctamente",
  "invoice": {
    "id": "456e7890-e12b-34d5-b678-901234567890",
    "uuid": "12345678-1234-1234-1234-123456789012",
    "tipo": "INGRESO",
    "fecha_emision": "2024-03-15T10:30:00.000Z",
    "rfc_emisor": "DEF987654321",
    "nombre_emisor": "Proveedor SA",
    "rfc_receptor": "ABC123456789",
    "nombre_receptor": "Mi Empresa SA de CV",
    "subtotal": 10000.00,
    "total": 11600.00,
    "moneda": "MXN",
    "estado_validacion": {
      "valido": true,
      "rfcVerificado": true,
      "regimenFiscalVerificado": true,
      "uuidDuplicado": false,
      "advertencias": [],
      "errores": []
    }
  }
}
The API automatically validates the CFDI against your profile’s RFC and fiscal regime. Check the estado_validacion object for any issues.
5

Retrieve Invoice Data

Fetch your processed invoices with optional filtering and pagination.
curl -X GET "https://api.contafy.com/api/invoices?profileId=987e6543-e21b-12d3-a456-426614174000&page=1&limit=10" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response:
{
  "invoices": [
    {
      "id": "456e7890-e12b-34d5-b678-901234567890",
      "uuid": "12345678-1234-1234-1234-123456789012",
      "tipo": "INGRESO",
      "fecha_emision": "2024-03-15T10:30:00.000Z",
      "total": 11600.00,
      "moneda": "MXN",
      "rfc_emisor": "DEF987654321",
      "nombre_emisor": "Proveedor SA"
    }
  ],
  "pagination": {
    "currentPage": 1,
    "totalPages": 1,
    "totalItems": 1,
    "itemsPerPage": 10
  }
}

Next Steps

Authentication

Learn about JWT authentication, token refresh, and security best practices

Profiles API

Manage fiscal profiles and configure validation rules

Invoices API

Process CFDI invoices and retrieve parsed data

Subscriptions

Manage plans and monitor usage limits

Alternative: Google Authentication

You can also authenticate using Google Sign-In:
curl -X POST https://api.contafy.com/api/auth/google \
  -H "Content-Type: application/json" \
  -d '{
    "idToken": "FIREBASE_ID_TOKEN"
  }'
This endpoint accepts a Firebase ID token and returns the same JWT tokens as the standard login endpoint.

Default Subscription

All new accounts automatically receive a FREE plan with:
  • 1 fiscal profile
  • 100 invoices per month
  • Basic validation features
Upgrade to BASIC, PRO, or ENTERPRISE plans for more profiles and higher invoice limits.

Build docs developers (and LLMs) love