Decode M-Pesa HashNumbers, into clear Mobile numbers.
Eliminate need for mandatory customer phone registrations,
Enjoy Simple reconciliation, Send notifications of payments and more.

Simplifying your payment process with clear and transparent payment records. Join hundreds of Businesses and Developers utilizing our service.
Check our Pricing Developers

How It Works

It's simple, you can start decoding in 5 minutes.
1
Receive Callback Response
When a transaction occurs, Safaricom sends a callback response to your webhook with hashed MSISDN through the M-Pesa C2B APIs V2.
2
Create Account and decode
Sign up and Sign in to your MpesaHashDecode account. Top up from your account with KES 50 or more. Copy paste your hash and click "Decode".
3
Decode via API
Generate an API token from your MpesaHashDecode dashboard and copy it somewhere safe. Use it in your code script and send a request to our endpoint as shown below.


For Developers. How to decode via API

Easily decode hashed MSISDNs using our API by sending a simple json object of the hash or hashes

URL: https://hashdecoder.co.ke/api/decode
METHOD: POST

Request Parameter Type Description
hashes Array List of hashes to be decoded into mobile numbers.
Response Parameter Type Description
hash String The hash value that was provided in the request.
mobile String The decoded mobile number corresponding to the hash.
Response Error Code Meaning
200 Success. The request was processed successfully.
400 Bad Request: Missing parameters. This error appears when not all mandatory parameters are provided.
401 Authentication error: Invalid API key. This error occurs if the provided API key is unknown or expired.
402 Low Balance. Please recharge to make requests.
403 An error occurred while fetching data.
404 Unauthorized access. This error occurs when the request lacks proper authentication.
419 Too Many Requests: Rate limit exceeded.
500 Internal server error. A generic error indicating an issue on the server side.
Send JSON Request
Below is an example of how to send a JSON request to our API:

Authorization: Bearer < your-accounts-api-token>
{
    "hashes": [
        "19715418b8d85f13e084b779185e158703ee42188420fd254ad39f3c912a34f4",
        "19715418b8d85f13e084b77hhweidbukeawfd254ad39f3c9cdddcddcddc8420f"
    ]
}

                    
Receive synchronous JSON Response
The API will return a JSON response with the decoded mobile numbers:

[
    {
        "hash": "19715418b8d85f13e084b779185e158703ee42188420fd254ad39f3c912a34f4",
        "mobile": "254725164293"
    },
    {
        "hash": "19715418b8d85f13e084b77hhweidbukeawfd254ad39f3c9cdddcddcddc8420f",
        "mobile": "254723350761"
    }
]

                    


Code samples

Check out the samples below. Need assistance with intergration? Chat on whatsapp

cURL

curl -X POST https://hashdecoder.co.ke/api/decode \
-H "Authorization: Bearer 1|S0UDLbvixay1MQCCyulQWSZjIX39ADvNDtDpU2SA95c291c3" \
-H "Content-Type: application/json" \
-d '{
    "hashes": [
        "017eeddaa0ddea5ed4fe550aa03c1626d7a59c2126a6a14fd0a66a86a98f5448"
    ]
}'

HTTP

POST /api/decode  HTTP/1.1
Host: hashdecoder.co.ke
Content-Type: application/json
Authorization: Bearer 7|QtzTHM7p3SsUeZT7rz2yi14J3CysnKOhwIqn5Wu9cd16c26a
Content-Length: 100

{
    "hashes": [
        "017eeddaa0ddea5ed4fe550aa03c1626d7a59c2126a6a14fd0a66a86a98f5448"
    ]
}

Javascript fetch


  const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer 7|QtzTHM7p3SsUeZT7rz2yi14J3CysnKOhwIqn5Wu9cd16c26a");

const raw = JSON.stringify({
  "hashes": [
    "017eeddaa0ddea5ed4fe550aa03c1626d7a59c2126a6a14fd0a66a86a98f5448"
  ]
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://hashdecoder.co.ke/api/decode ", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

Nodejs


  const axios = require('axios');
let data = JSON.stringify({
  "hashes": [
    "017eeddaa0ddea5ed4fe550aa03c1626d7a59c2126a6a14fd0a66a86a98f5448"
  ]
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://hashdecoder.co.ke/api/decode ',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer 7|QtzTHM7p3SsUeZT7rz2yi14J3CysnKOhwIqn5Wu9cd16c26a'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

PHP cURL



$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://hashdecoder.co.ke/api/decode ',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "hashes": [
        "017eeddaa0ddea5ed4fe550aa03c1626d7a59c2126a6a14fd0a66a86a98f5448"
    ]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer 7|QtzTHM7p3SsUeZT7rz2yi14J3CysnKOhwIqn5Wu9cd16c26a'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Python http.client


  import http.client
  import json
  
  conn = http.client.HTTPSConnection("hashdecoder.co.ke")
  payload = json.dumps({
    "hashes": [
      "017eeddaa0ddea5ed4fe550aa03c1626d7a59c2126a6a14fd0a66a86a98f5448"
    ]
  })
  headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer 7|QtzTHM7p3SsUeZT7rz2yi14J3CysnKOhwIqn5Wu9cd16c26a'
  }
  conn.request("POST", "/api/decode ", payload, headers)
  res = conn.getresponse()
  data = res.read()
  print(data.decode("utf-8"))







Clear Pricing

No hidden costs. Pay for what you use
Sign up and Top up with any amount above 50 KES and immediately start decoding hashes both via API or Manually via your accounts dashboard.

Standard

Simple standard pricing
KES 0.5 / decode request
Unlimited requests
Non-expiring credits
Only successful decodes charged
99% API & Web Uptime
Get started

Talk to us and get your project moving!

Email us at [email protected]

Need more information?

Jump into a call with us to discuss. Call Now +254725164293

More on M-Pesa Hash Decode

Developers How it Works

Stay Connected

Github Twitter
Logo © 2024 M-Pesa Hash Decode Ltd.