> Toden documentation. For the full index fetch /llms.txt. Every page is available as Markdown by appending .md to its URL. Every endpoint is under /api/v1. Identity verification and Risk Intelligence are separate contracts there with different error shapes; /api/kyc and /api/identity are older prefixes that still answer the same. Never invent an endpoint, field or enum value: read the API reference page for the operation first.

# Check a phone number

POST https://sandbox-api.toden.co/api/v1/checks/phone
Content-Type: application/json

Scores a phone number for risk with no code sent to it: whether it is a real number, which country it belongs to, what kind of line it is, and whether other people in your organisation already used it.

Send the number with its country code, or send a local number with `country`, the two-letter code of the country it is dialled in.

The outcome follows the score: `low` is `pass`, `medium` is `review` and `high` is `fail`. A number that is not valid always fails. A VoIP or "follow me" number goes to review on its own; a premium rate number fails.

The check runs on Toden's own data and is never sent to a lookup provider. Outside production it runs for real and is not charged.

Charged per check at your price (production only); a check that could not be completed is not charged. Send a `requestId`: a retry with the same value returns the same check with `replayed: true`, without running or charging again.

**Error codes**

| `error` | Status | Meaning |
|---|---|---|
| `invalid_input` | 400 | The body is missing something the check needs, or the requestId is malformed. |
| `insufficient_credits` | 402 | Your balance cannot cover the check. Nothing was run or charged. |
| `checks_unavailable` | 403 | These checks are not switched on for your organisation yet. |
| `spot_checks_disabled` | 403 | Spot checks are not enabled for your organisation. |
| `request_id_reused` | 409 | The requestId was used for a different check. |
| `check_in_progress` | 409 | A check with this requestId is still running. |
| `file_not_found` | 422 | The uploaded file was not found, is not yours, or has expired. |
| `check_unavailable` | 503 | The check cannot run on this deployment right now. Nothing was charged. |
| `secret_key_required` | 403 | A publishable key was used. This endpoint accepts secret keys only. |
| `environment_mismatch` | 403 | The key belongs to an environment this deployment does not serve. |
| `ip_not_allowed` | 403 | The key has an IP allowlist and the calling address is not on it. |
| `organization_suspended` | 403 | The organisation is suspended. The response carries `reason` and `suspendedAt`. |
| `business_not_approved` | 403 | A live key was used before the business was approved for production. |

A missing or unknown key answers `401`, where `error` is a short sentence rather than a code.

Requires a secret (`sk_`) key. A publishable key receives `403 secret_key_required`.

Reference: https://docs.toden.co/api-reference/verification/standalone-checks/create-phone-check

## Authentication

- `Authorization` header (bearer token, required) — Send the API key as a Bearer token. Each operation states whether a publishable key is enough or a secret key is required. A scoped publishable key has Verification flow access, the fixed set `flow.run`, `flow.config.read` and `verifications.status.read`; a scoped secret key reaches what its scopes allow.

## Servers

- `https://sandbox-api.toden.co` (Sandbox, default)
- `https://api.toden.co` (Production)

## Request

### Body (application/json)

This endpoint expects a PhoneCheckRequest.

- `phone` (string, required) — The phone number, with its country code (`+234 803 123 4567`) or local with `country` (`0803 123 4567`). Spaces and punctuation are fine.
- `country` (string, optional) — Optional. The ISO 3166-1 alpha-2 code of the country a local number is dialled in, e.g. `NG`.
- `externalUserId` (string, optional) — Your own reference for the check (a customer or case id), kept with it and searchable in your history.
- `requestId` (string, optional) — Your idempotency key, 8 to 120 characters: a retry with the same value returns the same check.

## Response

### 200

A retry: the check already run under this requestId.

- `id` (string, required) — The check id (`chk_…`).
- `kind` (enum, required) — Which check this is.
  - Allowed values: `phone`
- `outcome` (enum, required) — `pass`: nothing of concern. `review`: something a person should look at. `fail`: a clear problem. `unavailable`: the check could not be completed, was not charged, and is never a pass.
  - Allowed values: `pass`, `review`, `fail`, `unavailable`
- `subject` (string, required) — What was checked, as your history lists it.
- `channel` (enum, required) — Whether the check was run through the API or from the dashboard.
  - Allowed values: `api`, `dashboard`
- `createdAt` (datetime, required) — When the check was run.
- `input` (PhoneCheckInput, optional) — What was sent, minimised: never image bytes, only media ids.
- `externalUserId` (string, optional, nullable) — Your own reference for the check, as sent.
- `result` (PhoneCheckResult, optional, nullable) — What was found. Null when the check could not be completed.
- `failureCode` (string, optional, nullable) — Why the check could not be completed, when `outcome` is `unavailable`.
- `charged` (string, optional, nullable) — What the check cost in USD, as a decimal string. Null when nothing was charged.
- `entityId` (string, optional, nullable) — The customer record this check was saved to.
- `completedAt` (datetime, optional, nullable) — When it finished.
- `replayed` (boolean, optional) — On a run only: true when this is a check already run under the same `requestId`.

