# x402 Payment & Agentic Commerce Endpoint Auditor (MCP Ready) (`cbum/x402-endpoint-auditor`) Actor

Bulk audit HTTP 402 (x402 v1/v2) paid APIs and domains. Decodes PAYMENT-REQUIRED headers, calculates exact USDC costs on Base & Solana, checks wallet/budget compatibility, and discovers .well-known A2A, MCP, OpenAPI & llms.txt manifests.

- **URL**: https://apify.com/cbum/x402-endpoint-auditor.md
- **Developed by:** [Kai-Chin Huang](https://apify.com/cbum) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 audited endpoint

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## x402 Payment & Agentic Commerce Endpoint Auditor (MCP Ready)

Bulk-inspect **HTTP 402 (`x402` v1 & v2)** machine-payable APIs and company domains before your AI agent signs a spending mandate—or audit thousands of domains to map the emerging **Agentic Commerce** ecosystem.

Built specifically for **autonomous AI agents (via Apify MCP Server)**, **x402 API developers**, **crypto/fintech researchers**, and **agent directory indexers**.

***

### What Does This Actor Do?

1. **Decodes `x402` v2 & v1 Payment Challenges**
   - Parses `PAYMENT-REQUIRED` (Base64 / Base64URL JSON headers), `X-PAYMENT-REQUIRED`, HTTP `402` JSON bodies, `/.well-known/x402`, and `WWW-Authenticate` (`L402`) headers.
2. **Calculates Exact USD / Stablecoin Costs (BigInt-Safe)**
   - Converts atomic token base units (e.g. `"10000"` on 6-decimal USDC) into exact human-readable decimals and USD prices across **Base**, **Solana**, **Ethereum**, **Arbitrum**, **OP Mainnet**, **Polygon**, and **Avalanche** (both Mainnet & Testnets via CAIP-2).
3. **Verifies Wallet & Budget Compatibility for AI Agents**
   - Checks whether an endpoint's accepted chains match your agent's `preferredNetworks` (e.g. `["base", "solana"]`) and whether `cheapestPriceUsd` fits within `maxPriceUsd`.
4. **Discovers `.well-known` Agentic Manifests**
   - Automatically probes each origin (cached once per domain) for:
     - `/.well-known/x402`
     - `/.well-known/agent.json` & `/.well-known/agent-card.json` (Google A2A Protocol)
     - `/.well-known/mcp.json` (Model Context Protocol)
     - `/openapi.json`
     - `/llms.txt`
5. **Validates Security & Spec Compliance**
   - Flags unencrypted `http://` mainnet payment challenges, malformed EVM (`0x...`) or Solana (Base58) `payTo` recipient addresses, unrecognized token contracts, and invalid timeouts.
6. **Outputs Token-Efficient Markdown Briefs**
   - Every dataset record includes a `markdownBrief` ready to feed directly into Claude, Gemini, GPT, Cursor, or custom MCP agents.

***

### Example Output Record

```json
{
  "url": "https://api.example.com/v2/enrich",
  "origin": "https://api.example.com",
  "httpStatus": 402,
  "isX402Detected": true,
  "x402Version": 2,
  "transportSource": "header:payment-required",
  "cheapestPriceUsd": 0.005,
  "supportedNetworks": ["Base Mainnet", "Solana Mainnet"],
  "budgetFit": true,
  "walletCompatible": true,
  "agentReadinessScore": 90,
  "paymentOptions": [
    {
      "scheme": "exact",
      "network": "Base Mainnet",
      "networkRaw": "eip155:8453",
      "networkSlug": "base",
      "caip2": "eip155:8453",
      "isTestnet": false,
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bda02913",
      "tokenSymbol": "USDC",
      "decimals": 6,
      "rawAmount": "5000",
      "humanAmount": "0.005",
      "usdEstimate": 0.005,
      "payTo": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
      "maxTimeoutSeconds": 60,
      "description": "Per-request enrichment fee",
      "mimeType": "application/json",
      "hasOutputSchema": true
    }
  ],
  "wellKnownDiscovery": {
    "x402Manifest": false,
    "a2aAgentCard": true,
    "a2aAgentName": "Example Data Agent",
    "mcpManifest": true,
    "openApiSpec": true,
    "llmsTxt": true,
    "detectedPaths": {
      "/.well-known/agent.json": true,
      "/.well-known/mcp.json": true,
      "/openapi.json": true,
      "/llms.txt": true
    }
  },
  "validationWarnings": [],
  "responseTimeMs": 118,
  "markdownBrief": "### https://api.example.com/v2/enrich\n- **HTTP Status:** 402 (118 ms) | **Agent Readiness:** 90/100\n- **x402 Protocol:** v2 via `header:payment-required` | **Min Price:** $0.005 USD\n- **Networks:** Base Mainnet, Solana Mainnet | **Wallet Match:** Yes | **Within Budget:** Yes\n- **Discovered Manifests:** /.well-known/agent.json, /.well-known/mcp.json, /openapi.json, /llms.txt",
  "auditedAt": "2026-11-29T22:20:00.000Z"
}
```

***

### Using with AI Agents (Apify MCP Server)

Connect this Actor directly to Claude Desktop, Cursor, Windsurf, or custom MCP clients via `https://mcp.apify.com`:

- **Pre-flight Cost Guardrail:** Ask your agent to audit an unknown x402 URL with `maxPriceUsd: 0.02` and `preferredNetworks: ["base"]` before authorizing payment.
- **Ecosystem Indexing:** Feed a list of 1,000 developer domains to discover which companies expose A2A Agent Cards, MCP manifests, or x402 paid APIs.

# Actor input Schema

## `urls` (type: `array`):

List of x402 API URLs or root domains (e.g. https://api.example.com/paid-endpoint or https://x402.org) to audit.

## `httpMethod` (type: `string`):

HTTP method sent to the primary target URL to trigger an HTTP 402 challenge without executing side effects where possible.

## `discoverWellKnown` (type: `boolean`):

Also probe /.well-known/x402, /.well-known/agent.json (A2A), /.well-known/agent-card.json, /.well-known/mcp.json, /openapi.json, and /llms.txt on each target's origin.

## `maxPriceUsd` (type: `number`):

Optional per-request USD budget ceiling (e.g. 0.05). Endpoints costing more than this threshold are flagged with budgetFit = false.

## `preferredNetworks` (type: `array`):

Optional list of networks your agent wallet supports (e.g. 'base', 'solana', 'eip155:8453', 'arbitrum'). Checks wallet compatibility.

## `concurrency` (type: `integer`):

Maximum number of URLs audited in parallel.

## `timeoutSecs` (type: `integer`):

Per-request HTTP timeout in seconds.

## `customHeaders` (type: `object`):

Optional custom HTTP headers sent with target probes (do NOT put wallet private keys here).

## Actor input object example

```json
{
  "urls": [
    "https://www.x402.org",
    "https://apify.com"
  ],
  "httpMethod": "GET",
  "discoverWellKnown": true,
  "preferredNetworks": [
    "base",
    "solana"
  ],
  "concurrency": 5,
  "timeoutSecs": 15
}
```

# Actor output Schema

## `dataset` (type: `string`):

All audited URLs with decoded x402 payment requirements, USDC prices, network support, readiness scores, and Markdown briefs.

## `summaryReport` (type: `string`):

Aggregated statistics across all audited URLs saved in the default Key-Value Store.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://www.x402.org",
        "https://apify.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("cbum/x402-endpoint-auditor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": [
        "https://www.x402.org",
        "https://apify.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("cbum/x402-endpoint-auditor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://www.x402.org",
    "https://apify.com"
  ]
}' |
apify call cbum/x402-endpoint-auditor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cbum/x402-endpoint-auditor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ssABdkcnvfQ0s02xF/builds/unmwyHEe3iL4NNaoS/openapi.json
