# Getting Started with 402ify

## Getting Started with 402ify

### Overview

402ify is an API monetization service that lets you create payment-protected endpoints (PayGates) for any API. It handles payment enforcement, blockchain verification (via x402-hub), and request proxying automatically.

### Base URL

* **Production**: `https://402ify.com`, `https://402.sigwei.com`

All management endpoints use `/api/v1/` prefix.

### Prerequisites

* **Wallet**: Ethereum-compatible wallet with private key
* **USDC Balance**: USDC on Base blockchain for creating PayGates
* **HTTP Client**: curl, axios, requests, or similar for API integration
* **Target API** (optional): The API endpoint you want to monetize

### Quick Start

#### 1. Authenticate with Wallet

402ify uses the same authentication as x402-hub (SIWE-based wallet signing).

```bash
# Get authentication message
curl "https://402ify.com/api/v1/auth/message?walletAddress=0xYOUR_WALLET"

# Sign the message with your wallet, then login
curl -X POST https://402ify.com/api/v1/auth/login \
     -H "Content-Type: application/json" \
     -d '{"message": "SIGNED_MESSAGE", "signature": "0xSIGNATURE"}'
```

Response includes access token for management API calls.

#### 2. Create a PayGate

Create a payment-protected proxy to your API:

```bash
curl -X POST https://402ify.com/api/v1/paygates \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "targetUrl": "https://api.example.com/premium-data",
    "method": "GET",
    "price": "0.01",
    "network": "base-sepolia",
    "paymentAddress": "0xYOUR_PAYMENT_ADDRESS",
    "title": "Premium API Access",
    "description": "Real-time data access"
  }'
```

Response:

```json
{
  "id": 1,
  "shortCode": "abc123",
  "accessUrl": "https://402ify.com/abc123",
  "price": "0.01",
  "method": "GET",
  "title": "Premium API Access"
}
```

#### 3. Access Your PayGate

When users access your PayGate URL, they'll receive a 402 Payment Required response:

```bash
curl https://402ify.com/abc123
```

Response:

```json
{
  "x402": {
    "token": "payment_token_here",
    "amount": "0.01",
    "address": "0xYOUR_PAYMENT_ADDRESS"
  }
}
```

After paying, they can access the protected resource:

```bash
curl https://402ify.com/abc123 \
  -H "X-Payment: payment_proof_here"
```

This proxies the request to your target URL and returns the response.

## Common Use Cases

### For API Providers

1. **Instant Monetization**: Turn any existing API into a paid service
2. **Flexible Pricing**: Set per-call or bulk pricing models
3. **No Code Changes**: Protect APIs without modifying existing code
4. **Analytics**: Track usage, revenue, and user behavior

### For Content Creators

1. **Paywall Content**: Monetize articles, videos, or premium resources
2. **Subscription Alternative**: One-time payments with multiple accesses
3. **Global Payments**: Accept USDC from users worldwide
4. **Instant Access**: No signup process, just API authentication via wallet signing

### For AI Agents

1. **Automated Payments**: AI agents can pay for API access programmatically
2. **Micropayments**: Cost-effective for small, frequent API calls
3. **No Traditional Payment Methods**: No credit cards or payment processors needed
4. **Instant Access**: Real-time payment and access without delays