### 201

The check was run.

- `id` (string, required) — The check id (`chk_…`).
- `kind` (enum, required) — Which check this is.
  - Allowed values: `phone`
- `outcome` (enum, required) — `pass`: nothing of concern. `review`: something a person should look at. `fail`: a clear problem. `unavailable`: the check could not be completed, was not charged, and is never a pass.
  - Allowed values: `pass`, `review`, `fail`, `unavailable`
- `subject` (string, required) — What was checked, as your history lists it.
- `channel` (enum, required) — Whether the check was run through the API or from the dashboard.
  - Allowed values: `api`, `dashboard`
- `createdAt` (datetime, required) — When the check was run.
- `input` (PhoneCheckInput, optional) — What was sent, minimised: never image bytes, only media ids.
- `externalUserId` (string, optional, nullable) — Your own reference for the check, as sent.
- `result` (PhoneCheckResult, optional, nullable) — What was found. Null when the check could not be completed.
- `failureCode` (string, optional, nullable) — Why the check could not be completed, when `outcome` is `unavailable`.
- `charged` (string, optional, nullable) — What the check cost in USD, as a decimal string. Null when nothing was charged.
- `entityId` (string, optional, nullable) — The customer record this check was saved to.
- `completedAt` (datetime, optional, nullable) — When it finished.
- `replayed` (boolean, optional) — On a run only: true when this is a check already run under the same `requestId`.

## Errors

### 400 Bad Request Error

The request body, query or path was invalid.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 401 Unauthorized Error

The Authorization header is missing, or the API key is unknown or revoked.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 402 Payment Required Error

The organisation does not have enough credit for this request.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 403 Forbidden Error

The key may not call this endpoint, or the organisation may not use this feature.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 409 Conflict Error

The request conflicts with the current state of the resource.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 422 Unprocessable Entity Error

The request was understood but cannot be processed as sent.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

### 503 Service Unavailable Error

The service is temporarily unavailable.

- `error` (string, required) — A stable machine-readable code such as `invalid_input`. Authentication failures (401) carry a short sentence here instead of a code.
- `message` (string, optional) — A human-readable explanation, safe to log. The wording may change.

## Types

### PhoneCheckInput

What was sent, minimised: never image bytes, only media ids.

### PhoneCheckResult

What was found. Null when the check could not be completed.

- `e164` (string, required) — The number in E.164 form, e.g. `+2348031234567`.
- `international` (string, required) — The number written the international way, e.g. `+234 803 123 4567`.
- `valid` (boolean, required) — True when the number is in a range a carrier has been given. False fails the check.
- `possible` (boolean, required) — True when the number has the right length for its country. A number can be possible and still not valid.
- `score` (integer, required) — The phone risk score: 0 is nothing found, 100 the most risk.
- `level` (enum, required) — `low` below 30, `medium` from 30, `high` from 60.
  - Allowed values: `low`, `medium`, `high`
- `reasons` (list of enum, required) — Why points were added, strongest first. New codes may be added; existing ones are never renamed.
  - Allowed values: `invalid_number`, `premium_rate_line`, `voip_line`, `personal_number`, `service_line`, `shared_number`, `linked_to_declined`
- `reuse` (PhoneCheckResultReuse, required) — Whether your organisation has seen the number before, in this environment. Never another organisation's records. All zero for an invalid number.
- `country` (string, optional, nullable) — The ISO 3166-1 alpha-2 code of the country the number belongs to.
- `countryName` (string, optional, nullable) — That country's name in English, e.g. `Nigeria`.
- `callingCode` (string, optional, nullable) — The country calling code, digits only, e.g. `234`.
- `countryMismatch` (boolean, optional, nullable) — True when you sent a `country` and the number belongs to another. Null when you sent none. Not scored: many people carry a number from another country.
- `lineType` (enum, optional) — What kind of line the number is. Null when the range is not classified. New values may be added.
  - Allowed values: `mobile`, `fixed_line`, `fixed_line_or_mobile`, `voip`, `toll_free`, `premium_rate`, `shared_cost`, `personal_number`, `pager`, `uan`, `voicemail`
- `virtual` (boolean, optional, nullable) — True for a VoIP range, false for any other known line type, null when the line type is unknown.

### PhoneCheckResultReuse

Whether your organisation has seen the number before, in this environment. Never another organisation's records. All zero for an invalid number.

- `verifications` (integer, required) — Your verifications that proved this number with a code.
- `declined` (integer, required) — How many of those were declined.
- `customers` (integer, required) — Your customers whose contact details hold this number.
- `people` (integer, required) — At least this many different people used the number. Verifications for the same ID number count once.

## Examples

### Example 1

**Request**

```json
{
  "phone": "+234 803 123 4567",
  "country": "NG",
  "requestId": "phone-check-7f3a9c21"
}
```

**Response**

