# Batch Gateway Creation - JSON Format

## Example Format

```json
[
  {
    "slug": "crypto-news-api",
    "targetApiUrl": "https://api.rumour.app/automatch.v1.RumourService/ListRumour",
    "httpMethod": "POST",
    "paymentAmount": "0.01",
    "payTo": "0xAb4cE88Db0277E05CFb5eeb346F6dfb635950eD0",
    "network": "base",
    "credits": 500,
    "description": "Crypto news and rumors API",
    "requestHeaders": {
      "Content-Type": "application/json",
      "Accept": "application/json"
    },
    "requestBody": {
      "pageNumber": 1,
      "pageSize": 10
    }
  },
  {
    "slug": "weather-api",
    "targetApiUrl": "https://api.weather.com/v1/forecast",
    "httpMethod": "GET",
    "paymentAmount": "0.05",
    "payTo": "0xAb4cE88Db0277E05CFb5eeb346F6dfb635950eD0",
    "network": "base",
    "credits": 5000,
    "description": "Weather forecast API"
  },
  {
    "slug": "free-trial-api",
    "targetApiUrl": "https://api.example.com/v1/data",
    "httpMethod": "GET",
    "paymentAmount": "0.01",
    "payTo": "0xAb4cE88Db0277E05CFb5eeb346F6dfb635950eD0",
    "network": "base",
    "credits": 10,
    "description": "Free trial API with 10 requests"
  }
]
```

## Field Descriptions

- **slug** (required): Unique gateway identifier (lowercase, numbers, hyphens only)
- **targetApiUrl** (required): The API endpoint to proxy requests to
- **httpMethod** (required): HTTP method - either "GET" or "POST"
- **paymentAmount** (required): Payment amount in USDC (e.g., "0.01" = 0.01 USDC, minimum 0.01)
- **payTo** (required): Ethereum address where payments will be sent
- **network** (required): Blockchain network (currently only "base" is supported)
- **credits** (optional): Number of API requests/credits for this gateway (default: 10)
  - **10 credits** (FREE): No platform fee
  - **< 1,000 credits** (BASIC): Uses 1,000 req / 0.99 USDC ratio (e.g., 500 credits = 0.495 USDC)
  - **≥ 1,000 credits** (PRO): Uses 1,000 req / 0.49 USDC ratio (e.g., 1,000 credits = 0.49 USDC, 5,000 credits = 2.45 USDC)
- **description** (optional): Human-readable description of the gateway
- **requestHeaders** (optional): Custom headers for POST requests (JSON object)
- **requestBody** (optional): Default request body for POST requests (JSON object)

## Credit Tiers & Pricing

Each gateway has a prepaid credit system that determines the number of API requests it can handle:

| Tier | Credits | Platform Fee | Notes |
|------|---------|--------------|-------|
| FREE | ≤ 10 | Free | $0 |
| BASIC | 11-1,000 | **FLAT 0.99 USDC** | Same price regardless of exact count |
| PRO | > 1,000 | 0.49 USDC / 1,000 | $0.00049 per request |

**Pricing Examples:**
- **10 requests or less**: FREE (no payment required)
- **11 requests**: **$0.99 USDC** (Basic tier flat rate)
- **100 requests**: **$0.99 USDC** (Basic tier flat rate)
- **500 requests**: **$0.99 USDC** (Basic tier flat rate)
- **1,000 requests**: **$0.99 USDC** (Basic tier flat rate)
- **5,000 requests**: 5,000 × $0.00049 = **$2.45 USDC** (Pro tier)
- **10,000 requests**: 10,000 × $0.00049 = **$4.90 USDC**

**Batch Creation Examples:**
- 3 gateways with 10 credits each = **0 USDC** (all free)
- 2 gateways with 500 credits each = **$1.98 USDC** ($0.99 × 2)
- 1 gateway with 500 credits + 1 gateway with 5,000 credits = **$3.44 USDC** ($0.99 + $2.45)
- 1 gateway with 10,000 credits = **$4.90 USDC** (10,000 × $0.00049)

## Notes

- **Total cost** = sum of platform fees for all gateways based on their credit tiers
- All gateways in a batch must have unique slugs
- Headers and body are only applicable for POST requests
- Payment amounts must be at least 0.01 USDC
- Credits default to 10 (FREE tier) if not specified
- Once credits are exhausted, the gateway will return a 402 Payment Required status

## Batch Creation Bonus

**When creating gateways via batch, any gateway with 11-1000 credits specified will automatically receive 1,000 credits!**

This means:
- Specify 50 credits → Pay $0.99 → **Receive 1,000 credits**
- Specify 500 credits → Pay $0.99 → **Receive 1,000 credits**
- Specify 1,000 credits → Pay $0.99 → **Receive 1,000 credits**

This batch creation bonus gives you maximum value when purchasing multiple gateways at once.
