> ## Documentation Index
> Fetch the complete documentation index at: https://docs.countrystatecity.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Parse Phone Number

> Parse an E.164 phone number into its country and national parts

Given a phone number in E.164 format (`+` followed by country code and national digits), identify the originating country and split out the national portion.

The matcher walks 3-digit → 2-digit → 1-digit ITU prefixes, so longer-prefix countries (like `+972` Israel) win over shorter-prefix ones that share the leading digit. For NANP `+1` numbers, the area code is matched against known territory area codes — `+1-246-555-1234` resolves to Barbados (`BB`), not the US.

> [!NOTE]
>
> **Availability:** Starter plan and above. Returns `403` on lower tiers.

> [!WARNING]
>
> **The response echoes the phone number** (`e164` and `national_number`), so it's PII. The endpoint returns `Cache-Control: no-store` and emits no `ETag` — Cloudflare, browsers, and intermediate proxies will not retain the response. Do not change this if you're proxying through additional caching layers; the `Cache-Control` is intentional.
>
> The **internal phone-prefix index** is cached server-side for 24 hours. The `X-Parse-Index-Cache: HIT|MISS` header reports whether that internal lookup was a cache hit — it does **not** describe the response body.

```bash cURL (US number) theme={null}
curl -X GET 'https://api.countrystatecity.in/v1/phone/parse?number=%2B14155552671' \
  -H 'X-CSCAPI-KEY: YOUR_API_KEY'
```

```bash cURL (Indian number) theme={null}
curl -X GET 'https://api.countrystatecity.in/v1/phone/parse?number=%2B919876543210' \
  -H 'X-CSCAPI-KEY: YOUR_API_KEY'
```

```bash cURL (NANP territory — Barbados) theme={null}
curl -X GET 'https://api.countrystatecity.in/v1/phone/parse?number=%2B12465551234' \
  -H 'X-CSCAPI-KEY: YOUR_API_KEY'
```

```javascript JavaScript theme={null}
const number = '+14155552671';
const response = await fetch(
  `https://api.countrystatecity.in/v1/phone/parse?number=${encodeURIComponent(number)}`,
  { headers: { 'X-CSCAPI-KEY': 'YOUR_API_KEY' } }
);

const parsed = await response.json();
// { country: "US", dial_code: "+1", iso2: "US", iso3: "USA",
//   national_number: "4155552671", e164: "+14155552671" }
```

```python Python theme={null}
import requests

response = requests.get(
  'https://api.countrystatecity.in/v1/phone/parse',
  params={'number': '+919876543210'},
  headers={'X-CSCAPI-KEY': 'YOUR_API_KEY'}
)

