Best Practice
Best Practices for Using the Phone Call API
Use Proper Phone Number Formatting
When interacting with the Phone Call API, it is critical to ensure all phone numbers are formatted correctly to avoid issues with international calls or number recognition. Follow these guidelines:
Always Prefix Phone Numbers with the Country Code
Ensure that every phone number passed to the API includes the country code, even for local calls. The phone number should be in the E.164 format, which is the international standard for phone number representation.
Example: Convert (123) 456-7890
to +11234567890
In this format:
+1 is the country code for the United States.
There should be no parentheses, spaces, or dashes—only the + symbol followed by the country code and the number.
Benefits:
This ensures compatibility with international phone systems.
It helps prevent ambiguity in regional number formats.
Using Zapier to Format Phone Numbers
If you are automating workflows with Zapier, you can use a "Code by Zapier" block to clean and format phone numbers before passing them to the API. Below is a Python script that can be used to accomplish this:
valid_digits = '0123456789'
digit_str = ''
phone_number = input_data['phoneNumber']
for char in phone_number:
# Only collect characters that are digits
if char in valid_digits:
digit_str += char
# Ensure the digit string is valid length for a US number
if len(digit_str) == 10:
# Add country code "+1" to the number
digit_str = f'+1{digit_str}'
return {'phoneNumber': digit_str}
Explanation:
This code extracts all valid digits from the input phone number.
If the phone number has ten digits, it adds the +1 prefix to indicate it is a U.S. number.
The cleaned number is then in the correct E.164 format, ready to be passed to the API.
Updated about 1 month ago