> ## Documentation Index
> Fetch the complete documentation index at: https://docs-mx.taxo.ws/llms.txt
> Use this file to discover all available pages before exploring further.

# Tax Retention Documents

> Understanding Mexican tax retention certificates and their extraction from SAT

## Overview

**Tax Retention Documents** (Comprobantes de Retención) are official certificates issued when taxes are withheld from payments in Mexico. These documents are mandatory for various business transactions including contractor payments, professional services, and rental income.

## What are Tax Retention Documents?

Tax retention documents serve as proof that taxes have been withheld and paid to SAT on behalf of the recipient. They are essential for:

* **Tax compliance**: Proving taxes were properly withheld
* **Income declarations**: Supporting deductions and credits
* **Audit requirements**: Maintaining proper tax records
* **Business relationships**: Transparency between parties

<AccordionGroup>
  <Accordion title="Legal Framework" icon="scale-balanced">
    Tax retention in Mexico is governed by:

    * **Income Tax Law (ISR)**: Defines retention requirements
    * **VAT Law (IVA)**: Sets VAT retention rules
    * **SAT Guidelines**: Operational procedures and formats
    * **CFF (Fiscal Code)**: General tax obligations
  </Accordion>

  <Accordion title="Digital Structure" icon="code">
    Tax retention documents are XML-based with specific structure:

    ```xml theme={null}
    <retenciones:Retenciones>
      <retenciones:Emisor RfcEmisor="ABC123456789"/>
      <retenciones:Receptor RfcRecep="XYZ987654321"/>
      <retenciones:Periodo MesIni="01" MesFin="01" Ejerc="2024"/>
      <retenciones:Totales MontoTotOperacion="10000.00" 
                           MontoTotRet="1000.00"/>
      <retenciones:ImpRetenidos>
        <retenciones:ImpRet BaseRet="10000.00" 
                           Impuesto="001" 
                           MontoRet="1000.00"/>
      </retenciones:ImpRetenidos>
    </retenciones:Retenciones>
    ```
  </Accordion>

  <Accordion title="Available Formats" icon="file">
    Tax retention documents can be retrieved as:

    * **XML**: Original structured data with all fiscal information
    * **PDF**: Human-readable certificate for printing and sharing
    * **Metadata**: Extracted key fields for integration
  </Accordion>
</AccordionGroup>

## Types of Tax Retention

### Common Retention Scenarios

<CardGroup cols={2}>
  <Card title="Professional Services" icon="briefcase">
    **Retention Rate**: 10% ISR + 10.67% VAT

    * Legal services
    * Consulting fees
    * Professional advice
    * Technical services
  </Card>

  <Card title="Contractor Payments" icon="hammer">
    **Retention Rate**: Variable based on service

    * Construction work
    * Maintenance services
    * Installation projects
    * Repair services
  </Card>

  <Card title="Rental Income" icon="building">
    **Retention Rate**: 10% ISR

    * Property rental
    * Equipment leasing
    * Vehicle rental
    * Commercial spaces
  </Card>

  <Card title="Transportation" icon="truck">
    **Retention Rate**: 4% ISR

    * Freight services
    * Logistics
    * Courier services
    * Cargo transport
  </Card>
</CardGroup>

### Tax Types Subject to Retention

| Tax Code | Tax Name         | Common Rate | Description                   |
| -------- | ---------------- | ----------- | ----------------------------- |
| `001`    | ISR (Income Tax) | 10%         | Most professional services    |
| `002`    | IVA (VAT)        | 10.67%      | Services with VAT retention   |
| `003`    | IEPS             | Variable    | Special products and services |

## Extracting Tax Retention Documents

### Basic Extraction Request

```json theme={null}
{
  "subject": {
    "identifier": "ABC123456789"
  },
  "credentials": {
    "SAT": {
      "type": "USERNAME_PASSWORD", 
      "username": "ABC123456789",
      "password": "CIEC_PASSWORD"
    }
  },
  "options": {
    "informationType": "TAX_RETENTION",
    "direction": "INBOUND",
    "period": {
      "from": "2024-01-01",
      "to": "2024-01-31"
    }
  }
}
```

### Advanced Filtering Options

<CodeGroup>
  ```json Filter by Withholding Agent theme={null}
  {
    "filters": {
      "emitter": {
        "operator": "equals",
        "value": "GACJ841128A87"
      }
    }
  }
  ```

  ```json Filter by Retention Amount theme={null}
  {
    "filters": {
      "retentionAmount": {
        "operator": "greater_than",
        "value": 5000
      }
    }
  }
  ```

  ```json Filter by Tax Type theme={null}
  {
    "filters": {
      "taxType": {
        "operator": "in",
        "value": ["001", "002"]
      }
    }
  }
  ```
