PeerTupeer API

PeerTupeer API

v1.0  ·  REST  ·  JSON  ·  Gift Card Trading & Purchasing

Introduction

The PeerTupeer API gives developers and businesses programmatic access to buy gift cards, submit gift card trades, check balances, and manage webhooks. All responses are JSON.

There are two main flows:

Authentication

Every request requires two headers:

HeaderRequiredDescription
X-API-KeyRequiredYour API key from the Merchant Dashboard
X-API-UsernameOptionalYour merchant slug or business email. Adds an extra layer of security when provided.

Example headers

X-API-Key: ptp_live_abc123xyz...
X-API-Username: yourcompany
Key types: Live keys start with ptp_live_. Sandbox keys start with ptp_test_ — use them to test without real transactions or wallet charges.

Generate keys at https://app.peertupeer.com/merchant/api-keys

Base URL

https://app.peertupeer.com/api/v1

Quick Start — Buy a Gift Card

The fastest way to integrate: get your API key, pick a product, and place an order. Poll for the card code once it's ready.

<?php
$apiKey      = 'ptp_live_YOUR_KEY';
$apiUsername = 'your-merchant-slug';  // optional
$base        = 'https://app.peertupeer.com/api/v1';

// Step 1 — List available gift card products
$ch = curl_init($base . '/gift-cards');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'X-API-Key: '      . $apiKey,
        'X-API-Username: ' . $apiUsername,
    ],
]);
$products = json_decode(curl_exec($ch), true);
curl_close($ch);

// Step 2 — Purchase a $50 Amazon USA card
$ch = curl_init($base . '/gift-cards');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS     => json_encode([
        'product_id' => 1,      // Amazon
        'country'    => 'USA',
        'currency'   => 'USD',
        'face_value' => 50,
        'quantity'   => 1,
    ]),
    CURLOPT_HTTPHEADER     => [
        'X-API-Key: '      . $apiKey,
        'X-API-Username: ' . $apiUsername,
        'Content-Type: application/json',
    ],
]);
$order = json_decode(curl_exec($ch), true);
curl_close($ch);
$ref = $order['data']['reference'];  // e.g. "GCAXXXXXXXX"

// Step 3 — Poll until ready (usually < 5 minutes)
do {
    sleep(10);
    $ch = curl_init($base . '/purchase-status?reference=' . $ref);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER     => [
            'X-API-Key: '      . $apiKey,
            'X-API-Username: ' . $apiUsername,
        ],
    ]);
    $status = json_decode(curl_exec($ch), true);
    curl_close($ch);
} while (!$status['data']['ready']);

$cardCode = $status['data']['cards'][0]['code'];
echo "Card code: " . $cardCode;

Error Handling

All errors return success: false with an HTTP status code and a message.

CodeMeaning
400Bad request — missing or invalid parameters
401Invalid or missing API key / username mismatch
402Insufficient wallet balance
404Resource not found
409Conflict — e.g. duplicate reference
422Validation error — see message for details
500Server error
// Error response example
{
  "success": false,
  "message": "Insufficient merchant wallet balance. Need GHS 155.00, have GHS 50.00."
}

GET /gift-cards — List Products

Returns all available gift card products with rates and pricing. No auth required for this endpoint, but API key enables per-merchant pricing.

GET/api/v1/gift-cards
curl 'https://app.peertupeer.com/api/v1/gift-cards' \
  -H 'X-API-Key: ptp_live_YOUR_KEY' \
  -H 'X-API-Username: your-slug'

Response

{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "Amazon",
      "slug": "amazon",
      "category": "retail",
      "image_url": "https://app.peertupeer.com/uploads/gift_cards/amazon.png",
      "rate_count": 3,
      "min_rate_ghs": 14.5,
      "stock_available": 0
    }
  ]
}

POST /gift-cards — Purchase a Card

