Skip to main content

Welcome to Request Network

Get started with Request Network in just a few minutes. This guide will walk you through setting up your account, obtaining API keys, and making your first payment.

Quick Setup

1

Create Account

Sign up for a free Request Network account at portal.request.network
2

Get API Keys

Generate your API keys from the portal dashboard
3

Create Your First Request

Use the API to create a payment request
4

Process Payment

Get payment calldata and execute the transaction

Account Setup

Request Portal Registration

Create Your Account

Sign up at portal.request.network to get started. All accounts include:
  • Free API access with generous limits
  • API documentation and tools
  • Community support

API Key Generation

  1. Log in to Request Portal
  2. Navigate to “API Keys” section
  3. Click “Create new key”
  4. Copy and securely store the key
Security Best Practices
  • Store API keys in environment variables
  • Never commit keys to version control
  • Rotate keys regularly

Your First Integration

Let’s create a simple Node.js server that integrates with the Request Network API to create payments and track their status.

Project Setup

Create a new project and install dependencies:
mkdir request-api-demo
cd request-api-demo
npm init -y
npm install dotenv
Create a .env file:
RN_API_KEY=your_api_key_here
RN_API_URL=https://api.request.network/v2

Create a Payment

Create an index.js file:
require('dotenv').config();

async function createPayment() {
  try {
    const response = await fetch(`${process.env.RN_API_URL}/payouts`, {
      method: 'POST',
      headers: {
        'X-Api-Key': process.env.RN_API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        payee: '0x...', // Your wallet address
        amount: '0.1',
        invoiceCurrency: 'ETH-sepolia-sepolia',
        paymentCurrency: 'ETH-sepolia-sepolia'
      })
    });

    if (!response.ok) {
      const errorText = await response.text();
      console.error('API Error:', errorText);
      return;
    }

    const data = await response.json();
    console.log('Payment created:', {
      requestId: data.requestId,
      paymentReference: data.paymentReference,
      transactions: data.transactions,
      metadata: data.metadata
    });
    
    return data;
    
  } catch (error) {
    console.error('Error:', error.message);
  }
}

createPayment();
Run it:
node index.js
The response will include:
  • requestId — Unique identifier for the request
  • paymentReference — Used to track the payment
  • transactions — Array of transaction calldata to execute
  • metadata — Additional info like stepsRequired and needsApproval

Understanding the Response

{
  "requestId": "011d9f76e07a678b8321ccfaa300efd4d80832652b8bbc07ea4069ca71006210b5",
  "paymentReference": "0xe23a6b02059c2b30",
  "transactions": [
    {
      "data": "0xb868980b000000000000000000000000...",
      "to": "0xe11BF2fDA23bF0A98365e1A4c04A87C9339e8687",
      "value": {
        "type": "BigNumber",
        "hex": "0x02c68af0bb140000"
      }
    }
  ],
  "metadata": {
    "stepsRequired": 1,
    "needsApproval": false,
    "paymentTransactionIndex": 0
  }
}
Note: The amount is in human-readable format. No BigNumber conversions needed!

Setting Up Webhooks

To track payment status in real-time, set up a webhook endpoint:
const crypto = require('crypto');

// Webhook handler
app.post('/webhooks', async (req, res) => {
  const signature = req.headers['x-request-network-signature'];
  const webhookSecret = process.env.RN_WEBHOOK_SECRET;

  // Verify signature
  const expectedSignature = crypto
    .createHmac('sha256', webhookSecret)
    .update(JSON.stringify(req.body))
    .digest('hex');

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

  const { requestId, event } = req.body;
  console.log(`Webhook: ${event} for request ${requestId}`);
  
  // Handle different events
  switch (event) {
    case 'payment.confirmed':
      console.log('Payment confirmed!');
      // Update your database, send email, etc.
      break;
    case 'payment.pending':
      console.log('Payment pending...');
      break;
  }

  res.send({ code: 200, message: 'Webhook received' });
});

Testing Webhooks Locally

Since webhooks can’t reach your local server directly, use ngrok:
ngrok http 3000
Copy the HTTPS URL (e.g., https://abc123.ngrok.io/webhooks) and add it in the API Portal under Webhooks section. Copy the webhook signing secret to your .env:
RN_WEBHOOK_SECRET=your_webhook_secret_here

Environment Configuration

Set up environment variables for secure API key management:
# Request Network Configuration
RN_API_KEY=your_api_key_here
RN_API_URL=https://api.request.network/v2

# Webhook Configuration (optional)
RN_WEBHOOK_SECRET=your_webhook_secret_here

What’s Next?

Now that you’ve made your first API call, explore more features:

📚 API Features

Learn about different payment types and features

🔍 Payment Detection

Understand how payments are tracked

⚡ Integration Tutorial

Complete tutorial with backend + frontend

Troubleshooting

Common Issues

  • Verify API key is correct
  • Check that you’re using the right header: X-Api-Key
  • Ensure the key hasn’t been revoked
  • Check required fields: payee, amount, invoiceCurrency, paymentCurrency
  • Ensure amount is a string (e.g., “0.1”)
  • Verify currency IDs are valid
  • Verify webhook URL is publicly accessible
  • Check webhook signature verification
  • Ensure webhook is enabled in the portal
You’re all set! You’ve created your first payment request with Request Network. For a complete working example with frontend, check out the Integration Tutorial.