</CodeGroup>

## Key Data Fields

### Essential Retention Information

<AccordionGroup>
  <Accordion title="Parties Information" icon="users">
    **Withholding Agent (Emisor)**:

    * RFC and business name
    * Address and contact information
    * Retention authority designation

    **Recipient (Receptor)**:

    * RFC and taxpayer name
    * Tax regime information
    * Address details
  </Accordion>

  <Accordion title="Financial Details" icon="calculator">
    **Payment Information**:

    * Total operation amount
    * Taxable base for each tax
    * Retention rates applied
    * Total retained amounts

    **Tax Breakdown**:

    * ISR retention details
    * VAT retention (if applicable)
    * Other applicable taxes
  </Accordion>

  <Accordion title="Period and Dates" icon="calendar">
    **Time Information**:

    * Payment period covered
    * Retention certificate issue date
    * SAT validation timestamp
    * Fiscal year reference
  </Accordion>
</AccordionGroup>

## Direction Types

<Tip>
  Understanding direction is crucial for proper accounting treatment.
</Tip>

| Direction  | Description                                | Accounting Impact                           |
| ---------- | ------------------------------------------ | ------------------------------------------- |
| `INBOUND`  | Taxes retained from payments you received  | **Tax Credit** - Reduces your tax liability |
| `OUTBOUND` | Taxes you retained from payments to others | **Tax Liability** - Must be paid to SAT     |

## Integration Examples

### Processing Inbound Retention Certificates

```javascript theme={null}
// Process retention certificates received (tax credits)
async function processInboundRetentions(extractions) {
  const retentions = await getCompletedDocuments(extractions, 'TAX_RETENTION');
  
  for (const retention of retentions) {
    const retentionData = await parseRetentionXML(retention.xmlContent);
    
    // Record as tax credit
    await recordTaxCredit({
      period: retentionData.period,
      withholdingAgent: retentionData.emitter.name,
      isrRetention: retentionData.taxes.isr.amount,
      vatRetention: retentionData.taxes.iva.amount,
      totalCredit: retentionData.totalRetention,
      certificateId: retentionData.uuid
    });
    
    console.log(`Processed retention credit: $${retentionData.totalRetention}`);
  }
}
```

### Processing Outbound Retention Obligations

```javascript theme={null}
// Process retention certificates issued (tax obligations)
async function processOutboundRetentions(extractions) {
  const retentions = await getCompletedDocuments(extractions, 'TAX_RETENTION');
  
  for (const retention of retentions) {
    const retentionData = await parseRetentionXML(retention.xmlContent);
    
    // Record as tax obligation
    await recordTaxObligation({
      period: retentionData.period,
      recipient: retentionData.receptor.name,
      baseAmount: retentionData.operationAmount,
      retainedAmount: retentionData.totalRetention,
      dueDate: calculateDueDate(retentionData.period),
      status: 'pending_payment'
    });
    
    console.log(`Recorded retention obligation: $${retentionData.totalRetention}`);
  }
}
```

### Monthly Retention Report

```javascript theme={null}
// Generate monthly retention summary
async function generateRetentionReport(month, year) {
  const period = {
    from: `${year}-${month.padStart(2, '0')}-01`,
    to: `${year}-${month.padStart(2, '0')}-31`
  };
  
  // Get both inbound and outbound retentions
  const [inboundRetentions, outboundRetentions] = await Promise.all([
    extractRetentions('INBOUND', period),
    extractRetentions('OUTBOUND', period)
  ]);
  
  const report = {
    period: `${year}-${month}`,
    credits: {
      count: inboundRetentions.length,
      totalISR: sumRetentionsByTax(inboundRetentions, '001'),
      totalVAT: sumRetentionsByTax(inboundRetentions, '002'),
      totalAmount: sumTotalRetentions(inboundRetentions)
    },
    obligations: {
      count: outboundRetentions.length,
      totalISR: sumRetentionsByTax(outboundRetentions, '001'),
      totalVAT: sumRetentionsByTax(outboundRetentions, '002'),
      totalAmount: sumTotalRetentions(outboundRetentions)
    },
    netPosition: calculateNetPosition(inboundRetentions, outboundRetentions)
  };
  
  return report;
}
```

## Compliance Requirements

### Legal Obligations

<Warning>
  **Retention Payment Deadline**: Retained taxes must be paid to SAT by the 17th of the following month.
</Warning>