Places a gift card order. The total GHS amount is deducted from your merchant wallet immediately. The card code is delivered within 5 minutes — poll /purchase-status or listen for the purchase.fulfilled webhook.

POST/api/v1/gift-cards
ParameterTypeRequiredDescription
product_idintegerYesProduct ID from GET /gift-cards
countrystringYesCountry code e.g. "USA", "UK", "Canada"
currencystringYesCurrency e.g. "USD", "GBP"
face_valuefloatYesCard denomination e.g. 10, 25, 50, 100
quantityintegerNoNumber of cards (default 1, max 10)
curl -X POST 'https://app.peertupeer.com/api/v1/gift-cards' \
  -H 'X-API-Key: ptp_live_YOUR_KEY' \
  -H 'X-API-Username: your-slug' \
  -H 'Content-Type: application/json' \
  -d '{"product_id":1,"country":"USA","currency":"USD","face_value":50,"quantity":1}'

Response

{
  "success": true,
  "message": "Order placed. Card will be ready within 5 minutes.",
  "data": {
    "reference":   "GCAXXXXXXXX",
    "purchase_id": 42,
    "status":      "pending",
    "card_status": "pending",
    "quantity":    1,
    "face_value":  50,
    "currency":    "USD",
    "country":     "USA",
    "buy_rate":    14.5,
    "base_ghs":    725.00,
    "fee_ghs":     18.13,
    "total_ghs":   743.13,
    "note": "Poll GET /api/v1/purchase-status?reference=GCAXXXXXXXX"
  }
}

GET /purchase-status — Card Readiness

Poll this endpoint after placing an order to check when the card code is ready. Alternatively, set up a purchase.fulfilled webhook to receive a push notification.

GET/api/v1/purchase-status?reference=GCAXXXXXXXX
curl 'https://app.peertupeer.com/api/v1/purchase-status?reference=GCAXXXXXXXX' \
  -H 'X-API-Key: ptp_live_YOUR_KEY'

Response when ready

{
  "success": true,
  "message": "Card is ready.",
  "data": {
    "reference":   "GCAXXXXXXXX",
    "card_status": "ready",
    "ready":       true,
    "cards": [
      { "code": "XXXX-XXXX-XXXX-XXXX", "pin": null, "expiry": null }
    ]
  }
}

// Response when still pending
{
  "success": true,
  "message": "Card is being processed.",
  "data": { "reference": "GCAXXXXXXXX", "card_status": "pending", "ready": false }
}

GET /rates — Exchange Rates

Returns all active buy/sell rates. No authentication required.

GET/api/v1/rates

POST /trades — Submit Trade (Sell)

Submit a gift card for review and receive GHS payout once approved. Requires multipart form data with card images.

POST/api/v1/trades
ParameterTypeRequiredDescription
card_type_idintegerYesCard type ID from /rates
countrystringYes"USA", "UK", "Canada" etc.
currencystringYes"USD", "GBP" etc.
card_amountfloatYesFace value of card
front_imagefileYesFront image (JPG/PNG, max 10MB)
back_imagefileYesBack image (JPG/PNG, max 10MB)
quantityintegerNoNumber of cards (default 1)
card_numberstringNoCard number/PIN if available
receipt_imagefileNoPurchase receipt
notesstringNoAdditional notes
curl -X POST 'https://app.peertupeer.com/api/v1/trades' \
  -H 'X-API-Key: ptp_live_YOUR_KEY' \
  -F 'card_type_id=1' \
  -F 'country=USA' \
  -F 'currency=USD' \
  -F 'card_amount=100' \
  -F 'front_image=@/path/to/front.jpg' \
  -F 'back_image=@/path/to/back.jpg'

Response

{
  "success": true,
  "data": {
    "reference":        "PTP1A2B3C4D5E",
    "status":           "pending",
    "card_amount":      100,
    "currency":         "USD",
    "gross_payout_ghs": 850.00,
    "fee_ghs":          21.25,
    "net_payout_ghs":   828.75
  }
}

