Actions4
Get Country
AI-generatedSummary
Extract the ISO 3166-1 alpha-2 country code and country calling code from a given phone number.
Inputs
- Phone Number (required) — The phone number to process, including the international prefix (e.g. +40).
- Default Country — ISO 3166-1 alpha-2 country code to assume when the phone number lacks an international prefix.
- Options — Settings including 'Continue On Invalid' to return a result with isValid=false instead of throwing an error if parsing fails.
Output shape
A single JSON object per input item containing 'input' (the original phone number), 'country' (the ISO alpha-2 country code or null if undetermined), and 'countryCallingCode' (the country calling code prefixed with '+').
If the phone number cannot be parsed and 'Continue On Invalid' is false, the node throws an error; if true, the output contains isValid=false with an error message. The operation handles multiple input items independently.
Examples
Example 1: Extract country code from fully international phone number
Phone Number set to '+40215700000', Default Country left empty, Continue On Invalid false or omitted, returns country 'RO' and countryCallingCode '+40'.
Example 2: Extract country code from a national (non-international) phone number
Phone Number set to '0215700000', Default Country set to 'RO', Continue On Invalid false or omitted, returns country 'RO' and countryCallingCode '+40'.