# x402-manifest-from-openapi

> Turn an OpenAPI 3.x / Swagger 2.0 spec (JSON or YAML, URL or inline) into a ready-to-mount x402 V2 paywall: per-operation accepts[] (exact, CAIP-2 network, atomic USDC amount, payTo, EIP-712 extra), @x402/core route config, Bazaar discovery input/output schemas, a /.well-known/x402 document and a sample PAYMENT-REQUIRED payload.

- URL: https://forge-tools.dentreprise.workers.dev/api/x402-manifest-from-openapi (GET or POST)
- Price: 0.003 USDC on Base (3000 atomic USDC)
- MCP tool: x402_manifest_from_openapi
- Docs: https://agent-hub.dentreprise.workers.dev/tools/x402-manifest-from-openapi/

## Parameters

- `url` (string): OpenAPI URL
- `spec` (object): Inline spec (POST)
- `payTo` (string, required): Receiving address
- `price` (string): Default USD price per call
- `prices` (string): JSON map {"GET /path": 0.002}
- `network` (string): CAIP-2, default eip155:8453
- `base_url` (string): Override server URL

## Unpaid example

```bash
curl -sS -D - "https://forge-tools.dentreprise.workers.dev/api/x402-manifest-from-openapi?url=https%3A%2F%2Fpetstore3.swagger.io%2Fapi%2Fv3%2Fopenapi.json&payTo=0x7B8bf45ac6AcbA6D4CFB626b57D3f5fF3C9C89F7&price=0.001"
```

## Example 402 challenge

```json
{
  "x402Version": 2,
  "error": "Payment required",
  "resource": {
    "url": "https://forge-tools.dentreprise.workers.dev/api/x402-manifest-from-openapi",
    "description": "Turn an OpenAPI 3.x / Swagger 2.0 spec (JSON or YAML, URL or inline) into a ready-to-mount x402 V2 paywall: per-operation accepts[] (exact, CAIP-2 network, atomic USDC amount, payTo, EIP-712 extra), @x402/core route config, Bazaar discovery input/output schemas, a /.well-known/x402 document and a sample PAYMENT-REQUIRED payload.",
    "mimeType": "application/json"
  },
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "amount": "3000",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "payTo": "0x7B8bf45ac6AcbA6D4CFB626b57D3f5fF3C9C89F7",
      "maxTimeoutSeconds": 120,
      "extra": {
        "name": "USD Coin",
        "version": "2"
      }
    }
  ]
}
```

## Example response

```json
{
  "operations": 19,
  "routes": [
    {
      "method": "GET",
      "path": "/pet/{petId}",
      "accepts": [
        {
          "scheme": "exact",
          "amount": "1000"
        }
      ]
    }
  ],
  "well_known_x402": {
    "version": 1,
    "resources": []
  }
}
```

## Free demo / sample

This tool accepts `?demo=1` on the wave-1 worker (labelled sample, HTTP 200, not live data). The first 3 successful real calls per IP per UTC day are also free.

```bash
curl -sS "https://forge-tools.dentreprise.workers.dev/api/x402-manifest-from-openapi?url=https%3A%2F%2Fpetstore3.swagger.io%2Fapi%2Fv3%2Fopenapi.json&payTo=0x7B8bf45ac6AcbA6D4CFB626b57D3f5fF3C9C89F7&price=0.001&demo=1"
```

```json
{
  "demo": true,
  "demo_label": "DEMO / SAMPLE — not live data. This is a labelled example response and was not charged.",
  "charged": false,
  "tool": "/api/x402-manifest-from-openapi",
  "docs": "https://agent-hub.dentreprise.workers.dev/tools/x402-manifest-from-openapi/",
  "how_to_get_live_data": "Call the same URL without demo=1. The first 3 successful real calls per IP per UTC day are free; after that attach an x402 v2 PAYMENT-SIGNATURE (USDC on Base).",
  "sample": {
    "operations": 19,
    "routes": [
      {
        "method": "GET",
        "path": "/pet/{petId}",
        "accepts": [
          {
            "scheme": "exact",
            "amount": "1000"
          }
        ]
      }
    ],
    "well_known_x402": {
      "version": 1,
      "resources": []
    }
  }
}
```

## Clients

- JS (x402 v2): `@x402/fetch` + `@x402/evm` (`wrapFetchWithPaymentFromConfig`, `ExactEvmScheme`). The older package `x402-fetch` is deprecated v1.
- Python: PyPI package `x402` (`x402HttpxClient` or `x402_requests`, `register_exact_evm_client`, `EthAccountSigner`).
- MCP: stdio `node src/server.mjs` in [forge-agent-mcp](https://github.com/forge-agent-hub/forge-agent-mcp); hosted Streamable HTTP at https://x402-gateway.forge-x402.workers.dev/mcp (original gateway tools).
- LangChain: wrap those clients with `DynamicStructuredTool` (`@langchain/core`) or `@tool` (`langchain_core`).
- Copy-paste snippets: https://agent-hub.dentreprise.workers.dev/tools/x402-manifest-from-openapi/ and https://agent-hub.dentreprise.workers.dev/quickstart/
