# Phone Intelligence (`phone.intelligence`)

Validates a phone number and returns its E.164, national and international formats, country, calling code and line type.

Docs: https://primaryapi.com/docs/api-reference/phone/intelligence

- Endpoint: `POST https://api.primaryapi.com/v1/run/phone.intelligence`
- Category: Validation · Platform: `phone` · Kind: validation · Status: live
- Price: 1 credit per call. Every call costs the same, including calls that were retried automatically.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=phone.intelligence`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `phone_number` | string | yes |  | max 32 chars | Phone number in E.164 (+14155552671) or national format together with `country`. |
| `country` | string | no |  | exactly 2 chars | ISO 3166-1 alpha-2 default region used to parse a national-format phone_number, for example "us". Not needed for E.164. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `phoneNumber` | string | E.164 form. |
| `valid` | boolean | The number is in an assignable range of its numbering plan. |
| `countryCode` | string \| null | ISO 3166-1 alpha-2 country of the number. |
| `callingCode` | string \| null | Country calling code, for example "1". |
| `nationalFormat` | string \| null |  |
| `internationalFormat` | string \| null |  |
| `region` | string \| null | State, province or area when the source knows it. |
| `timezones` | string[] | IANA time zones when the source knows them. |
| `lineType` | enum |  |
| `carrier` | object \| null | Current (portability-aware) carrier; null when the serving source cannot tell. |
| `carrier.name` | string \| null |  |
| `carrier.type` | string \| null |  |
| `carrier.mcc` | string \| null |  |
| `carrier.mnc` | string \| null |  |
| `carrier.ocn` | string \| null |  |
| `carrier.lrn` | string \| null |  |
| `ported` | boolean \| null | null when the serving source cannot tell. |
| `numberStatus` | enum | "valid"/"invalid" = numbering-plan check only; "active"/"inactive" come from live carrier sources. |
| `reachable` | boolean \| null | Handset reachability; only HLR-grade sources fill it. |
| `coverage` | enum | What kind of data answered: live US/CA carrier data, static international data, or offline numbering-plan metadata. |
| `source` | string | Identifier of the data source that answered. |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/phone.intelligence" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phone_number":"+14155552671"}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "phoneNumber": "string",
      "valid": true,
      "countryCode": "string",
      "callingCode": "string",
      "nationalFormat": "string",
      "internationalFormat": "string",
      "region": "string",
      "timezones": [
        "string"
      ],
      "lineType": "mobile",
      "carrier": {
        "name": "string",
        "type": "string",
        "mcc": "string",
        "mnc": "string",
        "ocn": "string",
        "lrn": "string"
      },
      "ported": true,
      "numberStatus": "active",
      "reachable": true,
      "coverage": "live-nanp",
      "source": "string"
    }
  },
  "provider": "PrimaryAPI",
  "credits": 1,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z"
}
```

## Pricing and reliability

- Usual price: 1 credit per call
- Price ceiling: the usual price, even when a call is retried. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=phone.intelligence`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Currently answered from numbering-plan metadata (coverage "offline"): carrier, porting and reachability are null. An invalid number is still a result (valid=false); unparseable input is rejected with HTTP 400 and no charge.

