Synapse Logo

Synapse x402 Explorer

Explorer for PayAI Facilitator

API Documentation

Complete guide to integrate Synapse Merchant token-based payment system

Quick Start

Get started in 3 simple steps

1

Purchase Service

Create payment request and pay via PayAI

2

Get Token

Verify payment and receive access token

3

Make Requests

Use token to access RPC and transaction services

Base URL

https://merchant.synapse.network

Payment Flow

Purchase services and receive access tokens

POST
/api/payments/create

Create a payment request for a specific service

Request Body
{
  "sessionId": "sess_abc123",
  "serviceType": "rpc_call",
  "tier": "basic",
  "clientPublicKey": "YourSolanaPublicKey..."
}
Response
{
  "success": true,
  "paymentUrl": "https://facilitator.payai.network/pay/req_xyz",
  "amountSOL": 0.002,
  "expiresAt": "2024-01-15T12:00:00Z"
}
ACTION
Complete Payment via PayAI

Open the paymentUrl and complete the on-chain payment

POST
/api/payments/verify

Verify the payment was completed successfully

Request Body
{
  "sessionId": "sess_abc123",
  "signature": "5k2n8m..."
}
Response
{
  "success": true,
  "receipt": {
    "receiptId": "rcpt_def456",
    "servicePurchased": "rpc_call",
    "quantityPurchased": 100,
    "verified": true
  }
}
POST
/api/tokens/create

Generate access token from verified receipt

Request Body
{
  "receiptId": "rcpt_def456",
  "label": "MyAIAgent - RPC Access"
}
Response
{
  "success": true,
  "token": {
    "token": "mt_live_48a8b3c9d1e2f3g4h5i6j7k8l9m0n1o2",
    "remainingLamports": 2000000,
    "remainingRequests": 100,
    "rpsLimit": 10,
    "active": true
  }
}

Using Tokens

Make authenticated requests with your access token

POST
/api/ai/rpc

Execute Solana RPC method calls

Headers
Authorization: Bearer mt_live_48a8b3c9d1e2f3g4h5i6j7k8l9m0n1o2
Request Body
{
  "method": "getAccountInfo",
  "params": ["YourAccountPublicKey..."]
}
Response
{
  "success": true,
  "result": {
    "lamports": 1000000,
    "owner": "11111111111111111111111111111111"
  },
  "cost": 20000,
  "remaining": {
    "lamports": 1980000,
    "requests": 99
  }
}
POST
/api/ai/transaction

Send Solana transactions with priority

Request Body
{
  "transaction": "base64-encoded-transaction",
  "options": {
    "skipPreflight": false
  }
}
Response
{
  "success": true,
  "signature": "5k2n8m...",
  "cost": 1000000,
  "remaining": {
    "lamports": 980000,
    "requests": 98
  }
}

Token Management

Manage your access tokens

GET
/api/tokens/info

Get current token balance and rate limits

Response
{
  "success": true,
  "token": {
    "remainingLamports": 1980000,
    "remainingRequests": 99,
    "rpsLimit": 10,
    "rpmLimit": 600,
    "active": true
  }
}
POST
/api/tokens/refill

Top-up existing token with additional balance

Request Body
{
  "token": "mt_live_48a8b3c9d1e2f3g4h5i6j7k8l9m0n1o2",
  "receiptId": "rcpt_ghi789"
}
POST
/api/tokens/revoke

Permanently disable a token

Request Body
{
  "token": "mt_live_48a8b3c9d1e2f3g4h5i6j7k8l9m0n1o2"
}

Pricing

Instance-based pricing with volume discounts

RPC Calls

Basic tier

20k lamports
per call
  • 10 RPS limit
  • 100% markup
Popular

Priority TX

Premium tier

1M lamports
per transaction
  • Fast confirmation
  • 100% markup

AI Analysis

Enterprise tier

100M lamports
per analysis
  • Advanced AI
  • 900% markup

Volume Discounts

10+ instances
-5%
100+ instances
-10%
1000+ instances
-20%

Error Handling

401
Unauthorized
{
  "success": false,
  "error": "Missing or invalid authorization header"
}
402
Insufficient Balance
{
  "success": false,
  "error": "Insufficient balance",
  "remaining": {
    "lamports": 5000,
    "required": 20000
  }
}
429
Rate Limit Exceeded
{
  "success": false,
  "error": "Rate limit exceeded",
  "retryAfter": 1000
}

Code Examples

Integration examples in popular languages

TypeScript / JavaScript
import axios from 'axios';

const client = axios.create({
  baseURL: 'https://merchant.synapse.network',
  headers: {
    'Authorization': 'Bearer mt_live_48a8b3c9d1e2f3g4h5i6j7k8l9m0n1o2'
  }
});

// Make RPC call
const { data } = await client.post('/api/ai/rpc', {
  method: 'getAccountInfo',
  params: ['YourPublicKey...']
});

console.log('Result:', data.result);
console.log('Remaining:', data.remaining);
Python
import requests

client = requests.Session()
client.headers.update({
    'Authorization': 'Bearer mt_live_48a8b3c9d1e2f3g4h5i6j7k8l9m0n1o2'
})

# Make RPC call
response = client.post(
    'https://merchant.synapse.network/api/ai/rpc',
    json={
        'method': 'getAccountInfo',
        'params': ['YourPublicKey...']
    }
)

data = response.json()
print('Result:', data['result'])
print('Remaining:', data['remaining'])

Need Help?

For technical support, questions, or feedback: