# Validate phone number

`POST https://api.foxentry.com/phone/validate`

Foxentry allows you to check validity and the existence of phone numbers. It can also give you additional information about the validated phone number based on the validationType option. Please pay attention to the formatNumber option. This option defines the format of number that should be considered as valid. Foxentry validator is able not only to evaluate the validity of the entered information but it also can fix various typos, errors and missing data. Foxentry can also suggest more suitable alternatives to the data sent in query. Please pay attention to the result, resultCorrected and suggestions in the response. Always check result.proposal in the response for a proposed solution by Foxentry how you should process the response in your form or application.

## Headers

| Header | Value |
|---|---|
| `Api-Version` | `2.1` or `2.0` |
| `Authorization` | `Bearer <your API key>` |
| `Content-Type` | `application/json` |

## Request body

### request.query

Parameters you want to validate or search for.

| Field | Type | Description |
|---|---|---|
| `prefix` | string | Phone number prefix. |
| `number` | string | Phone number. |
| `numberFull` | string | Phone number with prefix. |

### request.options

Options that change how the endpoint behaves.

| Field | Type | Description |
|---|---|---|
| `validationType` | string | Type of validation. One of: `basic`, `extended`. Default: `"basic"`. |
| `allowedPrefixes` | array[string] | List of allowed prefixes. |
| `preferredPrefixes` | array[string] | Ordered list of preferred prefixes. If phone number is valid with multiple prefixes, the resultCorrected will use the first valid prefix from this list. If not set, the resultCorrected will be null and there will be all valid combinations in the suggestions. |
| `numberFormat` | string | Determines the format of the phone number output. raw = number as entered, national = national format without prefix (607 123 456), e123 = international format with spaces (+420 607 123 456), e164 = international format without spaces (+420607123456). One of: `raw`, `national`, `e123`, `e164`. Default: `"e164"`. |
| `correctionMode` | string | This option determines how automatic corrections are handled. You can choose between full to allow all corrections, format to fix formatting only, suggestion to return corrected data in suggestions, or none for no corrections to be applied. One of: `full`, `format`, `suggestion`, `none`. Default: `"full"`. |

### request.client

Information about your user, to make results more relevant.

| Field | Type | Description |
|---|---|---|
| `ip` | string | IP address of your end user (IPv4 or IPv6). Used for geolocation to make results — for example for the search endpoints — more relevant to the user's location. If you have the user's GPS coordinates, prefer sending those via location, as an IP address may be less precise. |
| `country` | string | Country code in ISO-3166-1 alpha-2 format. |
| `location.lat` | number | Client's latitude |
| `location.lon` | number | Client's longitude |

### Example

```json
{
  "request": {
    "query": {
      "numberFull": "+420775111222"
    },
    "options": {
      "validationType": "extended",
      "allowedPrefixes": [
        "+420",
        "+421"
      ],
      "numberFormat": "e164"
    },
    "client": {
      "country": "CZ",
      "location": {
        "lat": 50.0628,
        "lon": 13.9271
      }
    }
  }
}
```

## Responses

- `200` Successful response. Examples: `valid`, `invalid`, `invalidWithCorrection`, `validWithSuggestion`
- `400` Bad Request
- `401` Unauthorized
- `402` Payment Required
- `403` Forbidden
- `404` Not Found
- `405` Method Not Allowed
- `429` Too Many Requests
- `500` Internal Server Error
- `503` Service Unavailable