<AccordionGroup>
  <Accordion title="For Withholding Agents" icon="building">
    **Responsibilities**:

    * Calculate correct retention rates
    * Issue retention certificates within 30 days
    * Pay retained taxes to SAT by deadline
    * File monthly retention declarations

    **Penalties for non-compliance**:

    * Late payment: 1.13% monthly interest
    * Missing certificates: Fines up to \$15,000 MXN
    * Incorrect retention: Additional penalties
  </Accordion>

  <Accordion title="For Recipients" icon="user">
    **Rights and obligations**:

    * Request retention certificates
    * Apply credits in tax declarations
    * Keep certificates for 5 years
    * Report discrepancies to SAT

    **Benefits**:

    * Reduce tax liability
    * Improve cash flow
    * Simplified tax compliance
  </Accordion>
</AccordionGroup>

### Best Practices

<Checklist>
  <Check>Reconcile retention certificates with payment records monthly</Check>
  <Check>Verify retention rates match current SAT regulations</Check>
  <Check>Store both XML and PDF versions for audit purposes</Check>
  <Check>Set up alerts for missing retention certificates</Check>
  <Check>Automate retention calculations to prevent errors</Check>
  <Check>Review retention positions before tax declarations</Check>
</Checklist>

## Common Issues and Solutions

<AccordionGroup>
  <Accordion title="Missing Retention Certificates" icon="exclamation-triangle">
    **Problem**: Expected certificates not found in SAT system

    **Possible Causes**:

    * Withholding agent hasn't issued certificate
    * Incorrect RFC information
    * Processing delays in SAT system

    **Solutions**:

    * Contact withholding agent for certificate status
    * Verify RFC spelling and format
    * Wait 24-48 hours for SAT processing
    * Use alternative documentation if necessary
  </Accordion>

  <Accordion title="Incorrect Retention Amounts" icon="calculator">
    **Problem**: Retention amounts don't match expectations

    **Possible Causes**:

    * Wrong retention rate applied
    * Calculation errors
    * Different taxable base interpretation

    **Solutions**:

    * Verify current retention rates with SAT
    * Review taxable base calculations
    * Consult with tax advisor for complex cases
    * Request correction from withholding agent
  </Accordion>

  <Accordion title="XML Parsing Errors" icon="code">
    **Problem**: Cannot process retention XML data

    **Possible Causes**:

    * Corrupted file download
    * Invalid XML structure
    * Missing required fields

    **Solutions**:

    * Re-download document from SAT
    * Validate XML against SAT schemas
    * Use robust XML parsing libraries
    * Implement error handling for malformed data
  </Accordion>
</AccordionGroup>

## Integration with Accounting Systems

### Automatic Journal Entries

```javascript theme={null}
// Create accounting entries for retention certificates
async function createRetentionJournalEntry(retentionData, direction) {
  const entries = [];
  
  if (direction === 'INBOUND') {
    // Tax credits from received retention certificates
    entries.push({
      account: 'ISR_RECEIVABLE',
      debit: retentionData.taxes.isr.amount,
      description: `ISR retention credit - ${retentionData.emitter.name}`
    });
    
    if (retentionData.taxes.iva.amount > 0) {
      entries.push({
        account: 'VAT_RECEIVABLE', 
        debit: retentionData.taxes.iva.amount,
        description: `VAT retention credit - ${retentionData.emitter.name}`
      });
    }
    
    entries.push({
      account: 'ACCOUNTS_RECEIVABLE',
      credit: retentionData.totalRetention,
      description: `Total retention credit`
    });
  } else {
    // Tax obligations from issued retention certificates
    entries.push({
      account: 'ACCOUNTS_PAYABLE',
      debit: retentionData.totalRetention,
      description: `Retention obligation - ${retentionData.receptor.name}`
    });
    
    entries.push({
      account: 'ISR_PAYABLE',
      credit: retentionData.taxes.isr.amount,
      description: `ISR retention obligation`
    });
  }
  
  await createJournalEntry({
    date: retentionData.issueDate,
    reference: retentionData.uuid,
    entries: entries
  });
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="SAT API Quickstart" icon="rocket" href="/countries/mx/tax-authorities/sat/quickstart">
    Start extracting retention documents from SAT
  </Card>

  <Card title="CFDI Invoices" icon="file-invoice" href="/countries/mx/document-types/cfdi-invoices">
    Learn about invoice extraction and processing
  </Card>

  <Card title="Use Cases" icon="lightbulb" href="/countries/mx/use-cases/compliance-automation">
    See retention compliance automation examples
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/global/troubleshooting/common-errors">
    Resolve common retention processing issues
  </Card>
</CardGroup>