```json
{
  "id": "string",
  "kind": "phone",
  "outcome": "pass",
  "subject": "string",
  "channel": "api",
  "createdAt": "2024-01-15T09:30:00Z",
  "input": {},
  "externalUserId": "string",
  "result": {
    "e164": "string",
    "international": "string",
    "valid": true,
    "possible": true,
    "score": 1,
    "level": "low",
    "reasons": [
      "invalid_number"
    ],
    "reuse": {
      "verifications": 1,
      "declined": 1,
      "customers": 1,
      "people": 1
    },
    "country": "string",
    "countryName": "string",
    "callingCode": "string",
    "countryMismatch": true,
    "lineType": "mobile",
    "virtual": true
  },
  "failureCode": "string",
  "charged": "string",
  "entityId": "string",
  "completedAt": "2024-01-15T09:30:00Z",
  "replayed": true
}
```

**SDK Code**

```python
import requests

url = "https://sandbox-api.toden.co/api/v1/checks/phone"

payload = {
    "phone": "+234 803 123 4567",
    "country": "NG",
    "requestId": "phone-check-7f3a9c21"
}
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://sandbox-api.toden.co/api/v1/checks/phone';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"phone":"+234 803 123 4567","country":"NG","requestId":"phone-check-7f3a9c21"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://sandbox-api.toden.co/api/v1/checks/phone"

	payload := strings.NewReader("{\n  \"phone\": \"+234 803 123 4567\",\n  \"country\": \"NG\",\n  \"requestId\": \"phone-check-7f3a9c21\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://sandbox-api.toden.co/api/v1/checks/phone")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"phone\": \"+234 803 123 4567\",\n  \"country\": \"NG\",\n  \"requestId\": \"phone-check-7f3a9c21\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://sandbox-api.toden.co/api/v1/checks/phone")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"phone\": \"+234 803 123 4567\",\n  \"country\": \"NG\",\n  \"requestId\": \"phone-check-7f3a9c21\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sandbox-api.toden.co/api/v1/checks/phone', [
  'body' => '{
  "phone": "+234 803 123 4567",
  "country": "NG",
  "requestId": "phone-check-7f3a9c21"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://sandbox-api.toden.co/api/v1/checks/phone");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"phone\": \"+234 803 123 4567\",\n  \"country\": \"NG\",\n  \"requestId\": \"phone-check-7f3a9c21\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "phone": "+234 803 123 4567",
  "country": "NG",
  "requestId": "phone-check-7f3a9c21"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox-api.toden.co/api/v1/checks/phone")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Example 2

**Request**

```json
{
  "phone": "+234 803 123 4567",
  "country": "NG",
  "requestId": "phone-check-7f3a9c21"
}
```

**Response**

```json
{
  "id": "string",
  "kind": "phone",
  "outcome": "pass",
  "subject": "string",
  "channel": "api",
  "createdAt": "2024-01-15T09:30:00Z",
  "input": {},
  "externalUserId": "string",
  "result": {
    "e164": "string",
    "international": "string",
    "valid": true,
    "possible": true,
    "score": 1,
    "level": "low",
    "reasons": [
      "invalid_number"
    ],
    "reuse": {
      "verifications": 1,
      "declined": 1,
      "customers": 1,
      "people": 1
    },
    "country": "string",
    "countryName": "string",
    "callingCode": "string",
    "countryMismatch": true,
    "lineType": "mobile",
    "virtual": true
  },
  "failureCode": "string",
  "charged": "string",
  "entityId": "string",
  "completedAt": "2024-01-15T09:30:00Z",
  "replayed": true
}
```

**SDK Code**

```python
import requests

url = "https://sandbox-api.toden.co/api/v1/checks/phone"

payload = {
    "phone": "+234 803 123 4567",
    "country": "NG",
    "requestId": "phone-check-7f3a9c21"
}
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://sandbox-api.toden.co/api/v1/checks/phone';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"phone":"+234 803 123 4567","country":"NG","requestId":"phone-check-7f3a9c21"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://sandbox-api.toden.co/api/v1/checks/phone"

	payload := strings.NewReader("{\n  \"phone\": \"+234 803 123 4567\",\n  \"country\": \"NG\",\n  \"requestId\": \"phone-check-7f3a9c21\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://sandbox-api.toden.co/api/v1/checks/phone")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"phone\": \"+234 803 123 4567\",\n  \"country\": \"NG\",\n  \"requestId\": \"phone-check-7f3a9c21\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://sandbox-api.toden.co/api/v1/checks/phone")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"phone\": \"+234 803 123 4567\",\n  \"country\": \"NG\",\n  \"requestId\": \"phone-check-7f3a9c21\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sandbox-api.toden.co/api/v1/checks/phone', [
  'body' => '{
  "phone": "+234 803 123 4567",
  "country": "NG",
  "requestId": "phone-check-7f3a9c21"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://sandbox-api.toden.co/api/v1/checks/phone");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"phone\": \"+234 803 123 4567\",\n  \"country\": \"NG\",\n  \"requestId\": \"phone-check-7f3a9c21\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "phone": "+234 803 123 4567",
  "country": "NG",
  "requestId": "phone-check-7f3a9c21"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox-api.toden.co/api/v1/checks/phone")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```