HivePay Docs v1.0
Sign In Get API Keys
Security & Headers

Authentication & API Keys

All requests to the HivePay Gateway API must be authenticated using your merchant API key passed via standard HTTP headers.

Environment Base URLs

Environment Base URL Status
Production https://hivepay.site/api/v1 Live

Merchant Credentials & Headers

Every merchant account on HivePay is provisioned with a triad of credentials: an API Key, a confidential API Secret, and a unique Account Number (e.g. HP2609562857).

Header Status Type Description & Purpose
X-API-Key REQUIRED string Your merchant API Key (e.g. ph_...). Identifies which merchant account is initiating the API call.
X-API-Secret HIGHLY RECOMMENDED string (64-char) Your private server credential. Proves that the request is genuinely from your backend server and not an intercepted client-side call.
X-Account-Number RECOMMENDED string Your HivePay Merchant Account Number (e.g. HP2609562857). Ensures transactions route strictly to your settlement wallet.
X-Signature OPTIONAL string (HMAC-SHA256) Cryptographic payload hash computed via hash_hmac('sha256', $body, $apiSecret) for tamper-proof payload integrity.
Content-Type POST ONLY string Set to application/json on all POST/PUT requests.
?

What is the Purpose of the API Secret?

In modern financial APIs, an API Key is often used as a public identifier, but it alone does not provide complete protection against credential leaks or payload tampering. The API Secret provides three vital security pillars:

🔒 1. Server-to-Server Auth

Passing X-API-Secret guarantees requests originate from your secure backend server, blocking unauthorized frontend calls.

✍ 2. Request Signing (HMAC)

You can hash request bodies using your API Secret into an X-Signature header. Nobody can alter amounts or numbers in flight.

📡 3. Webhook Authentication

Use your secrets to verify incoming webhook alerts from HivePay, confirming payments are legitimate before crediting customers.

Verification Request

Verify that your credentials function properly by querying the wallet balance endpoint:

curl -X GET https://hivepay.site/api/v1/balance \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "X-API-Secret: YOUR_API_SECRET" \
  -H "X-Account-Number: YOUR_ACCOUNT_NUMBER" \
  -H "Accept: application/json"

Cryptographic Request Signing (HMAC-SHA256)

HIGH SECURITY

For maximum financial security, you can use your API Secret to sign POST request bodies with HMAC-SHA256. Pass the resulting hash in the X-Signature header. HivePay verifies that the payload has not been intercepted or tampered with in transit:

<?php
$apiSecret = getenv('HIVEPAY_API_SECRET');
$payload   = json_encode([
    'phone_number' => '0777123456',
    'amount'       => 50000,
    'description'  => 'Payment for Order #1042'
]);

// Generate cryptographic HMAC-SHA256 signature using your API Secret
$signature = hash_hmac('sha256', $payload, $apiSecret);

$ch = curl_init('https://hivepay.site/api/v1/collect-money');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $payload,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-API-Key: " . getenv('HIVEPAY_API_KEY'),
        "X-API-Secret: {$apiSecret}",
        "X-Account-Number: " . getenv('HIVEPAY_ACCOUNT_NUMBER'),
        "X-Signature: {$signature}",
        "Content-Type: application/json"
    ]
]);

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

API Key Protection Guidelines

  • Never embed your API key directly in client-side code, mobile apps, or public Git repositories.
  • Store keys in encrypted environment variables (e.g. .env).
  • If an API key is accidentally exposed, immediately revoke and regenerate it from your Settings panel.