GET /trade-status — Check Trade

GET/api/v1/trade-status?reference=PTP...
curl 'https://app.peertupeer.com/api/v1/trade-status?reference=PTP1A2B3C4D5E' \
  -H 'X-API-Key: ptp_live_YOUR_KEY'

GET /wallet — Balance

GET/api/v1/wallet
curl 'https://app.peertupeer.com/api/v1/wallet' \
  -H 'X-API-Key: ptp_live_YOUR_KEY'

Response

{
  "success": true,
  "data": {
    "currency":          "GHS",
    "available_balance": 5420.00,
    "pending_balance":   250.00,
    "total_earned":      18000.00,
    "total_withdrawn":   12580.00
  }
}

POST /withdrawals — Request Withdrawal

Withdraw your merchant wallet balance via Mobile Money or bank transfer.

POST/api/v1/withdrawals
ParameterTypeRequiredDescription
amountfloatYesAmount in GHS
methodstringYesmtn_momo, telecel_cash, airtel_tigo, bank_transfer
account_namestringYesName on the account
account_numberstringYesPhone or account number
bank_namestringCond.Required for bank_transfer
curl -X POST 'https://app.peertupeer.com/api/v1/withdrawals' \
  -H 'X-API-Key: ptp_live_YOUR_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"amount":500,"method":"mtn_momo","account_name":"John Doe","account_number":"0241234567"}'

Webhooks — Setup

Register a URL to receive real-time POST notifications when events happen. Create webhooks at https://app.peertupeer.com/merchant/webhooks.

Verifying Signatures

<?php
$payload   = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_PEERTUPEER_SIGNATURE'] ?? '';
$secret    = 'your_webhook_secret';

if (!hash_equals(hash_hmac('sha256', $payload, $secret), $signature)) {
    http_response_code(401);
    exit('Unauthorized');
}

$event = json_decode($payload, true);
$type  = $event['event'];  // e.g. "purchase.fulfilled"

if ($type === 'purchase.fulfilled') {
    $ref   = $event['data']['reference'];
    $cards = $event['data']['cards'];
    // Deliver card codes to your customer
}

Webhook Events

EventWhen it fires
trade.createdNew trade submitted via API
trade.processingTrade moved to Under Review or Processing
trade.completedTrade approved — wallet credited
trade.rejectedTrade rejected
withdrawal.completedWithdrawal paid out
withdrawal.rejectedWithdrawal rejected
purchase.fulfilledGift card order fulfilled — codes ready
rate.updatedAn exchange rate was updated

purchase.fulfilled Payload

{
  "event":     "purchase.fulfilled",
  "timestamp": 1717000000,
  "data": {
    "reference":    "GCAXXXXXXXX",
    "product_id":   1,
    "country":      "USA",
    "currency":     "USD",
    "face_value":   50,
    "quantity":     1,
    "total_ghs":    743.13,
    "fulfilled_at": "2026-06-01 14:30:00",
    "cards": [
      { "code": "XXXX-XXXX-XXXX-XXXX", "pin": null, "expiry": null }
    ]
  }
}

Rate Update Subscriptions

Subscribe to get notified when exchange rates change.

POST/api/v1/rate-updates
curl -X POST 'https://app.peertupeer.com/api/v1/rate-updates' \
  -H 'X-API-Key: ptp_live_YOUR_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"url":"https://yoursite.com/webhooks/rates"}'

Sandbox Testing

Use keys prefixed with ptp_test_ to test. No real wallet charges. Card codes return as SANDBOX-XXXXXXXX-TEST.
GET/api/v1/sandbox?action=test-cards
curl 'https://app.peertupeer.com/api/v1/sandbox?action=test-cards' \
  -H 'X-API-Key: ptp_test_YOUR_SANDBOX_KEY'

Need help? Contact support@peertupeer.com or message us on WhatsApp.