sms compliance
sms compliance
Portugal Phone Numbers: Format, Area Code & Validation Guide
Complete guide to Portuguese phone number formats, validation, and implementation. Learn E.164 formatting, area codes, mobile prefixes, and best practices for handling Portugal's 9-digit numbering system.
Portugal Phone Numbers: Format, Area Code & Validation Guide
Introduction
Building an application that interacts with Portuguese phone numbers? Understanding Portugal's country code (+351) and 9-digit phone number format is essential for accurate validation and international calling. Accurate handling prevents failed deliveries, billing errors, and compliance violations – whether you're validating user input for an e-commerce checkout, implementing SMS-based two-factor authentication, routing customer support calls, or preventing fraudulent transactions. This guide provides the technical specifications, practical guidance, and best practices you need to confidently navigate the Portuguese telephone numbering system.
Quick Facts About Portugal Phone Numbers
Establish these fundamental facts about Portuguese phone numbers:
- Country: Portugal
- Country Code: +351
- International Prefix (from Portugal): 00
- National Prefix: None (removed on 31 October 1999 for a closed numbering plan)
- Regulatory Authority: ANACOM (Autoridade Nacional de Comunicações) – https://www.anacom.pt/
- Emergency Number: 112 (European standard emergency number, free from any phone)
- Health Line: 808 24 24 24 (SNS 24 – non-emergency health advice, 24/7)
- Time Zone: WET (UTC+0) / WEST (UTC+1 during daylight saving, last Sunday March to last October)
- Calling Hours: Automated calls should respect 9 AM–9 PM local time to comply with consumer protection regulations
This shift to a closed numbering plan on 31 October 1999 simplified the system – all calls within Portugal now require 9 digits, regardless of whether they're local or long-distance.
Portuguese Phone Number Structure
Portugal adheres to the ITU-T E.164 recommendation, ensuring international compatibility. ANACOM, the national regulatory body, enforces strict compliance with this standard. All Portuguese subscriber numbers follow a consistent 9-digit structure:
Format Breakdown:
┌─────────────────────────────────────────────────┐
│ +351 │ 2X │ XXX XXXX │
│ Country │ Area │ Subscriber │
│ Code │ Code │ Number │
└─────────────────────────────────────────────────┘
Example (Lisbon): +351 21 123 4567
Example (Mobile): +351 91 234 5678
Each component:
- Country Code (+351): Identifies Portugal in international calls. Handle both the "+" and "00" prefixes (e.g., +351 and 00351) for maximum flexibility.
- Area/Service Code (2/9/8/6): The first digit of this two-digit code categorizes the number type (geographic, mobile, or special service).
- Subscriber Number (XXXXXXX): The unique 7-digit identifier within the given area or service code.
Portuguese Phone Number Categories and Implementation Guidelines
Understand the different categories of Portuguese phone numbers for accurate validation and processing:
1. Portugal Landline Numbers (Geographic Numbers)
- Format:
2X XXXXXXX - Area Code Distribution:
- 21: Lisbon metropolitan area (Lisboa)
- 22: Porto metropolitan area
- 23: Regions including Aveiro, Coimbra, Viseu
- 24–29: Other regions across Portugal
- Implementation Note: Validate area codes against the most current ANACOM allocation tables. Hardcoding these values can lead to errors as allocations change.
2. Portugal Mobile Numbers
- Format:
9X XXXXXXX - Operator Prefixes (Historically):
- 91: Vodafone Portugal
- 92, 96: MEO (formerly TMN)
- 93: NOS (formerly Optimus)
- MVNO Operators: Portugal has a growing MVNO market including Lycamobile, NOWO, and others using the same prefix ranges as their host networks
- Best Practice: Due to number portability (implemented nationwide since January 2002 for mobile numbers), implement a portability check before making assumptions about the current operator. These prefixes indicate the original operator only, not necessarily the current one – crucial for accurate routing and billing.
3. Special Services
- Toll-Free:
800 XXXXXX– Free for the caller - Shared Cost:
808 XXXXXX– Cost split between caller and recipient (capped at €0.10/minute from fixed lines per ANACOM regulations) - Premium Rate:
607 XXXXXX– Higher calling rates up to €3.28/minute plus VAT for value-added services - Standard Rate:
707 XXXXXX,708 XXXXXX– Entertainment and business services (€0.25 + VAT/minute, capped by ANACOM) - VoIP Carriers:
30X XXXXXX– Voice over IP service providers - Personal Numbering:
884 XXXXXX– Follow-me services that redirect to multiple numbers - Carrier Selection:
10XX– Codes for selecting specific carriers for calls - Warning: When handling premium-rate numbers, provide clear notifications to users about potential charges (display the per-minute rate) and obtain explicit consent before initiating calls. Portuguese consumer protection laws require this.
Consult ANACOM's documentation for a complete list of special number ranges and their current allocations.
How to Validate Portuguese Phone Numbers
Implement robust Portuguese phone number validation using regular expressions:
const portugalPhoneValidation = {
// Geographic (Landline)
landline: /^2\d{8}$/,
// Mobile
mobile: /^9[1236]\d{7}$/,
// Special Services (Partial – consult ANACOM for full list)
tollFree: /^800\d{6}$/,
sharedCost: /^808\d{6}$/,
premium: /^6[046]\d{5}$/,
// Full validation with optional country code (handles +351 and 00351)
international: /^(?:\+351|00351)?[269]\d{8}$/
};
// Usage Example
function validatePortugueseNumber(number, type = 'any') {
// Clean the number (remove whitespace and other non-digit characters)
const cleaned = number.replace(/\D/g, '');
if (type === 'any') {
return Object.values(portugalPhoneValidation).some(regex => regex.test(cleaned));
}
return portugalPhoneValidation[type]?.test(cleaned) || false;
}
// Example Test Cases
console.log(validatePortugueseNumber('+351912345678', 'mobile')); // true
console.log(validatePortugueseNumber('21 123 45 67', 'landline')); // true
console.log(validatePortugueseNumber('00351211234567')); // true
console.log(validatePortugueseNumber('12345')); // falsePython Validation Example:
import re
class PortugalPhoneValidator:
PATTERNS = {
'landline': r'^2\d{8}$',
'mobile': r'^9[1236]\d{7}$',
'toll_free': r'^800\d{6}$',
'shared_cost': r'^808\d{6}$',
'premium': r'^6[046]\d{5}$',
'international': r'^(?:\+351|00351)?[269]\d{8}$'
}
@classmethod
def validate(cls, number, number_type='any'):
# Clean the number
cleaned = re.sub(r'\D', '', number)
if number_type == 'any':
return any(re.match(pattern, cleaned) for pattern in cls.PATTERNS.values())
pattern = cls.PATTERNS.get(number_type)
return bool(re.match(pattern, cleaned)) if pattern else False
# Test cases
print(PortugalPhoneValidator.validate('+351912345678', 'mobile')) # True
print(PortugalPhoneValidator.validate('21 123 45 67', 'landline')) # TrueTest your validation logic thoroughly with valid and invalid inputs, including edge cases.
Portugal Phone Number Implementation Best Practices
Beyond basic validation, implement these best practices for Portuguese phone numbers:
1. How to Store Portuguese Phone Numbers
Store Portuguese phone numbers in E.164 format (+351XXXXXXXXX). This ensures consistency and simplifies international interactions.
Database Schema Recommendations:
CREATE TABLE contacts (
id SERIAL PRIMARY KEY,
phone_e164 VARCHAR(15) NOT NULL, -- E.164 format: +351XXXXXXXXX
phone_display VARCHAR(20), -- Formatted for display: 21 123 4567
phone_country_code VARCHAR(3) DEFAULT '351',
phone_type VARCHAR(20), -- 'mobile', 'landline', 'toll_free', etc.
is_verified BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT NOW(),
INDEX idx_phone_e164 (phone_e164),
INDEX idx_phone_type (phone_type)
);// Format to E.164
const formatToE164 = (number) => {
const cleaned = number.replace(/\D/g, '');
return cleaned.startsWith('351') ? `+${cleaned}` : `+351${cleaned}`;
};This function handles cases where the user inputs the country code or not.
2. How to Format Portuguese Phone Numbers for Display
Format Portuguese phone numbers for display according to local conventions (XX XXX XXXX) to improve readability.
const formatForDisplay = (number) => {
// Remove country code and format
const local = number.replace(/^\+351/, '');
return local.replace(/(\d{2})(\d{3})(\d{3,4})/, '$1 $2 $3'); // Handles 5 or 6 digit subscriber numbers for special services
};This formatting function correctly handles the varying lengths of subscriber numbers for different service types.
3. Portugal Number Portability Handling
Portugal's number portability allows users to keep their number when switching operators (implemented January 2002 for mobile, June 2001 for fixed). ANACOM Regulation No. 38/2025 (effective November 2025) establishes:
- Portability must complete within one working day from the agreed date
- No direct charges to end-users for portability (prohibited by regulation)
- Wholesale cost between operators capped at €1 per ported number
- 3-month quarantine period for numbers after contract termination
- Portability Validation Code (PVC) required for all portability requests
Important: ANACOM does not provide a public API for real-time portability lookups. Operators exchange portability data through the Reference Entity system. For accurate operator routing:
class PortabilityCheck {
async checkOperator(number) {
// Note: ANACOM's portability database is not publicly accessible
// Implementation requires:
// 1. Commercial agreement with a telecommunications operator
// 2. Access to operator's portability lookup service
// 3. Integration with Reference Database (RDB) via operator intermediary
try {
const operatorInfo = await this.queryOperatorDatabase(number);
return {
currentOperator: operatorInfo.operator,
originalOperator: this.getOriginalOperator(number),
lastPortedDate: operatorInfo.portedDate,
isPorted: operatorInfo.isPorted
};
} catch (error) {
console.error("Error checking portability:", error);
// Fallback to prefix-based identification (less reliable)
return {
currentOperator: 'Unknown',
originalOperator: this.getOriginalOperator(number),
note: 'Prefix-based identification only – may be inaccurate due to portability'
};
}
}
// This function is less reliable due to portability but can still provide a hint
getOriginalOperator(number) {
const prefix = number.substring(4, 6); // Extract prefix after +351
const operators = {
'91': 'Vodafone',
'92': 'MEO',
'93': 'NOS',
'96': 'MEO'
};
return operators[prefix] || 'Unknown';
}
// Implement caching to reduce API calls
async queryOperatorDatabase(number) {
// Check cache first (TTL: 24 hours recommended)
const cached = await this.getCachedOperator(number);
if (cached && !this.isCacheExpired(cached)) {
return cached.data;
}
// Query operator lookup service (requires commercial agreement)
const result = await this.performOperatorLookup(number);
await this.cacheOperator(number, result);
return result;
}
}Caching Strategy: Cache operator lookups for 24 hours to balance accuracy and performance. Portability changes take effect during scheduled windows, so hourly updates are unnecessary.
Technical Considerations for Portuguese Phone Numbers
1. Error Handling
Implement robust error handling with specific error codes for Portuguese phone number validation:
const PhoneValidationErrors = {
INVALID_FORMAT: {
code: 'PT_INVALID_FORMAT',
message: 'Your phone number is invalid. Use the format: 21 123 4567 or +351 211 234 567',
message_pt: 'Número de telefone inválido. Use o formato: 21 123 4567 ou +351 211 234 567'
},
INVALID_AREA_CODE: {
code: 'PT_INVALID_AREA_CODE',
message: 'Your area code is not recognized',
message_pt: 'Código de área não reconhecido'
},
LANDLINE_NOT_SMS_CAPABLE: {
code: 'PT_LANDLINE_SMS',
message: 'Landline numbers cannot receive SMS messages',
message_pt: 'Números fixos não podem receber SMS'
},
PREMIUM_RATE_BLOCKED: {
code: 'PT_PREMIUM_BLOCKED',
message: 'Premium rate numbers are not allowed',
message_pt: 'Números de taxa premium não são permitidos'
}
};
function validateWithErrors(number, options = {}) {
const cleaned = number.replace(/\D/g, '');
if (!/^[269]\d{8}$/.test(cleaned)) {
return { valid: false, error: PhoneValidationErrors.INVALID_FORMAT };
}
if (options.smsOnly && cleaned.startsWith('2')) {
return { valid: false, error: PhoneValidationErrors.LANDLINE_NOT_SMS_CAPABLE };
}
if (options.blockPremium && /^6[046]/.test(cleaned)) {
return { valid: false, error: PhoneValidationErrors.PREMIUM_RATE_BLOCKED };
}
return { valid: true, number: `+351${cleaned}` };
}2. International Integration
Support both +351 and 00351 prefixes for international calls. Use E.164 formatting consistently for storage and internal processing.
SMS Character Encoding for Portugal:
- GSM-7 Encoding: Standard SMS in Portugal uses GSM-7, allowing 160 characters per message
- Portuguese Characters: Portuguese uses accented characters (á, â, ã, à, ç, é, ê, í, ó, ô, õ, ú) which are supported in GSM-7
- Unicode (UCS-2): Required for emoji or non-GSM characters, reduces limit to 70 characters per message
- Concatenation: Messages exceeding limits split into segments of 153 characters (GSM-7) or 67 characters (UCS-2), with 7 characters reserved for concatenation headers
function calculateSMSSegments(message) {
const gsmCharacters = /^[\u0000-\u007F\u00A0-\u00FF]*$/;
const isGSM7 = gsmCharacters.test(message);
if (isGSM7) {
const length = message.length;
const segmentSize = length > 160 ? 153 : 160;
return {
encoding: 'GSM-7',
segments: Math.ceil(length / segmentSize),
charactersPerSegment: segmentSize,
totalCharacters: length
};
} else {
const length = message.length;
const segmentSize = length > 70 ? 67 : 70;
return {
encoding: 'UCS-2',
segments: Math.ceil(length / segmentSize),
charactersPerSegment: segmentSize,
totalCharacters: length
};
}
}3. Regulatory Compliance
GDPR and Data Protection:
Portugal implements GDPR through Law No. 58/2019 (effective August 8, 2019). Key requirements for phone number data:
- Legal Basis Required: Explicit consent, contract necessity, or legitimate interest
- Data Minimization: Collect only necessary phone data
- Retention Limits: Maximum 24 months for call recordings (distance contracts), longer if contractual obligations require
- Right to Erasure: Users can request deletion after contract termination
- Supervisory Authority: CNPD (Comissão Nacional de Proteção de Dados) – https://www.cnpd.pt/
Marketing Communications Opt-Out:
Under Portuguese law (Law No. 46/2012 of August 29) and enforced by ANACOM:
- Opt-In Required: Obtain prior express consent before sending marketing SMS/calls to individuals
- Opt-Out for Businesses: Organizations can be contacted until they explicitly opt-out
- Penalties for Violations:
- Individuals: €1,500–€25,000 fine
- Organizations: €5,000–€5,000,000 fine
- Required Elements: All marketing messages must support STOP/HELP keywords and identify the sender
- Consent Records: Maintain updated logs of all opt-in consents with timestamps
- Do-Not-Call Registry: Check Direção-Geral do Consumidor's nationwide opt-out list
// Example opt-out handling
class MarketingConsent {
async canSendMarketing(phoneNumber) {
// Check explicit opt-in consent
const hasConsent = await this.checkConsentDatabase(phoneNumber);
if (!hasConsent) return false;
// Check national do-not-call registry
const isOnDNCList = await this.checkDoNotCallRegistry(phoneNumber);
if (isOnDNCList) return false;
// Verify consent is not expired (recommend reconfirming annually)
const consentAge = await this.getConsentAge(phoneNumber);
if (consentAge > 365) return false; // days
return true;
}
async recordOptOut(phoneNumber, source) {
await this.database.insert({
phone: phoneNumber,
opted_out: true,
opt_out_date: new Date(),
source: source, // 'STOP keyword', 'web form', 'support request'
processed_by: 'system'
});
}
}Maintain up-to-date area code mappings and implement required consumer protection measures, especially for premium-rate numbers. Regularly consult ANACOM's official documentation for the latest regulations and updates.
Conclusion
You now have a comprehensive understanding of Portuguese phone number formatting, validation, and best practices. Follow this guide to build robust and reliable applications that seamlessly interact with the Portuguese telecommunications system.
Key Takeaways:
- Store numbers in E.164 format (+351XXXXXXXXX)
- Implement number portability awareness – prefix ≠ current operator
- Respect GDPR requirements and maintain opt-in consent records
- Handle SMS encoding properly (GSM-7 vs. UCS-2)
- Provide clear cost warnings for premium-rate numbers
- Respect time zones (WET/WEST) for automated communications
- Keep emergency number 112 accessible in your applications
Next Steps:
- Test validation with ANACOM's official number ranges
- Integrate operator portability checks if routing requires it
- Implement GDPR-compliant consent management
- Set up monitoring for failed deliveries and adjust validation rules
- Subscribe to ANACOM updates for regulatory changes
For the most current information and regulatory updates, refer to ANACOM's official resources at https://www.anacom.pt/.
Frequently Asked Questions (FAQ)
What is Portugal's country code for international calls?
Portugal's country code is +351. When calling Portugal from abroad, dial either +351 or 00351 followed by the 9-digit Portuguese phone number. For example, to call a Lisbon landline (21 123 4567) from outside Portugal, dial +351 211 234 567. All Portuguese numbers require the full 9 digits after the country code, with no additional trunk prefix or area code prefix needed.
How many digits are in a Portuguese phone number?
Portuguese phone numbers contain exactly 9 digits after the country code. This applies to all number types – landlines, mobile phones, toll-free numbers, and special services. The 9-digit format was standardized on 31 October 1999 when Portugal implemented a closed numbering plan, eliminating the previous trunk prefix and simplifying the system.
What area code is Lisbon, Portugal?
Lisbon uses area code 21 for landline numbers. All Lisbon landline numbers follow the format 21X XXX XXX (9 digits total). When calling within Portugal, dial the full 9-digit number starting with 21. From abroad, dial +351 21X XXX XXX. Other major cities include Porto (area code 22) and regions like Aveiro, Coimbra, and Viseu (area code 23).
How do I validate a Portuguese mobile number?
Portuguese mobile numbers start with 9 followed by specific operator prefixes: 91 (Vodafone), 92 or 96 (MEO), and 93 (NOS). Use the regular expression /^9[1236]\d{7}$/ to validate 9-digit mobile numbers. However, due to number portability (implemented since January 2002), these prefixes only indicate the original operator, not necessarily the current one. For accurate operator identification, query an operator portability database through a commercial agreement, as ANACOM does not provide public API access.
What is the E.164 format for Portuguese phone numbers?
The E.164 format for Portuguese phone numbers is +351XXXXXXXXX, where the X's represent the 9-digit local number. For example, a Lisbon landline becomes +351211234567, and a mobile number becomes +351912345678. Store phone numbers in E.164 format to ensure consistency, simplify international interactions, and maintain compatibility with telecommunications APIs and services.
Do Portuguese mobile numbers change when switching operators?
No, Portugal has implemented nationwide number portability, allowing users to keep their mobile number when switching operators (available since January 2002 for mobile, June 2001 for fixed lines). While prefixes like 91, 92, 93, and 96 originally indicated specific operators (Vodafone, MEO, NOS), these now only show the original operator, not the current one. Under ANACOM Regulation No. 38/2025, portability completes within one working day, costs €1 or less wholesale between operators, and is free for end-users.
What are the toll-free and premium rate numbers in Portugal?
Portugal uses several special service number formats: Toll-free numbers start with 800 (format: 800 XXXXXX) and are free for callers. Shared cost numbers start with 808 (format: 808 XXXXXX) where costs split between caller and recipient, capped at €0.10/minute from fixed lines. Premium rate numbers start with 607 (format: 607 XXXXXX) and charge up to €3.28/minute plus VAT for value-added services. Standard rate numbers (707, 708) are capped at €0.25 + VAT/minute. Notify users about potential charges for premium-rate numbers and obtain explicit consent before initiating such calls, as required by Portuguese consumer protection laws.
How do I format Portuguese phone numbers for display?
Format Portuguese phone numbers using the local convention XX XXX XXXX for readability. For example, display 211234567 as "21 123 4567" for landlines and 912345678 as "91 234 5678" for mobile numbers. Remove the country code (+351) for domestic display, and use spaces to separate the area/operator code (2 digits), first subscriber block (3 digits), and remaining subscriber digits (3–4 digits depending on service type).
What is the emergency number in Portugal?
Portugal uses 112 as the single European emergency number for police, fire, and ambulance services. This number is free to call from any landline or mobile phone, available 24/7. For non-emergency health advice, contact SNS 24 at 808 24 24 24 (Health Line 24). Note that calling 999 or 991 does not work in Portugal – use 112 for emergencies. Ensure the emergency number 112 is always accessible in your applications, even when the phone is locked.
What are GDPR requirements for storing Portuguese phone numbers?
Under Portuguese Law No. 58/2019 implementing GDPR, storing phone numbers requires: (1) Legal basis – explicit consent, contractual necessity, or legitimate interest; (2) Purpose limitation – clearly state why you collect phone numbers; (3) Data minimization – collect only necessary data; (4) Retention limits – maximum 24 months for call recordings, longer only if contractual obligations require; (5) Right to erasure – users can request deletion; (6) Security measures – encrypt phone data at rest and in transit. For marketing communications, obtain prior express consent before sending SMS/calls, maintain consent logs, and honor opt-out requests immediately. Violations result in fines from €1,500 to €5,000,000. The supervisory authority is CNPD (https://www.cnpd.pt/).
Can I send SMS to Portuguese landline numbers?
No, you cannot send SMS messages to Portuguese landline numbers (starting with 2). SMS delivery is only supported for mobile numbers (starting with 9). If you attempt to send an SMS to a landline via the Twilio REST API or similar services, the API returns a 400 error with code 21614, the message is not logged, and your account is not charged. Validate that the destination number is a mobile number before attempting SMS delivery.
How does SMS character encoding work for Portuguese messages?
Portuguese SMS uses GSM-7 encoding by default, supporting Portuguese accented characters (á, â, ã, à, ç, é, ê, í, ó, ô, õ, ú) and allowing 160 characters per message. If your message includes emoji or non-GSM characters, it switches to UCS-2 (Unicode) encoding, reducing the limit to 70 characters per message. For longer messages, concatenation splits them into segments: 153 characters per segment for GSM-7, or 67 characters per segment for UCS-2 (with 7 characters reserved for concatenation headers). To optimize costs and deliverability, avoid emoji in transactional messages and test character encoding before sending bulk campaigns.
Related Resources
Country Phone Number Guides:
- Spain Phone Numbers Guide
- France Phone Numbers Guide
- Italy Phone Numbers Guide
- United Kingdom Phone Numbers Guide
- Brazil Phone Numbers Guide
E.164 Format & International Standards:
- E.164 Phone Number Format Guide
- International Phone Number Formatting
- Country Codes Reference
- Phone Number Validation Best Practices
SMS & Telecommunications APIs:
- Twilio Portugal SMS Integration
- Plivo Portugal Phone Numbers
- MessageBird Portugal Setup
- Infobip Portugal SMS Guide
Regulatory & Compliance: