Skip to main content

Overview

Webhooks deliver real-time notifications when payment and request events occur. Configure your endpoints to receive HMAC-signed POST requests with automatic retry logic and comprehensive event data.

Webhook Configuration

Setup in Portal

  1. Navigate to Platform Settings โ†’ Webhooks in Request Portal
  2. Click Add webhook
  3. In the dialog that opens, enter URL and click Create webhook
  4. Click copy button to copy Signing Secret to clipboard (see Authentication for API key setup)
  5. Enable/disable or delete webhooks as needed

Local Development

Use ngrok to receive webhooks locally:
ngrok http 3000
# Use the HTTPS URL (e.g., https://abc123.ngrok.io/webhook) in Portal

Event Types

See Payload Examples below for detailed webhook structures.

Payment Events

EventDescriptionContextPrimary Use
payment.confirmedPayment fully completed and settledAfter blockchain confirmationComplete fulfillment, release goods
payment.partialPartial payment received for requestInstallments, partial ordersUpdate balance, allow additional payments
payment.failedPayment execution failedRecurring payments, cross-chain transfersNotify failure, retry logic, pause subscriptions
payment.refundedPayment has been refunded to payerCross-chain payment failures, refund scenariosUpdate order status, notify customer

Processing Events

EventDescriptionContextPrimary Use
payment.processingCrypto-to-fiat payment in progresssubStatus values: initiated, pending_internal_assessment, ongoing_checks, sending_fiat, fiat_sent, bouncedTrack crypto-to-fiat payment status, update UI

Request Events

EventDescriptionContextPrimary Use
request.recurringNew recurring request generatedSubscription renewals, scheduled paymentsSend renewal notifications, update billing

Compliance Events

EventDescriptionContextPrimary Use
compliance.updatedKYC or agreement status changedkycStatus values: not_started, pending, approved, rejected, retry_required
agreementStatus values: not_started, pending, completed, rejected, failed
Update user permissions, notify status
payment_detail.updatedBank account verification status updatedStates: approved, failed, pendingEnable fiat payments, update profiles

Security Implementation

Signature Verification

Every webhook includes an HMAC SHA-256 signature in the x-request-network-signature header:
import crypto from "node:crypto";

function verifyWebhookSignature(payload, signature, secret) {
  const expectedSignature = crypto
    .createHmac("sha256", secret)
    .update(JSON.stringify(payload))
    .digest("hex");
    
  return signature === expectedSignature;
}

// Usage in your webhook handler
app.post("/webhook", (req, res) => {
  const signature = req.headers["x-request-network-signature"];
  
  if (!verifyWebhookSignature(req.body, signature, WEBHOOK_SECRET)) {
    return res.status(401).json({ error: "Invalid signature" });
  }
  
  // Process webhook...
  res.status(200).json({ success: true });
});

Security Requirements

  • HTTPS only: Production webhooks require HTTPS endpoints
  • Always verify signatures: Never process unverified webhook requests
  • Keep secrets secure: Store signing secrets as environment variables
  • Return 2xx for success: Any 2xx status code confirms successful processing

Request Headers

Each webhook request includes these headers:
HeaderDescriptionExample
x-request-network-signatureHMAC SHA-256 signaturea1b2c3d4e5f6...
x-request-network-deliveryUnique delivery ID (ULID)01ARZ3NDEKTSV4RRFFQ69G5FAV
x-request-network-retry-countCurrent retry attempt (0-3)0
x-request-network-testPresent for test webhookstrue
content-typeAlways JSONapplication/json

Retry Logic

Automatic Retries

  • Max attempts: 3 retries (4 total attempts)
  • Retry delays: 1s, 5s, 15s
  • Trigger conditions: Non-2xx response codes, timeouts, connection errors
  • Timeout: 5 seconds per request

Response Handling

// โœ… Success - no retry
res.status(200).json({ success: true });
res.status(201).json({ created: true });

// โŒ Error - triggers retry
res.status(401).json({ error: "Unauthorized" });
res.status(404).json({ error: "Resource not found" });
res.status(500).json({ error: "Internal server error" });

Error Logging

Request API logs all webhook delivery failures with:
  • Endpoint URL
  • Attempt number
  • Error details
  • Final failure after all retries

Payload Examples

All payment events include an explorer field linking to Request Scan for transaction details. Common Fields:
  • requestId / requestID: Unique identifier for the payment request
  • paymentReference: Short reference, also unique to a request, used to link payments to the request
  • timestamp: ISO 8601 formatted event timestamp
  • paymentProcessor: Either request-network (crypto) or request-tech (fiat)

Payment Confirmed

{
  "event": "payment.confirmed",
  "requestId": "0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "requestID": "0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "paymentReference": "0x2c3366941274c34c",
  "explorer": "https://scan.request.network/request/0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "amount": "100.0",
  "totalAmountPaid": "100.0",
  "expectedAmount": "100.0",
  "timestamp": "2025-10-03T14:30:00Z",
  "txHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
  "network": "ethereum",
  "currency": "USDC",
  "paymentCurrency": "USDC",
  "isCryptoToFiat": false,
  "subStatus": "",
  "paymentProcessor": "request-network",
  "fees": [
    {
      "type": "network",
      "amount": "0.02",
      "currency": "ETH"
    }
  ]
}

Payment Processing

{
  "event": "payment.processing",
  "requestId": "0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "requestID": "0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "paymentReference": "0x2c3366941274c34c",
  "offrampId": "offramp_test123456789",
  "timestamp": "2025-10-03T14:35:00Z",
  "subStatus": "ongoing_checks",
  "paymentProcessor": "request-tech",
  "rawPayload": {
    "status": "ongoing_checks",
    "providerId": "provider_test123"
  }
}

Payment Partial

{
  "event": "payment.partial",
  "requestId": "0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "requestID": "0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "paymentReference": "0x2c3366941274c34c",
  "explorer": "https://scan.request.network/request/0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "amount": "50.0",
  "totalAmountPaid": "50.0",
  "expectedAmount": "100.0",
  "timestamp": "2025-10-03T14:30:00Z",
  "txHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
  "network": "ethereum",
  "currency": "USDC",
  "paymentCurrency": "USDC",
  "isCryptoToFiat": false,
  "subStatus": "",
  "paymentProcessor": "request-network",
  "fees": []
}

Payment Failed

{
  "event": "payment.failed",
  "requestId": "0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "requestID": "0151b394e3c482c5aebaa04eb04508a8db70595470760293f1b258ed96d1fafa93",
  "paymentReference": "0x2c3366941274c34c",
  "subStatus": "insufficient_funds",
  "paymentProcessor": "request-network"
}

Compliance Updated

{
  "event": "compliance.updated",
  "clientUserId": "user_test123456789",
  "kycStatus": "approved",
  "agreementStatus": "completed",
  "isCompliant": true,
  "timestamp": "2025-10-03T14:30:00Z",
  "rawPayload": {
    "verificationLevel": "full",
    "documents": "verified"
  }
}

Implementation Examples

For a complete working example, see the EasyInvoice demo which implements webhook handling for payment notifications.
  • Express.js
  • Next.js
import express from "express";
import crypto from "node:crypto";

const app = express();
const WEBHOOK_SECRET = process.env.WEBHOOK_SECRET;

app.use(express.json());

app.post("/webhook/payment", async (req, res) => {
  try {
    // Verify signature
    const signature = req.headers["x-request-network-signature"];
    const expectedSignature = crypto
      .createHmac("sha256", WEBHOOK_SECRET)
      .update(JSON.stringify(req.body))
      .digest("hex");

    if (signature !== expectedSignature) {
      return res.status(401).json({ error: "Invalid signature" });
    }

    // Check for test webhook
    const isTest = req.headers["x-request-network-test"] === "true";
    
    // Process webhook based on event type
    const { event, requestId } = req.body;
    
    switch (event) {
      case "payment.confirmed":
        await handlePaymentConfirmed(req.body);
        break;
      case "payment.processing":
        await handlePaymentProcessing(req.body);
        break;
      case "compliance.updated":
        await handleComplianceUpdate(req.body);
        break;
      default:
        console.log(`Unhandled event: ${event}`);
    }

    return res.status(200).json({ success: true });
    
  } catch (error) {
    console.error("Webhook processing error:", error);
    return res.status(500).json({ error: "Processing failed" });
  }
});

Testing

Portal Testing

  1. Go to Platform Settings โ†’ Webhooks in Request Portal
  2. Create a webhook if you havenโ€™t already
  3. Select the webhook event type and click Send test event
  4. Monitor your endpoint logs for test requests

Test Webhook Identification

Test webhooks include the x-request-network-test: true header:
app.post("/webhook", (req, res) => {
  const isTest = req.headers["x-request-network-test"] === "true";
  
  if (isTest) {
    console.log("Received test webhook");
    // Handle test scenario
  }
  
  // Process normally...
});

Best Practices

Error Handling

  • Implement idempotency: Use delivery IDs to prevent duplicate processing
  • Graceful degradation: Handle unknown event types without errors

Performance

  • Timeout management: Complete processing within 5 seconds

Troubleshooting

Common Issues

Signature verification fails:
  • Check your signing secret matches Portal configuration
  • Ensure youโ€™re using the raw request body for signature calculation
  • Verify HMAC SHA-256 implementation
Webhooks not received:
  • Confirm endpoint URL is accessible via HTTPS
  • Verify endpoint returns 2xx status codes

Debugging Tips

  • Use ngrok request inspector to see raw webhook data
  • Monitor retry counts in headers to identify issues
  • Test with Portalโ€™s โ€œSend test webhooksโ€ feature
โŒ˜I