Skip to main content

Overview

This guide walks you through creating your first offramp transaction.

Prerequisites

  • A StablePay partner account
  • Your API key (get it from the Dashboard)
  • A webhook endpoint to receive notifications

Step 1: Create a User

First, create a user who will receive the INR payout:
curl -X POST https://api.stablepay.global/v2/users \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Rahul Kumar",
    "mobile": "+919876543210",
    "email": "[email protected]",
    "externalId": "user_123",
    "deviceId": "device-fingerprint-12345"
  }'
Response:
{
  "success": true,
  "data": {
    "userId": "usr_abc123",
    "depositAddresses": {
      "evm": "0x742d35Cc6634C0532925a3b844Bc9e7595f3A123",
      "solana": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"
    },
    "kycStatus": "pending"
  }
}

Step 2: Complete KYC

The user must complete KYC before they can receive payouts. Use our KYC APIs to verify: 1. Aadhaar via DigiLocker (Required)
curl -X POST https://api.stablepay.global/v2/users/usr_abc123/kyc/digilocker/init \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"deviceId": "device-fingerprint-12345"}'
Redirect the user to the returned redirectUrl to complete DigiLocker verification. 2. PAN Verification (Required)
curl -X POST https://api.stablepay.global/v2/users/usr_abc123/kyc/pan/verify \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "panNumber": "ABCDE1234F",
    "deviceId": "device-fingerprint-12345"
  }'
3. Bank Account Verification (Required)
curl -X POST https://api.stablepay.global/v2/users/usr_abc123/kyc/bank/verify \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountNumber": "1234567890",
    "ifsc": "HDFC0001234",
    "accountHolderName": "Rahul Kumar",
    "deviceId": "device-fingerprint-12345"
  }'
You’ll receive a webhook when KYC is complete:
{
  "event": "user.kyc_updated",
  "timestamp": "2025-01-05T10:30:00Z",
  "data": {
    "userId": "usr_abc123",
    "kyc": {
      "level": "basic",
      "status": "verified"
    }
  }
}
See the KYC Flow Guide for detailed API documentation.

Step 3: Create a Transaction

Once KYC is verified, create a transaction. Each transaction requires a unique idempotency key (UUID) to prevent duplicates:
curl -X POST https://api.stablepay.global/v2/transactions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "userId": "usr_abc123",
    "amount": "100",
    "asset": "USDC",
    "network": "polygon"
  }'
Generate a new UUID for each transaction request.
Response:
{
  "success": true,
  "data": {
    "transactionId": "txn_xyz789",
    "depositAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f3A123",
    "depositNetwork": "polygon",
    "depositAsset": "USDC",
    "expectedAmount": "100",
    "quote": {
      "exchangeRate": 84.50,
      "grossInr": "8450.00",
      "netInr": "8407.75"
    },
    "expiresAt": "2025-01-06T10:30:00Z"
  }
}

Step 4: Deposit Stablecoins

Send stablecoins to the deposit address. Our system detects the deposit automatically. Webhook - Deposit Detected:
{
  "event": "transaction.deposit_detected",
  "timestamp": "2025-01-05T10:35:00Z",
  "data": {
    "transactionId": "txn_xyz789",
    "deposit": {
      "amount": "100",
      "asset": "USDC",
      "network": "polygon",
      "txHash": "0x123...",
      "confirmations": 1
    }
  }
}

Step 5: Automatic Payout

Once the deposit reaches required confirmations (30 for Polygon), we automatically initiate the INR payout: Webhook - Payout Completed:
{
  "event": "transaction.payout_completed",
  "timestamp": "2025-01-05T10:40:00Z",
  "data": {
    "transactionId": "txn_xyz789",
    "payout": {
      "amount": "8407.75",
      "currency": "INR",
      "status": "completed",
      "utr": "123456789012"
    }
  }
}

Complete Flow Diagram

Next Steps