Overview

ScopePay is a professional M-Pesa STK Push API aggregator. Two endpoints, simple JSON requests, instant payments.

PropertyValue
Base URLhttps://scopepay.co.ke/
Content-Typeapplication/json
MethodPOST
Min AmountKES 1
Max AmountKES 150,000

Authentication

All API requests are authenticated via api_key and api_secret sent in the JSON request body.

Get your API keys: Login to Dashboard → API Keys and generate them. Save your secret — it's shown only once.

Initiate STK Push

POST /api/initiatestk.php

Request Parameters

ParameterTypeRequiredDescription
api_keystringYesYour API key
api_secretstringYesYour API secret
account_idstringYesYour Linked Account ID
amountintegerYesAmount in KES (min 1)
phonestringYesPhone number (07XXXXXXXX or 01XXXXXXXX)
referencestringYesPayment reference / description

Success Response (200)

{
    "success": true,
    "transaction_ref": "TXN-A8F3D2B9-45",
    "merchant_request_id": "29115-34620561-1",
    "checkout_request_id": "ws_CO_191220191020363925",
    "result_code": 0,
    "message": "STK Push initiated successfully"
}

Error Response (500)

{
    "error": "Payment initiation failed",
    "merchant_request_id": "",
    "checkout_request_id": "",
    "result_code": 1
}

Transaction Status

POST /api/transactionstatus.php

Request Parameters

ParameterTypeRequiredDescription
api_keystringYesYour API key
api_secretstringYesYour API secret
checkout_request_idstringYesFrom initiate STK response

Success Response (200)

{
    "success": true,
    "merchant_request_id": "29115-34620561-1",
    "checkout_request_id": "ws_CO_191220191020363925",
    "result_code": "0",
    "status": "paid",
    "amount": 100.00,
    "phone": "0712345678",
    "receipt": "PZ3DUJJ7GY",
    "description": "Order #12345",
    "created_at": "2026-02-18 12:34:56"
}

Error Response (404)

{
    "error": "Transaction not found"
}

Webhook Payload

When a payment completes, ScopePay sends a POST request to your configured webhook URL:

{
    "merchant_request_id": "29115-34620561-1",
    "checkout_request_id": "ws_CO_191220191020363925",
    "result_code": 0,
    "scopepay_ref": "TXN-A8F3D2B9-45",
    "account_id": 1,
    "customer_phone": "0712345678",
    "amount": 100.00,
    "fee": 0.00,
    "net_settled": 100.00,
    "mpesa_receipt": "PZ3DUJJ7GY",
    "description": "Order #12345",
    "status": "settled",
    "timestamp": "2026-02-18T12:34:56+03:00"
}
Important: Your webhook must respond with HTTP 200 within 5 seconds. Configure your webhook URL in Dashboard → Webhooks.

Error Codes

HTTP CodeDescriptionSolution
400Bad Request / Missing paramsCheck required parameters
401Invalid API credentialsVerify api_key and api_secret
403No active subscriptionActivate account in dashboard
404Transaction not foundCheck checkout_request_id
500Server errorContact support

Code Examples

cURL — Initiate STK Push

curl -X POST https://scopepay.co.ke/api/initiatestk.php \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "your_api_key",
    "api_secret": "your_api_secret",
    "account_id": "your_account_id",
    "amount": 100,
    "phone": "0712345678",
    "reference": "Order #12345"
  }'

cURL — Transaction Status

curl -X POST https://scopepay.co.ke/api/transactionstatus.php \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "your_api_key",
    "api_secret": "your_api_secret",
    "checkout_request_id": "ws_CO_191220191020363925"
  }'

PHP — Initiate STK Push

<?php
$url = 'https://scopepay.co.ke/api/initiatestk.php';

$payload = json_encode([
    'api_key'    => 'your_api_key',
    'api_secret' => 'your_api_secret',
    'account_id' => 'your_account_id',
    'amount'     => 100,
    'phone'      => '0712345678',
    'reference'  => 'Order #12345'
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);
?>

PHP — Transaction Status

<?php
$url = 'https://scopepay.co.ke/api/transactionstatus.php';

$payload = json_encode([
    'api_key'             => 'your_api_key',
    'api_secret'          => 'your_api_secret',
    'checkout_request_id' => 'ws_CO_191220191020363925'
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);
?>