Validate phone number
Normalize a Kenyan phone number and identify its issuing network. Always free.
Base URL
https://api.dehashit.com/api/v1/Validate phone number
POST
/api/v1/validations/phone-validation/Validate a phone number and identify its issuing network operator. Always free. Supports Kenya (country_code: "254"). Non-Kenyan country codes return 404.
Validation checks number format, not whether the number is active or reachable. Carrier is based on the original numbering prefix and does not account for number portability; an unassigned prefix returns carrier: "unknown".
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
| phone_number | string | required | National or international format: 712345678, 0712345678, 254712345678, +254712345678, or 00254712345678. Spaces, dashes, and brackets are ignored. The response uses the normalized 254 format. |
| country_code | string | required | Use the string "254". Other numeric country codes return 404; a nonnumeric code returns 400. |
Request
curl -X POST https://api.dehashit.com/api/v1/validations/phone-validation/ \
-H "X-Api-Key: dh_live_..." -H "Content-Type: application/json" \
-d '{"phone_number": "712345678", "country_code": "254"}'import requests
r = requests.post(
"https://api.dehashit.com/api/v1/validations/phone-validation/",
json={"phone_number": "712345678", "country_code": "254"},
headers={"X-Api-Key": "dh_live_..."},
timeout=10,
)
print(r.json()["data"])const res = await fetch("https://api.dehashit.com/api/v1/validations/phone-validation/", {
method: "POST",
headers: { "X-Api-Key": "dh_live_...", "Content-Type": "application/json" },
body: JSON.stringify({ phone_number: "712345678", country_code: "254" }),
});
console.log((await res.json()).data);package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]string{
"phone_number": "712345678",
"country_code": "254",
})
req, _ := http.NewRequest("POST",
"https://api.dehashit.com/api/v1/validations/phone-validation/",
bytes.NewReader(body))
req.Header.Set("X-Api-Key", "dh_live_...")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var out struct {
Status bool `json:"status"`
Data struct {
PhoneNumber string `json:"phone_number"`
Country string `json:"country"`
Carrier string `json:"carrier"`
Valid bool `json:"valid"`
} `json:"data"`
}
if err := json.NewDecoder(res.Body).Decode(&out); err != nil {
panic(err)
}
fmt.Println(out.Data.PhoneNumber, out.Data.Carrier, out.Data.Valid)
}Response
{
"status": true,
"status_code": 0,
"message": "Data found.",
"data": {
"phone_number": "254712345678",
"country": "Kenya",
"carrier": "Safaricom",
"valid": true,
"type": "mobile"
}
}{
"status": false,
"status_code": 404,
"error_code": "not_found",
"message": "No data found.",
"data": {}
}Need a hand with your integration? Contact support.