This reference provides functions and utilities for parsing CLABE numbers into their individual components, along with SPEI operational timing constraints and validation patterns.
For detailed operational information about SPEI including operating hours, processing times, and holiday calendar, see the Payment Methods Reference page.

CLABE Component Structure

CLABE numbers contain four distinct components that can be extracted for processing. For detailed information about CLABE structure and validation algorithms, see CLABE Validation. A quick overview of the CLABE components:
  • Bank Code (positions 1-3): Identifies the financial institution.
  • Branch Code (positions 4-6): Identifies the specific branch.
  • Account Number (positions 7-17): The actual account identifier.
  • Check Digit (position 18): Validation digit calculated using algorithm.

Implementation Examples

Here you can find ready-to-use code examples for common CLABE processing and SPEI validation tasks:
This function parses a CLABE number into its individual components for further processing:
def parse_clabe(clabe):
    """Parse CLABE into its components"""
    
    if not validate_clabe(clabe):
        raise ValueError("Invalid CLABE format")
    
    return {
        'bank_code': clabe[:3],
        'branch_code': clabe[3:6],
        'account_number': clabe[6:17],
        'check_digit': clabe[17],
        'full_clabe': clabe
    }

# Example usage
clabe_parts = parse_clabe("012345678901234567")
print(f"Bank: {clabe_parts['bank_code']}")
print(f"Branch: {clabe_parts['branch_code']}")
print(f"Account: {clabe_parts['account_number']}")
print(f"Check Digit: {clabe_parts['check_digit']}")
This function checks if SPEI transfers are currently being processed based on Mexico City time and operating schedules:
from datetime import datetime
import pytz

def is_spei_operating_time(timestamp=None):
    """Check if SPEI is currently operating"""
    
    if timestamp is None:
        timestamp = datetime.now()
    
    # Convert to Mexico City timezone
    mexico_tz = pytz.timezone('America/Mexico_City')
    if timestamp.tzinfo is None:
        timestamp = pytz.utc.localize(timestamp)
    
    mexico_time = timestamp.astimezone(mexico_tz)
    
    # Check day of week (0 = Monday, 6 = Sunday)
    weekday = mexico_time.weekday()
    hour = mexico_time.hour
    
    if weekday < 5:  # Monday to Friday
        return 6 <= hour < 18
    elif weekday == 5:  # Saturday
        return 9 <= hour < 14
    else:  # Sunday
        return False

# Example usage
now = datetime.now(pytz.UTC)
is_operating = is_spei_operating_time(now)
print(f"SPEI is {'operating' if is_operating else 'not operating'} right now")

See also