{"schema":"https://iosor.com/schemas/webhook-dlr-simulator-v1.json","locale":"en","localizedSummary":"DLR webhook & error classifier JSON","simulation":{"scenario":"otp","corridor":"US_CA","primaryPartnerId":"simpletexting","primaryPartnerName":"SimpleTexting","failoverPartnerId":"msg91","failoverPartnerName":"MSG91","errorSpec":{"code":"SMPP_0x00000014","protocol":"SMPP_GSM","title":"Message Queue Full / MSC Congestion (0x14)","category":"carrier_congestion","retryableOnFailover":true,"recommendedAction":"failover_immediately","failoverDelayMs":150,"engineeringNote":"Downstream SMSC queue is saturated. Reroute immediately to secondary partner with independent MNO bind."},"eventId":"evt_us_ca_otp_smpp0x00000014","idempotencyKey":"idem_us_ca_otp_99481a","timestampUnix":1794240000,"signatureHeader":"t=1794240000,v1=35736c3a58967cf235736c3a58967cf235736c3a58967cf235736c3a58967cf2","canonicalSigningString":"1794240000.{\n  \"schema\": \"https://iosor.com/schemas/normalized-dlr-webhook-v1.json\",\n  \"eventId\": \"evt_us_ca_otp_smpp0x00000014\",\n  \"idempotencyKey\": \"idem_us_ca_otp_99481a\",\n  \"timestampUnix\": 1794240000,\n  \"corridor\": \"US_CA\",\n  \"workload\": \"otp\",\n  \"originRail\": {\n    \"role\": \"primary\",\n    \"partnerId\": \"simpletexting\",\n    \"partnerName\": \"SimpleTexting\"\n  },\n  \"telemetry\": {\n    \"protocol\": \"SMPP_GSM\",\n    \"errorCode\": \"SMPP_0x00000014\",\n    \"errorTitle\": \"Message Queue Full / MSC Congestion (0x14)\",\n    \"category\": \"carrier_congestion\"\n  },\n  \"routerDecision\": {\n    \"retryableOnFailover\": true,\n    \"action\": \"failover_immediately\",\n    \"targetFailoverPartnerId\": \"msg91\",\n    \"targetFailoverPartnerName\": \"MSG91\",\n    \"failoverDelayMs\": 150,\n    \"idempotencyTtlSec\": 86400\n  }\n}","normalizedPayloadJson":"{\n  \"schema\": \"https://iosor.com/schemas/normalized-dlr-webhook-v1.json\",\n  \"eventId\": \"evt_us_ca_otp_smpp0x00000014\",\n  \"idempotencyKey\": \"idem_us_ca_otp_99481a\",\n  \"timestampUnix\": 1794240000,\n  \"corridor\": \"US_CA\",\n  \"workload\": \"otp\",\n  \"originRail\": {\n    \"role\": \"primary\",\n    \"partnerId\": \"simpletexting\",\n    \"partnerName\": \"SimpleTexting\"\n  },\n  \"telemetry\": {\n    \"protocol\": \"SMPP_GSM\",\n    \"errorCode\": \"SMPP_0x00000014\",\n    \"errorTitle\": \"Message Queue Full / MSC Congestion (0x14)\",\n    \"category\": \"carrier_congestion\"\n  },\n  \"routerDecision\": {\n    \"retryableOnFailover\": true,\n    \"action\": \"failover_immediately\",\n    \"targetFailoverPartnerId\": \"msg91\",\n    \"targetFailoverPartnerName\": \"MSG91\",\n    \"failoverDelayMs\": 150,\n    \"idempotencyTtlSec\": 86400\n  }\n}","verifierSnippets":{"typescript":"// IOSOR 2027 Webhook HMAC-SHA256 + Replay & Idempotency Guard (Node / Edge)\nimport crypto from 'node:crypto';\n\nexport function verifyAndClassifyWebhook(\n  rawBody: string,\n  signatureHeader: string,\n  secret: string,\n  seenIdempotencyKeys: Set<string>,\n  toleranceSec = 300\n) {\n  const parts = Object.fromEntries(signatureHeader.split(',').map((p) => p.split('=')));\n  const ts = Number(parts.t || 0);\n  if (Math.abs(Math.floor(Date.now() / 1000) - ts) > toleranceSec) {\n    throw new Error('WEBHOOK_REPLAY_WINDOW_EXPIRED');\n  }\n  const expected = crypto\n    .createHmac('sha256', secret)\n    .update(`${ts}.${rawBody}`)\n    .digest('hex');\n  if (!crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1 || ''))) {\n    throw new Error('WEBHOOK_SIGNATURE_MISMATCH');\n  }\n  const event = JSON.parse(rawBody);\n  if (seenIdempotencyKeys.has(event.idempotencyKey)) {\n    return { status: 'duplicate_ignored', action: 'noop' };\n  }\n  seenIdempotencyKeys.add(event.idempotencyKey);\n  return {\n    status: 'verified',\n    action: event.routerDecision.action,\n    failoverPartnerId: event.routerDecision.targetFailoverPartnerId,\n  };\n}","python":"# IOSOR 2027 Webhook HMAC-SHA256 + Idempotency Verifier (Python / FastAPI)\nimport hmac, hashlib, json, time\n\ndef verify_and_classify_webhook(raw_body: str, sig_header: str, secret: str, seen_keys: set, tolerance_sec: int = 300):\n    parts = dict(item.split(\"=\", 1) for item in sig_header.split(\",\") if \"=\" in item)\n    ts = int(parts.get(\"t\", \"0\"))\n    if abs(int(time.time()) - ts) > tolerance_sec:\n        raise ValueError(\"WEBHOOK_REPLAY_WINDOW_EXPIRED\")\n    expected = hmac.new(secret.encode(), f\"{ts}.{raw_body}\".encode(), hashlib.sha256).hexdigest()\n    if not hmac.compare_digest(expected, parts.get(\"v1\", \"\")):\n        raise ValueError(\"WEBHOOK_SIGNATURE_MISMATCH\")\n    event = json.loads(raw_body)\n    idem = event[\"idempotencyKey\"]\n    if idem in seen_keys:\n        return {\"status\": \"duplicate_ignored\", \"action\": \"noop\"}\n    seen_keys.add(idem)\n    return {\"status\": \"verified\", \"action\": event[\"routerDecision\"][\"action\"]}","go":"// IOSOR 2027 Webhook HMAC-SHA256 + Replay Guard (Go)\npackage webhook\n\nimport (\n\t\"crypto/hmac\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"fmt\"\n)\n\nfunc VerifyWebhookSignature(timestamp string, rawBody []byte, receivedHex string, secret string) bool {\n\tmac := hmac.New(sha256.New, []byte(secret))\n\tmac.Write([]byte(fmt.Sprintf(\"%s.%s\", timestamp, string(rawBody))))\n\texpected := hex.EncodeToString(mac.Sum(nil))\n\treturn hmac.Equal([]byte(expected), []byte(receivedHex))\n}"}},"catalogCount":16}