parsed = response.json()
print(f"{parsed['country']} | {parsed['dial_code']} | national {parsed['national_number']}")
```

```json 200 - US number theme={null}
{
  "country": "US",
  "dial_code": "+1",
  "iso2": "US",
  "iso3": "USA",
  "national_number": "4155552671",
  "e164": "+14155552671"
}
```

```json 200 - NANP territory (area-code disambiguation) theme={null}
{
  "country": "BB",
  "dial_code": "+1",
  "area_code": "246",
  "iso2": "BB",
  "iso3": "BRB",
  "national_number": "2465551234",
  "e164": "+12465551234"
}
```

```json 200 - 3-digit ITU prefix wins theme={null}
{
  "country": "IL",
  "dial_code": "+972",
  "iso2": "IL",
  "iso3": "ISR",
  "national_number": "501234567",
  "e164": "+972501234567"
}
```

```json 400 - Missing param theme={null}
{
  "status": "error",
  "message": "Missing required query parameter: number"
}
```

```json 400 - No leading + theme={null}
{
  "status": "error",
  "message": "Phone number must be in E.164 format starting with + (e.g., +14155552671)."
}
```

```json 400 - Wrong digit count theme={null}
{
  "status": "error",
  "message": "Invalid phone number. Must contain 5-15 digits after the +."
}
```

```json 403 - Feature Restricted theme={null}
{
  "status": "error",
  "message": "This feature is not available on your current plan.",
  "details": {
    "feature": "phoneDialCode",
    "currentTier": "community",
    "requiredTier": "starter",
    "upgradeUrl": "https://app.countrystatecity.in/pricing"
  }
}
```

```json 404 - No matching country theme={null}
{
  "status": "error",
  "message": "Could not identify a country for the given phone number."
}
```

## Notes on Matching

The matcher tries 3-digit, then 2-digit, then 1-digit ITU prefixes:

* `+972...` matches Israel (3-digit prefix), not Yemen (`+967`) or any 1-digit `+9` country (none exist, but the logic generalizes).
* `+44...` matches the UK (2-digit prefix).
* `+1...` is the NANP — the next 3 digits are checked against known area codes (Barbados `246`, Antigua `268`, etc.). If no area code matches, the request falls back to the US.

When the data carries a `+1-XXX` area-code prefix for a country, the matcher prefers that more-specific entry over the bare `+1`.

## Related Endpoints

* [Get Dial Code by Country](https://docs.countrystatecity.in/api/endpoints/get-dial-code-by-country.md) — when you already know the country
* [List Dial Codes](https://docs.countrystatecity.in/api/endpoints/list-dial-codes.md) — every country plus reverse lookup


## OpenAPI

````yaml GET /phone/parse
openapi: 3.0.3
info:
  title: Country State City API
  description: >-
    Geographic data API providing countries, states, cities, timezones,
    currencies, and phone dial codes with tiered access levels.


    ## Authentication

    All endpoints require an API key passed via the `X-CSCAPI-KEY` header. Get
    your free key at [app.countrystatecity.in](https://app.countrystatecity.in).


    ## Pricing & Limits

    The fields returned, endpoints available, and request quotas depend on your
    plan. See current tiers and limits at:


    **[countrystatecity.in/pricing](https://countrystatecity.in/pricing)**


    ## Data Access Levels

    Each plan includes a data access level that controls which fields are
    returned:


    - **Basic** — Core fields: id, name, iso2, iso3, phonecode, capital,
    currency, coordinates, region, timezones, emoji

    - **Coordinates** — Basic + extended metadata (population, tld, nationality,
    currency details, postal codes, etc.)

    - **Full** — All fields including translations (18+ languages) and
    wikiDataId


    Fields restricted to higher tiers are marked in each schema below.


    ## Feature Gating

    Some endpoints require a minimum tier. Restricted endpoints return `403`
    with an `upgradeUrl` when accessed on a lower plan. Check the [pricing
    page](https://countrystatecity.in/pricing) for current feature availability.


    ## Rate Limiting

    Requests exceeding your daily or monthly quota receive a `429` response with
    your current limit, period, tier, and an upgrade URL.


    ## Caching

    Cacheable geographic responses include `Cache-Control`, `ETag`, and
    `X-Cache` (HIT/MISS) headers; send `If-None-Match` on them to receive `304
    Not Modified`. Phone number parsing is never cached (`Cache-Control:
    no-store`, no `ETag`); see each endpoint for exceptions.


    ## Usage Headers

    All `/v1/*` responses include usage and plan headers:

    - `X-CSC-Plan` — your current tier

    - `X-CSC-Daily-Used` / `X-CSC-Daily-Limit` — today's usage vs limit

    - `X-CSC-Monthly-Used` / `X-CSC-Monthly-Limit` — this month's usage vs limit


    Use these to monitor consumption without a separate API call.
  contact:
    name: Darshan Gada (dr5hn)
    email: gadadarshan@gmail.com
    url: https://countrystatecity.in
  license:
    name: Creative Commons Attribution 4.0
    url: https://creativecommons.org/licenses/by/4.0/
  version: 2.4.1
servers:
  - url: https://api.countrystatecity.in/v1
    description: Production API
security: []
tags:
  - name: Countries
    description: Country data — 250+ countries with metadata, coordinates, and translations
  - name: States
    description: State/province/region data — 5,000+ subdivisions
  - name: Cities
    description: City data — 150,000+ cities worldwide
  - name: Postcodes
    description: >-
      Postcode and ZIP code lookup and search. Informational data, not address
      verification.
  - name: Regions
    description: Geographic regions and subregions — continental groupings of countries
  - name: Timezones
    description: >-
      IANA timezone lookup by country, state, or city — includes UTC offset and
      DST status
  - name: Currencies
    description: ISO 4217 currency data — list all currencies or look up by country
  - name: Phone
    description: >-
      International dial codes — list, lookup by country, and E.164 phone number
      parsing
  - name: ISO
    description: >-
      ISO 3166 code lookup and conversion — country (alpha-2/3/numeric) and
      state (ISO 3166-2)
  - name: Search
    description: Typo-tolerant fuzzy search across cities, states, and countries
  - name: Changes
    description: >-
      Data change feed — track additions, removals, and updates to place records
      over time. **Professional and Business plans only.**
  - name: Meta
    description: Information about the dataset release currently served
paths:
  /phone/parse:
    get:
      tags:
        - Phone
      summary: Parse phone number
      description: >-
        Parses an E.164-formatted phone number to identify the originating
        country and extract the national number. Uses a hierarchical prefix
        system; for NANP (`+1`) numbers, performs area-code matching to
        distinguish territories.


        **Note:** The response echoes the phone number (`e164`) which is PII.
        This endpoint returns `Cache-Control: no-store` and no `ETag` header to
        prevent caching.


        **Availability:** Starter+ plan required.
      operationId: parsePhoneNumber
      parameters:
        - name: number
          in: query
          description: >-
            E.164-formatted phone number — `+` followed by 5–15 digits (e.g.,
            `+14155552671`)
          required: true
          schema:
            type: string
            example: '+14155552671'
      responses:
        '200':
          description: Parsed phone number with country identification
          headers:
            X-CSC-Plan:
              $ref: '#/components/headers/XCSCPlan'
            X-CSC-Daily-Used:
              $ref: '#/components/headers/XCSCDailyUsed'
            X-CSC-Daily-Limit:
              $ref: '#/components/headers/XCSCDailyLimit'
            X-CSC-Monthly-Used:
              $ref: '#/components/headers/XCSCMonthlyUsed'
            X-CSC-Monthly-Limit:
              $ref: '#/components/headers/XCSCMonthlyLimit'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneParsed'
        '400':
          description: Invalid E.164 format (missing `+`, wrong digit count)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatusError'
              example:
                status: error
                message: >-
                  Phone number must be in E.164 format starting with + (e.g.,
                  +14155552671).
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/FeatureRestricted'
        '404':
          description: No country matches the number
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatusError'
              example:
                status: error
                message: Could not identify a country for the given phone number.
        '429':
          $ref: '#/components/responses/RateLimited'
      security:
        - ApiKeyAuth: []
components:
  headers:
    XCSCPlan:
      description: Your current pricing tier
      schema:
        type: string
        enum:
          - community
          - starter
          - supporter
          - professional
          - business
          - legacy
          - custom
        example: supporter
    XCSCDailyUsed:
      description: Number of requests used today
      schema:
        type: integer
        example: 42
    XCSCDailyLimit:
      description: Your daily request limit (or 'unlimited' for custom plans)
      schema:
        type: string
        example: '1000'
    XCSCMonthlyUsed:
      description: Number of requests used this month
      schema:
        type: integer
        example: 850
    XCSCMonthlyLimit:
      description: Your monthly request limit (or 'unlimited' for custom plans)
      schema:
        type: string
        example: '30000'
  schemas:
    PhoneParsed:
      type: object
      description: >-
        Result of parsing an E.164 phone number. Contains PII (the echoed phone
        number) — the endpoint returns `Cache-Control: no-store`.
      properties:
        country:
          type: string
          description: ISO 3166-1 alpha-2 code of the originating country
          example: US
        dial_code:
          type: string
          description: Country dial code with `+` prefix
          example: '+1'
        iso2:
          type: string
          description: ISO 3166-1 alpha-2 code
          example: US
        iso3:
          type: string
          description: ISO 3166-1 alpha-3 code
          example: USA
        national_number:
          type: string
          description: Digits after removing the country code
          example: '4155552671'
        e164:
          type: string
          description: Normalized input echoed back
          example: '+14155552671'
        area_code:
          type: string
          nullable: true
          description: Area code for NANP territories only
          example: null
      required:
        - country
        - dial_code
        - iso2
        - iso3
        - national_number
        - e164
    StatusError:
      type: object
      description: Error envelope used by the postcode and meta endpoints.
      properties:
        status:
          type: string
          example: error
        message:
          type: string
        details:
          type: object
          nullable: true
          properties:
            reason:
              type: string
              description: >-
                Machine-readable reason. Check this instead of parsing
                `message`.
          additionalProperties: true
      required:
        - status
        - message
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
      required:
        - error
    FeatureError:
      type: object
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          example: This feature is not available on your current plan.
        details:
          type: object
          properties:
            feature:
              type: string
              description: The feature flag that was denied
              example: bulkStates
            currentTier:
              type: string
              example: community
            requiredTier:
              type: string
              nullable: true
              description: >-
                Lowest plan that unlocks the feature; null when it cannot be
                determined
              example: starter
            upgradeUrl:
              type: string
              format: uri
              example: https://countrystatecity.in/pricing
          required:
            - feature
            - currentTier
            - requiredTier
            - upgradeUrl
      required:
        - status
        - message
        - details
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: >-
            Daily usage limit exceeded. Please try again tomorrow or contact
            support for higher limits.
        limit:
          type: integer
          description: Your plan's limit for the exceeded period
          example: 100
        period:
          type: string
          enum:
            - daily
            - monthly
          example: daily
        tier:
          type: string
          description: Your current tier
          example: community
        upgradeUrl:
          type: string
          description: URL to upgrade your plan
          example: https://countrystatecity.in/pricing
      required:
        - error
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Unauthorized. You shouldn't be here.
    FeatureRestricted:
      description: >-
        Feature not available on your current plan. Upgrade to access this
        endpoint. `details.feature` names the denied feature and
        `details.requiredTier` the lowest plan that includes it (the example is
        for `/states`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/FeatureError'
          example:
            status: error
            message: This feature is not available on your current plan.
            details:
              feature: bulkStates
              currentTier: community
              requiredTier: starter
              upgradeUrl: https://countrystatecity.in/pricing
    RateLimited:
      description: Daily or monthly usage limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
          example:
            error: >-
              Daily usage limit exceeded. Please try again tomorrow or contact
              support for higher limits.
            limit: 100
            period: daily
            tier: community
            upgradeUrl: https://countrystatecity.in/pricing
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: >-
        API key for authentication. Get your free key at
        [app.countrystatecity.in](https://app.countrystatecity.in).
      name: X-CSCAPI-KEY
      in: header

````

## Related topics

- [List Dial Codes](https://docs.countrystatecity.in/api/endpoints/list-dial-codes.md)
- [Get Dial Code by Country](https://docs.countrystatecity.in/api/endpoints/get-dial-code-by-country.md)
- [Errors & Rate Limits](https://docs.countrystatecity.in/api/errors.md)
- [Changelog](https://docs.countrystatecity.in/changelog.md)
- [Export Formats](https://docs.countrystatecity.in/tools/export-tool/formats.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.