Developers

The delivery#

HTTP
POST /ekash/webhooks HTTP/1.1
Content-Type: application/json
User-Agent: ekash-webhooks/1
ekash-event-id: evt_9f1c7b2e4a6d4f0b8c3e5a7d9f1b3c5e
ekash-event-type: payment.sent
ekash-timestamp: 1758533400
ekash-signature: v1=86555d15e010a547f0f3ea5aa7f62b291f88e475ddd7b1b61ab498e3404091c4

{
  "id": "evt_9f1c7b2e4a6d4f0b8c3e5a7d9f1b3c5e",
  "type": "payment.sent",
  "created_at": "2026-09-22T09:30:00Z",
  "data": { … }
}

data is the same object the REST API returns for that resource — a PublicPayment for payment.*, a PublicBatch for batch.*. One parser handles both surfaces.

That includes the fee breakdown of the payment: sender_fee, recipient_fee, conversion_fee, fee_currency, total_debited, expected_received, recipient_gets_is_exact, rate, price_locked_at and price_ref (README, What a payment costs), and for a batch each row's breakdown plus the batch's total_fees and total_debited. They are the figures locked when the payment was priced, so every event of a payment carries the same price. A payment priced before the fee model changed has sender_fee and fee_currency only. What the payout provider charges ekash, ekash's margin and customer-specific pricing terms are never in a webhook.

data is a snapshot frozen at the moment of the change, not a fresh read. A retry six hours later still describes the state the event announced, so a payment.processing retry never arrives carrying "status": "sent".

Respond 2xx quickly. Anything else — including a 3xx — is a failed attempt. Do your real work on a queue: acknowledge, then process. We never follow redirects, because re-POSTing a signed payment notification to a host you did not register is exactly the property that would make the signature dangerous rather than useful.

Verify the signature#

Text
signed_payload = "<ekash-timestamp>" + "." + "<raw request body>"
ekash-signature = "v1=" + lowercase_hex(HMAC_SHA256(key = your endpoint secret, message = signed_payload))

Two details that trip up every webhook integration:

  1. Use the raw body bytes, exactly as received. If your framework parses the JSON and you re-serialise it before verifying, the digest will not match — key order and whitespace change.
  2. The key is the secret string as UTF-8 bytes, used as-is. Do not hex-decode it first.

Also check the timestamp. A signature is valid forever unless you bound it, so reject a delivery whose ekash-timestamp is more than a few minutes old — that is what stops a captured request being replayed at you later.

Python (Flask)#

Python
import hashlib, hmac, os, time
from flask import Flask, request, abort

SECRET = os.environ["EKASH_WEBHOOK_SECRET"]   # the 64-hex secret from registration
TOLERANCE_SECONDS = 300

app = Flask(__name__)

@app.post("/ekash/webhooks")
def ekash_webhook():
    raw = request.get_data()                       # RAW bytes, before any JSON parsing
    timestamp = request.headers.get("ekash-timestamp", "")
    signature = request.headers.get("ekash-signature", "")

    if abs(time.time() - int(timestamp or 0)) > TOLERANCE_SECONDS:
        abort(400, "stale delivery")

    expected = "v1=" + hmac.new(
        SECRET.encode(), timestamp.encode() + b"." + raw, hashlib.sha256
    ).hexdigest()
    if not hmac.compare_digest(expected, signature):   # constant time
        abort(400, "bad signature")

    event = request.get_json()
    if already_processed(event["id"]):             # at-least-once: dedupe on the event id
        return "", 200
    enqueue(event)                                 # acknowledge fast, work later
    return "", 200

Node (Express)#

JavaScript
const crypto = require('crypto');
const express = require('express');

const SECRET = process.env.EKASH_WEBHOOK_SECRET;
const TOLERANCE_SECONDS = 300;
const app = express();

// express.raw, NOT express.json — the signature covers the bytes on the wire.
app.post('/ekash/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
  const timestamp = req.get('ekash-timestamp') || '';
  const signature = req.get('ekash-signature') || '';

  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > TOLERANCE_SECONDS) {
    return res.status(400).send('stale delivery');
  }

  const expected = 'v1=' + crypto
    .createHmac('sha256', SECRET)
    .update(Buffer.concat([Buffer.from(timestamp + '.'), req.body]))
    .digest('hex');

  const a = Buffer.from(expected);
  const b = Buffer.from(signature);
  if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) {
    return res.status(400).send('bad signature');
  }

  const event = JSON.parse(req.body.toString('utf8'));
  if (alreadyProcessed(event.id)) return res.sendStatus(200);   // dedupe on event.id
  enqueue(event);                                               // acknowledge fast
  res.sendStatus(200);
});

A known-good vector#

Use this to check your implementation before you go near a real delivery.

Text
secret     = 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
timestamp  = 1758533400
body       = {"id":"evt_11112222333344445555666677778888","type":"payment.sent","created_at":"2026-09-22T09:30:00Z","data":{"id":"4210","status":"sent"}}

ekash-signature = v1=86555d15e010a547f0f3ea5aa7f62b291f88e475ddd7b1b61ab498e3404091c4