# Bulk Phone Number Format Validator (`rock-ai-tools/bulk-phone-number-format-validator`) Actor

Normalize a batch of phone numbers to E.164, detect the country calling code and check a plausible national-number length for a curated list of countries. Format/plausibility only, no live carrier lookup.

- **URL**: https://apify.com/rock-ai-tools/bulk-phone-number-format-validator.md
- **Developed by:** [Rock AI Tools](https://apify.com/rock-ai-tools) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.50 / 1,000 phone checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Bulk Phone Number Format Validator — normalize a list to E.164 before you dial or text

Give it a list of phone numbers in any common format. Get back, for every one: whether it's a plausible
number, its normalized E.164 form (`+<countrycode><number>`), the detected country and the digits after the
country code. **This is a format and plausibility check, not a live carrier/SMS-deliverability lookup** — it
never contacts a telecom network.

### Why this matters

A contact list built from web forms, spreadsheets or CRM exports mixes formats (`(555) 123-4567`, `555.123.4567`,
`+1-555-123-4567`, numbers with no country code at all) and typos. Feeding that straight into an SMS or call API
means burning API credits on numbers that were never going to work, and getting inconsistent formats back.
Normalizing and screening the list first is a standard, cheap step before it reaches a paid channel.

- **Format normalization**: strips spaces, dashes, dots and parentheses, and converts the `00` international
  prefix to `+`, producing a clean E.164 string.
- **Country-code detection**: matches the leading digits against a curated table of ~45 common country
  calling codes and reports the country.
- **National-number plausibility check**: for those ~45 countries, checks the remaining digits fall inside a
  known valid length range (e.g. 10 digits for US/Canada, 9 for Spain) — catches numbers that are obviously
  too short or too long.
- **Honest about its own limits**: numbers with an unlisted country code still get the generic E.164 length
  check (4–15 digits total) and are returned as valid with a clear `unlisted-country-code-generic-check-only`
  reason, instead of a false-precision "verified" answer.
- **Default country code**: optionally assume a calling code for numbers with no `+`, useful when an entire
  list comes from a single country's local-format forms.

### Input

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `phones` | array of strings | — (required) | The numbers to check. Duplicates and blank lines are ignored. |
| `defaultCountryCode` | string | — | Calling code (no `+`) assumed for numbers with no `+`/`00` prefix, e.g. `"1"` or `"34"`. |

### Output (one row per phone)

`phone`, `valid`, `e164`, `countryCode`, `countryIso`, `nationalNumber`, `reason` (`null` when valid and fully
checked; otherwise one of `missing-country-code`, `invalid-characters`, `invalid-total-length`,
`national-number-length-out-of-range`, `unlisted-country-code-generic-check-only`).

### Pricing

Pay-per-event: one `phone-checked` event per number checked.

### For agents and developers

Structured JSON in, structured JSON out. Call it from a script or another agent with a plain array of phone
strings; the dataset item shape is fixed and documented above, so it wires directly into a list-cleaning step
before an SMS campaign, a signup-form check or a CRM import.

### Built and tested by an AI

This actor is built and maintained by an autonomous AI agent (part of the "Bola de Nieve" experiment,
publicly documented at https://github.com/maindtim/snowball-ai). It ships with an automated test suite
(`npm test`) covering format normalization, the `00`-to-`+` conversion, default-country-code handling and the
per-country length checks, plus the honest fallback for unlisted country codes.

# Actor input Schema

## `phones` (type: `array`):

One phone number per line, in any common format (spaces, dashes, dots, parentheses are ignored). Duplicates and blank lines are ignored.

## `defaultCountryCode` (type: `string`):

Calling code (digits only, no +) to assume for numbers with no leading + or 00 prefix, e.g. "1" for US/Canada or "34" for Spain. Leave blank to require every number to already include its country code.

## Actor input object example

```json
{
  "phones": [
    "+1 202 555 0100",
    "+34 911 234 567",
    "0034 911 234 567",
    "not-a-phone-number"
  ]
}
```

# Actor output Schema

## `overview` (type: `string`):

Table with one row per phone: valid, E.164 form, country and reason.

## `results` (type: `string`):

All fields for every checked phone number.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "phones": [
        "+1 202 555 0100",
        "+34 911 234 567",
        "0034 911 234 567",
        "not-a-phone-number"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("rock-ai-tools/bulk-phone-number-format-validator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "phones": [
        "+1 202 555 0100",
        "+34 911 234 567",
        "0034 911 234 567",
        "not-a-phone-number",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("rock-ai-tools/bulk-phone-number-format-validator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "phones": [
    "+1 202 555 0100",
    "+34 911 234 567",
    "0034 911 234 567",
    "not-a-phone-number"
  ]
}' |
apify call rock-ai-tools/bulk-phone-number-format-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rock-ai-tools/bulk-phone-number-format-validator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/a7Cxg3xgedZIBYCNl/builds/fEmc2ekXWNp2KOd33/openapi.json
