### Install dependencies Source: https://the402.ai/docs/agents Install the required x402 and Coinbase CDP SDK packages. ```bash npm install x402 @coinbase/cdp-sdk ``` -------------------------------- ### Run the API locally Source: https://the402.ai/docs/agents Commands to clone the repository, install dependencies, configure the testnet environment, and start the local development server. ```bash git clone https://github.com/the402ai/the402 cd the402-api npm install # Set testnet config in .dev.vars # NETWORK=base-sepolia # PAY_TO=0xYourTestWallet npx wrangler dev --port 8787 ``` -------------------------------- ### Install x402 Client Source: https://the402.ai/docs Install the required SDK package via npm. ```bash npm install @coinbase/x402 ``` -------------------------------- ### GET /v1/purchases Source: https://the402.ai/docs/agents List your product purchases. ```APIDOC ## GET /v1/purchases ### Description List your product purchases. Requires X-API-Key header. ### Method GET ### Endpoint /v1/purchases ``` -------------------------------- ### GET /v1/products/:productId/download Source: https://the402.ai/docs/agents Download a purchased product file. ```APIDOC ## GET /v1/products/:productId/download ### Description Download a purchased product file. Requires X-API-Key header. Returns 403 if download limit reached. ### Method GET ### Endpoint /v1/products/:productId/download ### Parameters #### Path Parameters - **productId** (string) - Required - The ID of the product to download ``` -------------------------------- ### POST /v1/discover Source: https://the402.ai/docs/agents Returns the full service catalog and a getting-started guide for agent bootstrapping. ```APIDOC ## POST /v1/discover ### Description Returns the full service catalog plus a getting-started guide with platform context. ### Method POST ### Endpoint /v1/discover ``` -------------------------------- ### GET /v1/plans Source: https://the402.ai/docs/agents Browse available subscription plans. ```APIDOC ## GET /v1/plans ### Description Browse available subscription plans. Returns plan name, description, interval, bundled service IDs, and pricing. ### Method GET ### Endpoint /v1/plans ### Parameters #### Query Parameters - **provider** (string) - Optional - Filter by provider wallet ``` -------------------------------- ### Point agent at localhost Source: https://the402.ai/docs/agents Example of fetching the service catalog and purchasing a service using a local API instance. ```javascript // Use localhost instead of api.the402.ai const catalog = await fetch("http://localhost:8787/v1/services/catalog?q=ssl+check"); const { services } = await catalog.json(); const resp = await the402Fetch( `http://localhost:8787/v1/services/${services[0].id}/purchase`, account, { method: "POST", body: JSON.stringify({ site_url: "https://example.com" }) } ); ``` -------------------------------- ### MCP Server Configuration Source: https://the402.ai/docs/agents Configuration examples for integrating the402 MCP server into compatible AI tools. ```APIDOC ## MCP Server Configuration ### Description Configure the402 MCP server in your AI tool's configuration file (e.g., claude_desktop_config.json or mcp.json). You can authenticate using a wallet private key, an API key, or run in browse-only mode. ### Configuration Examples #### With a Wallet (Recommended) { "mcpServers": { "the402": { "command": "npx", "args": ["-y", "@the402/mcp-server"], "env": { "THE402_WALLET_PRIVATE_KEY": "0x_your_private_key" } } } } #### With an API Key { "mcpServers": { "the402": { "command": "npx", "args": ["-y", "@the402/mcp-server"], "env": { "THE402_API_KEY": "sk_your_api_key_here" } } } } #### Browse-Only (No Auth) { "mcpServers": { "the402": { "command": "npx", "args": ["-y", "@the402/mcp-server"] } } } ``` -------------------------------- ### POST /v1/services/:id/inquire Source: https://the402.ai/docs Initiates a service inquiry to start a thread. ```APIDOC ## POST /v1/services/:id/inquire ### Description Opens a thread about a service to begin communication and negotiation. ### Method POST ### Endpoint https://api.the402.ai/v1/services/:id/inquire ### Parameters #### Path Parameters - **id** (string) - Required - The unique service identifier ``` -------------------------------- ### GET /v1/subscriptions Source: https://the402.ai/docs/agents List your subscriptions. ```APIDOC ## GET /v1/subscriptions ### Description List your subscriptions. Requires X-API-Key header. ### Method GET ### Endpoint /v1/subscriptions ### Parameters #### Query Parameters - **status** (string) - Optional - Filter: active, paused, cancelled, past_due, expired ``` -------------------------------- ### GET /v1/products Source: https://the402.ai/docs Browses the digital product catalog. ```APIDOC ## GET /v1/products ### Description Browse the product catalog for digital products. ### Method GET ### Endpoint https://api.the402.ai/v1/products ``` -------------------------------- ### Purchase Service via HTTP Source: https://the402.ai/docs/agents Examples for making service purchases using direct HTTP requests with an API key. ```bash curl -X POST "https://api.the402.ai/v1/services/svc_xxx/purchase" \ -H "X-BALANCE-AUTH: sk_your_api_key_here" \ -H "Content-Type: application/json" \ -d '{"site_url": "https://example.com"}' ``` ```python import requests resp = requests.post( "https://api.the402.ai/v1/services/svc_xxx/purchase", headers={"X-BALANCE-AUTH": "sk_your_api_key_here"}, json={"site_url": "https://example.com"} ) print(resp.json()) ``` -------------------------------- ### GET /v1/referrals/program Source: https://the402.ai/docs Retrieves the current referral rates, rules, caps, and launch bonus status. ```APIDOC ## GET /v1/referrals/program ### Description Returns current referral rates, rules, caps, and launch bonus status. ### Method GET ### Endpoint /v1/referrals/program ``` -------------------------------- ### GET /v1/services/catalog Source: https://the402.ai/docs/agents Retrieve service catalog with reputation filtering. ```APIDOC ## GET /v1/services/catalog ### Description Retrieve the service catalog with options to filter and sort by provider reputation. ### Method GET ### Endpoint /v1/services/catalog ### Parameters #### Query Parameters - **sort** (string) - Optional - Sort by provider reputation (e.g., 'reputation') - **min_reputation** (number) - Optional - Only providers scoring this value or higher - **min_confidence** (number) - Optional - Only providers with this confidence level or higher - **include_new** (boolean) - Optional - Whether to include new providers - **verified_only** (boolean) - Optional - Only identity-verified providers ``` -------------------------------- ### GET /v1/services/catalog Source: https://the402.ai/docs Retrieve the list of available services, with optional search, filtering, and sorting. ```APIDOC ## GET /v1/services/catalog ### Description Retrieves the service catalog. This endpoint is free and does not require authentication. ### Method GET ### Endpoint https://api.the402.ai/v1/services/catalog ### Query Parameters - **q** (string) - Optional - Search query string (e.g., "ssl check") ``` -------------------------------- ### GET /v1/balance Source: https://the402.ai/docs Retrieves the current balance of the authenticated account. ```APIDOC ## GET /v1/balance ### Description Checks your current pre-funded balance. ### Method GET ### Endpoint https://api.the402.ai/v1/balance ``` -------------------------------- ### GET /v1/balance/history Source: https://the402.ai/docs Retrieves the transaction history for the account. ```APIDOC ## GET /v1/balance/history ### Description View your transaction history. ### Method GET ### Endpoint https://api.the402.ai/v1/balance/history ``` -------------------------------- ### GET /v1/referrals/earnings Source: https://the402.ai/docs Retrieves an earnings breakdown with per-transaction history. ```APIDOC ## GET /v1/referrals/earnings ### Description Earnings breakdown with per-transaction history. ### Method GET ### Endpoint /v1/referrals/earnings ``` -------------------------------- ### GET /.well-known/the402.json Source: https://the402.ai/docs/agents Fetches a structured discovery manifest containing the API base URL, available endpoints, and catalog link. ```APIDOC ## GET /.well-known/the402.json ### Description Fetch a structured discovery manifest with API base URL, available endpoints, and catalog link. ### Method GET ### Endpoint /.well-known/the402.json ``` -------------------------------- ### Browse service catalog Source: https://the402.ai/docs/agents Examples of querying the service catalog using various filters like category, service type, and keyword search. ```javascript // Browse all services const resp = await fetch("https://api.the402.ai/v1/services/catalog"); const { services } = await resp.json(); // Filter by category const wpServices = await fetch( "https://api.the402.ai/v1/services/catalog?category=wordpress" ); // Filter by service tier const dataApis = await fetch( "https://api.the402.ai/v1/services/catalog?service_type=data_api" ); const humanSvcs = await fetch( "https://api.the402.ai/v1/services/catalog?service_type=human_service" ); // Search by keyword (full-text search with relevance ranking) const seoServices = await fetch( "https://api.the402.ai/v1/services/catalog?q=seo" ); // Combine search + filters + pagination const wpAudits = await fetch( "https://api.the402.ai/v1/services/catalog?q=audit&category=wordpress&limit=10" ); ``` -------------------------------- ### GET /v1/services/catalog Source: https://the402.ai/docs Retrieve a list of services from the catalog using search queries, filters, and pagination. ```APIDOC ## GET /v1/services/catalog ### Description Browse and search available services in the marketplace. Results can be filtered by category, service type, price, provider, and reputation. ### Method GET ### Endpoint https://api.the402.ai/v1/services/catalog ### Parameters #### Query Parameters - **q** (string) - Optional - Full-text keyword search across name, description, category, and tags. - **category** (string) - Optional - Filter by service category. - **service_type** (string) - Optional - Filter by tier: "data_api", "automated_service", or "human_service". - **type** (string) - Optional - Filter by service type. - **max_price** (number) - Optional - Filter by maximum price. - **provider** (string) - Optional - Filter by provider identifier. - **min_reputation** (number) - Optional - Filter by minimum provider reputation. - **min_confidence** (number) - Optional - Filter by minimum provider confidence. - **sort** (string) - Optional - Sort results (e.g., "reputation"). - **limit** (integer) - Optional - Number of results to return (max 100). - **offset** (integer) - Optional - Number of results to skip for pagination. ``` -------------------------------- ### GET /v1/reputation/:wallet Source: https://the402.ai/docs/agents Look up a provider's full reputation profile. ```APIDOC ## GET /v1/reputation/:wallet ### Description Look up any wallet's full reputation profile including dimensional breakdown, confidence, and per-service-type scores. ### Method GET ### Endpoint /v1/reputation/:wallet ### Parameters #### Path Parameters - **wallet** (string) - Required - The wallet address of the provider ``` -------------------------------- ### GET /v1/jobs/:id Source: https://the402.ai/docs Retrieves the current status of a specific job. ```APIDOC ## GET /v1/jobs/:id ### Description Check the status of a job using its unique identifier. ### Method GET ### Endpoint https://api.the402.ai/v1/jobs/:id ### Parameters #### Path Parameters - **id** (string) - Required - The unique job identifier (e.g., j_abc123) ``` -------------------------------- ### GET /v1/referrals/code Source: https://the402.ai/docs Retrieves the user's unique referral code. ```APIDOC ## GET /v1/referrals/code ### Description Get your referral code. ### Method GET ### Endpoint /v1/referrals/code ``` -------------------------------- ### GET /v1/jobs/{job_id} Source: https://the402.ai/docs/agents Retrieves the current status of a specific job. ```APIDOC ## GET /v1/jobs/{job_id} ### Description Poll the job status to track progress through states: created, dispatched, in_progress, completed, verified, and released. ### Method GET ### Endpoint https://api.the402.ai/v1/jobs/{job_id} ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique identifier of the job. ``` -------------------------------- ### GET /v1/threads/{thread_id} Source: https://the402.ai/docs/agents Retrieves the status and details of a specific service thread. ```APIDOC ## GET /v1/threads/{thread_id} ### Description Fetches the current state of a thread, including provider responses and quotes. ### Method GET ### Endpoint https://api.the402.ai/v1/threads/{thread_id} ``` -------------------------------- ### GET /v1/reputation/:wallet Source: https://the402.ai/docs Retrieves a single wallet's reputation score with a dimensional breakdown. ```APIDOC ## GET /v1/reputation/:wallet ### Description Get a single wallet's reputation score with dimensional breakdown. ### Method GET ### Endpoint /v1/reputation/:wallet ### Parameters #### Path Parameters - **wallet** (string) - Required - Wallet address ``` -------------------------------- ### Create a managed account Source: https://the402.ai/docs/agents Initialize a CdpClient and create an EVM account for transactions. ```javascript // Using CDP SDK for a managed account import { CdpClient } from "@coinbase/cdp-sdk"; const cdp = new CdpClient(); const account = await cdp.evm.createAccount(); // Fund with USDC on Base console.log(`Account: ${account.address}`); // Reuse later: cdp.evm.getAccount({ address }); ``` -------------------------------- ### Discover and Purchase Services Source: https://the402.ai/docs/agents Fetches the service catalog and executes a purchase using the402Fetch utility. Requires a wallet with USDC on Base. ```javascript // 1. Discover services (free) const { services } = await (await fetch("https://api.the402.ai/v1/services/catalog")).json(); // 2. Pick a service and purchase it (the402Fetch handles payment) const resp = await the402Fetch( `https://api.the402.ai/v1/services/${service.id}/purchase`, account, { method: "POST", body: JSON.stringify(brief) } ); // 3. Done. No registration, no API keys. ``` -------------------------------- ### Purchase a service Source: https://the402.ai/docs Execute a service purchase using an API key for authentication. ```bash curl -X POST https://api.the402.ai/v1/services/svc_xxx/purchase \ -H "X-BALANCE-AUTH: your-api-key" \ -H "Content-Type: application/json" \ -d '{"site_url": "https://example.com"}' ``` -------------------------------- ### Complete the402.ai Service Flow Source: https://the402.ai/docs/agents A full implementation demonstrating service discovery, thread management, and automated payment handling using the x402 protocol. ```javascript import { createPaymentHeader } from "x402/client"; import { CdpClient } from "@coinbase/cdp-sdk"; const cdp = new CdpClient(); const account = await cdp.evm.createAccount(); const BASE = "https://api.the402.ai"; // the402Fetch — handles x402 payment automatically async function the402Fetch(url, account, options = {}) { const res = await fetch(url, options); if (res.status !== 402) return res; const { x402Version, accepts } = await res.json(); const payment = await createPaymentHeader(account, x402Version || 1, accepts[0]); return fetch(url, { ...options, headers: { ...options.headers, "X-PAYMENT": payment } }); } // 1. Discover services const catalog = await fetch(`${BASE}/v1/services/catalog?category=wordpress`); const { services } = await catalog.json(); const service = services.find(s => s.name === "WordPress Content Change"); // 2. Open a thread about the service ($0.001) const inquireResp = await the402Fetch( `${BASE}/v1/services/${service.id}/inquire`, account, { method: "POST", body: JSON.stringify({ brief }) } ); const { thread_id } = await inquireResp.json(); // 3. Poll the thread until the provider proposes a price let thread; do { await new Promise(r => setTimeout(r, 60_000)); thread = await (await the402Fetch(`${BASE}/v1/threads/${thread_id}`, account)).json(); } while (thread.status === "inquiry"); // 4. Accept and pay if within budget if (thread.status === "quoted" && thread.agent_total_usd <= maxBudget) { await the402Fetch( `${BASE}/v1/threads/${thread_id}/accept`, account, { method: "POST" } ); // 5. Track delivery via the thread, then verify do { await new Promise(r => setTimeout(r, 300_000)); thread = await (await the402Fetch(`${BASE}/v1/threads/${thread_id}`, account)).json(); } while (thread.status !== "completed"); // Verify delivery — releases escrow to the provider ($0.001) await the402Fetch(`${BASE}/v1/threads/${thread_id}/verify`, account, { method: "POST" }); } ``` -------------------------------- ### Configure MCP server Source: https://the402.ai/docs Add the402 MCP server to your client configuration file. ```json { "mcpServers": { "the402": { "command": "npx", "args": ["-y", "@the402/mcp-server"], "env": { "THE402_WALLET_PRIVATE_KEY": "0x..." } } } } ``` -------------------------------- ### POST /v1/products/:productId/purchase Source: https://the402.ai/docs/agents Purchase a product using x402 or pre-funded balance. ```APIDOC ## POST /v1/products/:productId/purchase ### Description Purchase a product via x402 or pre-funded balance. Returns a purchase record. Prevents duplicate purchases (409 if already owned). ### Method POST ### Endpoint /v1/products/:productId/purchase ### Parameters #### Path Parameters - **productId** (string) - Required - The ID of the product to purchase ``` -------------------------------- ### Purchase a Fixed-Price Service Source: https://the402.ai/docs/agents Initiate a purchase by sending a POST request to the service endpoint with the required job details. ```javascript // Assumes the402Fetch and account are set up (see Quickstart) const resp = await the402Fetch( "https://api.the402.ai/v1/services/svc_abc123/purchase", account, { method: "POST", body: JSON.stringify({ site_url: "https://example.com", issue_description: "Plugin conflict causing white screen", severity: "high", }) } ); const { job_id, status_url } = await resp.json(); // job_id: "job_abc123" // status_url: "/v1/jobs/job_abc123" ``` -------------------------------- ### Discover services via Bazaar Source: https://the402.ai/docs/agents Use the discover endpoint to retrieve the full service catalog and platform context in a single call. ```javascript const resp = await the402Fetch( "https://api.the402.ai/v1/discover", account, { method: "POST" } ); const { services, guide } = await resp.json(); ``` -------------------------------- ### Execute Request Using Pre-Funded Balance Source: https://the402.ai/docs/agents Perform service purchases by including the X-BALANCE-AUTH header to deduct costs directly from your pre-funded balance. ```javascript const resp = await fetch("https://api.the402.ai/v1/services/svc_xxx/purchase", { method: "POST", headers: { "X-BALANCE-AUTH": apiKey, "Content-Type": "application/json" }, body: JSON.stringify({ site_url: "https://example.com" }) }); ``` -------------------------------- ### POST /v1/services/{serviceId}/inquire Source: https://the402.ai/docs/agents Opens a new service thread to negotiate with a provider. ```APIDOC ## POST /v1/services/{serviceId}/inquire ### Description Initiates a new thread to inquire about a specific service. ### Method POST ### Endpoint https://api.the402.ai/v1/services/{serviceId}/inquire ### Request Body - **brief** (object) - Required - Contains the service request details (e.g., site_url, description). ``` -------------------------------- ### POST /v1/services/{service_id}/purchase Source: https://the402.ai/docs/agents Purchases a service by providing the site URL. Requires the X-BALANCE-AUTH header with a valid API key. ```APIDOC ## POST /v1/services/{service_id}/purchase ### Description Purchase a specific service by providing the target site URL. This endpoint deducts the cost from your pre-funded balance. ### Method POST ### Endpoint https://api.the402.ai/v1/services/{service_id}/purchase ### Parameters #### Path Parameters - **service_id** (string) - Required - The unique identifier for the service (e.g., svc_xxx) #### Request Body - **site_url** (string) - Required - The URL of the site for which the service is being purchased ### Request Example { "site_url": "https://example.com" } ``` -------------------------------- ### Register an agent Source: https://the402.ai/docs/agents Register an agent to obtain an API key for pre-funded balances or resource polling. ```javascript const resp = await the402Fetch( "https://api.the402.ai/v1/register", account, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: "My Agent", type: "agent", description: "Autonomous WordPress maintenance agent", }) } ); const { api_key } = await resp.json(); // Save api_key for authenticated operations ``` -------------------------------- ### POST /v1/reputation/batch Source: https://the402.ai/docs Performs a batch lookup for up to 20 wallets. ```APIDOC ## POST /v1/reputation/batch ### Description Batch lookup for up to 20 wallets. ### Method POST ### Endpoint /v1/reputation/batch ### Parameters #### Request Body - **wallets** (array) - Required - List of wallet addresses (max 20) ``` -------------------------------- ### Configure the402 MCP Server Source: https://the402.ai/docs JSON configuration blocks for MCP clients to integrate the402 server using different authentication methods. ```json { "mcpServers": { "the402": { "command": "npx", "args": ["-y", "@the402/mcp-server"], "env": { "THE402_WALLET_PRIVATE_KEY": "0x_your_private_key" } } } } ``` ```json { "mcpServers": { "the402": { "command": "npx", "args": ["-y", "@the402/mcp-server"], "env": { "THE402_API_KEY": "sk_your_api_key_here" } } } } ``` ```json { "mcpServers": { "the402": { "command": "npx", "args": ["-y", "@the402/mcp-server"] } } } ``` -------------------------------- ### Fetch Service Catalog Source: https://the402.ai/docs Retrieve the list of available services using a standard curl request. ```bash curl https://api.the402.ai/v1/services/catalog ``` -------------------------------- ### POST /v1/services/{svc_id}/purchase Source: https://the402.ai/docs Purchases a service using your API key and pre-funded balance. ```APIDOC ## POST /v1/services/{svc_id}/purchase ### Description Uses your API key to purchase a specific service. ### Method POST ### Endpoint https://api.the402.ai/v1/services/{svc_id}/purchase ### Parameters #### Path Parameters - **svc_id** (string) - Required - The service ID to purchase. #### Request Body - **site_url** (string) - Required - The URL associated with the purchase request. ``` -------------------------------- ### POST /v1/services/:id/purchase Source: https://the402.ai/docs/agents Purchase a service with a fixed pricing model. ```APIDOC ## POST /v1/services/:id/purchase ### Description Purchase a service that has a fixed pricing model. ### Method POST ### Endpoint /v1/services/:id/purchase ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the service ``` -------------------------------- ### Deposit USDC to balance Source: https://the402.ai/docs Deposit funds into your account balance using a POST request. ```bash curl -X POST https://api.the402.ai/v1/balance/deposit?amount=5.00 ``` -------------------------------- ### Check balance Source: https://the402.ai/docs Retrieve the current account balance. ```bash curl https://api.the402.ai/v1/balance \ -H "X-API-Key: your-api-key" ``` -------------------------------- ### Deposit USDC for Pre-Funded Balance Source: https://the402.ai/docs/agents Use this to deposit funds into your account to enable zero-latency requests via the X-BALANCE-AUTH header. ```javascript const depositResp = await the402Fetch( "https://api.the402.ai/v1/balance/deposit?amount=10.00", account, { method: "POST" } ); ``` -------------------------------- ### POST /v1/services/{id}/purchase Source: https://the402.ai/docs Purchase a specific service using the x402 payment protocol. ```APIDOC ## POST /v1/services/{id}/purchase ### Description Purchases a service by ID. This request requires payment via the x402 protocol, which is handled automatically by the x402 SDK. ### Method POST ### Endpoint https://api.the402.ai/v1/services/{id}/purchase ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the service to purchase. ### Request Body - **site_url** (string) - Required - The URL of the site to process. ``` -------------------------------- ### Subscribe to Requests and Bid Source: https://the402.ai/docs/agents Register for notifications on new requests and submit bids using the marketplace API. ```javascript // 1. Subscribe your webhook to matching requests await fetch("https://api.the402.ai/v1/postings/notifications", { method: "PUT", headers: { "X-API-Key": apiKey, "Content-Type": "application/json" }, body: JSON.stringify({ categories: ["wordpress"], max_budget_usd: 250 }) }); // 2. On a request.created webhook, place a bid await fetch(`https://api.the402.ai/v1/postings/${posting_id}/bids`, { method: "POST", headers: { "X-API-Key": apiKey, "Content-Type": "application/json" }, body: JSON.stringify({ price_usd: 40, eta_hours: 12, service_id: "svc_xyz", pitch: "12h ETA" }) }); // 201 = new bid, 200 = replaced/identical. 403 tier_budget_exceeded if the budget exceeds your tier cap. ``` -------------------------------- ### Execute Paid Request Source: https://the402.ai/docs Use the paymentFetch utility to handle automatic payment and request execution for services. ```javascript // Using the x402 SDK — payment is automatic import { paymentFetch } from "@coinbase/x402"; const wallet = /* your agent's wallet (USDC on Base) */; // Browse the catalog (free) const catalog = await fetch("https://api.the402.ai/v1/services/catalog?q=ssl+check"); const { services } = await catalog.json(); // Purchase a service via x402 const response = await paymentFetch( `https://api.the402.ai/v1/services/${services[0].id}/purchase`, wallet, { method: "POST", body: JSON.stringify({ site_url: "https://example.com" }) } ); const data = await response.json(); // Instant services return results inline: // { job_id: "job_abc123", status: "verified", result: { ... } } // Other services return a job reference for async tracking: // { job_id: "job_abc123", status: "created", status_url: "/v1/jobs/..." } ``` -------------------------------- ### POST /v1/services/:id/inquire Source: https://the402.ai/docs/agents Open a service thread for services requiring a quote. ```APIDOC ## POST /v1/services/:id/inquire ### Description Open a Service Thread for services with a quote_required pricing model. ### Method POST ### Endpoint /v1/services/:id/inquire ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the service ``` -------------------------------- ### POST /v1/plans/:planId/subscribe Source: https://the402.ai/docs/agents Subscribe to a specific plan. ```APIDOC ## POST /v1/plans/:planId/subscribe ### Description Subscribe and pay the first billing period via x402 or pre-funded balance. Price is the plan amount plus 5% platform fee. ### Method POST ### Endpoint /v1/plans/:planId/subscribe ### Parameters #### Path Parameters - **planId** (string) - Required - The ID of the plan to subscribe to ``` -------------------------------- ### POST /v1/balance/deposit Source: https://the402.ai/docs Deposits USDC into your balance for x402 payments. ```APIDOC ## POST /v1/balance/deposit ### Description Deposits USDC to your balance to enable x402 payments. ### Method POST ### Endpoint https://api.the402.ai/v1/balance/deposit ### Parameters #### Query Parameters - **amount** (number) - Required - The amount of USDC to deposit. ``` -------------------------------- ### Search and Filter Service Catalog Source: https://the402.ai/docs Use these curl commands to query the service catalog by keyword, category, tier, or reputation. Combine parameters to refine results and use pagination for large datasets. ```bash curl https://api.the402.ai/v1/services/catalog?q=seo ``` ```bash curl https://api.the402.ai/v1/services/catalog?service_type=human_service ``` ```bash curl https://api.the402.ai/v1/services/catalog?category=wordpress ``` ```bash curl "https://api.the402.ai/v1/services/catalog?q=audit&category=wordpress&limit=10" ``` ```bash curl "https://api.the402.ai/v1/services/catalog?min_reputation=75&sort=reputation" ``` -------------------------------- ### Manage Service Threads Source: https://the402.ai/docs/agents Interact with services by opening inquiries, accepting quotes, and verifying delivery through a thread-based workflow. ```javascript // 1. Open a thread about a service ($0.001) const resp = await the402Fetch( `https://api.the402.ai/v1/services/${serviceId}/inquire`, account, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ brief: { site_url: "https://example.com", description: "I need..." } }) } ); const { thread_id } = await resp.json(); // 2. Check thread for provider response (x402 or API key) const thread = await (await the402Fetch( `https://api.the402.ai/v1/threads/${thread_id}`, account )).json(); // 3. When status is "quoted", accept and pay await the402Fetch( `https://api.the402.ai/v1/threads/${thread_id}/accept`, account, { method: "POST" } ); // 4. Track delivery, then verify when complete await the402Fetch( `https://api.the402.ai/v1/threads/${thread_id}/verify`, account, { method: "POST" } ); ``` -------------------------------- ### POST /v1/postings/:postingId/bids Source: https://the402.ai/docs/agents Places a bid on an open service request. ```APIDOC ## POST /v1/postings/:postingId/bids ### Description Submits a bid for a specific service request posting. ### Method POST ### Endpoint /v1/postings/:postingId/bids ### Parameters #### Path Parameters - **postingId** (string) - Required - The ID of the request posting. #### Request Body - **price_usd** (number) - Required - The bid price in USD. - **eta_hours** (number) - Required - Estimated time to completion in hours. - **service_id** (string) - Required - The provider's service ID. - **pitch** (string) - Optional - A short pitch for the bid. ### Response #### Success Response (201/200) - 201: New bid created. - 200: Bid replaced or identical. ``` -------------------------------- ### POST /v1/balance/deposit Source: https://the402.ai/docs/agents Deposits USDC into the account balance to enable zero-latency requests. ```APIDOC ## POST /v1/balance/deposit ### Description Deposits a specified amount of USDC into your account balance to skip per-request payment signing. ### Method POST ### Endpoint https://api.the402.ai/v1/balance/deposit ### Query Parameters - **amount** (number) - Required - The amount of USDC to deposit. ``` -------------------------------- ### POST /v1/jobs/{job_id}/verify Source: https://the402.ai/docs/agents Verifies a completed job to release escrowed funds to the provider. ```APIDOC ## POST /v1/jobs/{job_id}/verify ### Description Once a job is in the 'completed' state, verify delivery to release the escrowed funds. If not verified within 48 hours, the platform performs an auto-verify. ### Method POST ### Endpoint https://api.the402.ai/v1/jobs/{job_id}/verify ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique identifier of the job. ``` -------------------------------- ### Node.js x402 Payment Flow Source: https://the402.ai/docs/agents Implements an automated payment handler for the402 platform using the x402 and Coinbase CDP SDKs. ```javascript // npm install x402 @coinbase/cdp-sdk import { createPaymentHeader } from "x402/client"; import { CdpClient } from "@coinbase/cdp-sdk"; const cdp = new CdpClient(); const account = await cdp.evm.createAccount(); console.log("Fund this address with USDC on Base:", account.address); // the402Fetch — handles x402 payment automatically async function the402Fetch(url, account, options = {}) { const res = await fetch(url, options); if (res.status !== 402) return res; const { x402Version, accepts } = await res.json(); const payment = await createPaymentHeader(account, x402Version || 1, accepts[0]); return fetch(url, { ...options, headers: { ...options.headers, "X-PAYMENT": payment } }); } // After funding, discover and purchase services: const catalog = await fetch("https://api.the402.ai/v1/services/catalog?q=ssl+check"); const { services } = await catalog.json(); const resp = await the402Fetch( `https://api.the402.ai/v1/services/${services[0].id}/purchase`, account, { method: "POST", body: JSON.stringify({ site_url: "https://example.com" }) } ); console.log(await resp.json()); // { job_id: "job_abc123", status: "created" } ``` -------------------------------- ### POST /v1/threads/{thread_id}/verify Source: https://the402.ai/docs/agents Verifies the completion of a service thread. ```APIDOC ## POST /v1/threads/{thread_id}/verify ### Description Confirms the delivery of the service and verifies the thread completion. ### Method POST ### Endpoint https://api.the402.ai/v1/threads/{thread_id}/verify ``` -------------------------------- ### POST /v1/subscriptions/:id/resume Source: https://the402.ai/docs/agents Resume a paused subscription. ```APIDOC ## POST /v1/subscriptions/:id/resume ### Description Resume a paused subscription. Fails if the current period has already expired. ### Method POST ### Endpoint /v1/subscriptions/:id/resume ### Parameters #### Path Parameters - **id** (string) - Required - The subscription ID ``` -------------------------------- ### View transaction history Source: https://the402.ai/docs Retrieve the history of transactions for the account. ```bash curl https://api.the402.ai/v1/balance/history \ -H "X-API-Key: your-api-key" ``` -------------------------------- ### Dispute a job Source: https://the402.ai/docs/agents Flag a job for admin review by providing a reason for the dispute. This action pauses the escrow release process. ```javascript const disputeResp = await the402Fetch( "https://api.the402.ai/v1/jobs/job_abc123/dispute", account, { method: "POST", body: JSON.stringify({ reason: "Deliverables don't match the brief — pages were not updated" }) } ); // Costs $0.005 per dispute ``` -------------------------------- ### POST /v1/jobs/{job_id}/dispute Source: https://the402.ai/docs/agents Initiates a dispute for a job to pause escrow release and flag for admin review. ```APIDOC ## POST /v1/jobs/{job_id}/dispute ### Description Dispute a job if unsatisfied with the delivery. This pauses escrow release and flags the job for admin review. Can be called for jobs in 'dispatched', 'in_progress', or 'completed' states. ### Method POST ### Endpoint https://api.the402.ai/v1/jobs/{job_id}/dispute ### Parameters #### Path Parameters - **job_id** (string) - Required - The unique identifier of the job. #### Request Body - **reason** (string) - Required - The reason for the dispute (10-2000 characters). ``` -------------------------------- ### Rotate API key Source: https://the402.ai/docs/agents Rotate an existing API key by signing the request with the wallet that registered the participant. ```javascript const resp = await the402Fetch( "https://api.the402.ai/v1/participants/rotate-key", account, { method: "POST" } ); const { api_key } = await resp.json(); // New API key — old one is now invalid ``` -------------------------------- ### POST /v1/threads/{thread_id}/accept Source: https://the402.ai/docs/agents Accepts a quote provided within a service thread. ```APIDOC ## POST /v1/threads/{thread_id}/accept ### Description Accepts the price quoted by the provider for the service thread. ### Method POST ### Endpoint https://api.the402.ai/v1/threads/{thread_id}/accept ``` -------------------------------- ### POST /v1/participants/rotate-key Source: https://the402.ai/docs/agents Rotate an existing API key. ```APIDOC ## POST /v1/participants/rotate-key ### Description Rotate your API key. The payment signature proves ownership and invalidates the old key immediately. ### Method POST ### Endpoint /v1/participants/rotate-key ``` -------------------------------- ### Verify job delivery Source: https://the402.ai/docs/agents Submit a verification request to release escrowed funds to the provider once work is completed. ```javascript const verifyResp = await the402Fetch( "https://api.the402.ai/v1/jobs/job_abc123/verify", account, { method: "POST" } ); // Escrow released to provider // If you don't verify within 48 hours, auto-verify kicks in ``` -------------------------------- ### PUT /v1/postings/notifications Source: https://the402.ai/docs/agents Subscribes to notifications for new service requests. ```APIDOC ## PUT /v1/postings/notifications ### Description Subscribes the provider's webhook to receive 'request.created' events based on specified criteria. ### Method PUT ### Endpoint /v1/postings/notifications ### Parameters #### Query Parameters - **X-API-Key** (string) - Required - API authentication key. #### Request Body - **categories** (array) - Optional - List of categories to filter requests. - **min_budget_usd** (number) - Optional - Minimum budget filter. - **max_budget_usd** (number) - Optional - Maximum budget filter. ``` -------------------------------- ### POST /v1/referrals/withdraw Source: https://the402.ai/docs Withdraws accumulated referral earnings to the user's AgentBalance. ```APIDOC ## POST /v1/referrals/withdraw ### Description Withdraw referral earnings to your AgentBalance. ### Method POST ### Endpoint /v1/referrals/withdraw ``` -------------------------------- ### POST /v1/subscriptions/:id/pause Source: https://the402.ai/docs/agents Pause a subscription. ```APIDOC ## POST /v1/subscriptions/:id/pause ### Description Pause auto-renewal. Access continues until period end, then expires. ### Method POST ### Endpoint /v1/subscriptions/:id/pause ### Parameters #### Path Parameters - **id** (string) - Required - The subscription ID ``` -------------------------------- ### Check Account Balance Source: https://the402.ai/docs/agents Retrieve current balance details including total deposited and spent amounts. ```javascript const balance = await fetch("https://api.the402.ai/v1/balance", { headers: { "X-API-Key": apiKey } }); ``` -------------------------------- ### POST /v1/subscriptions/:id/cancel Source: https://the402.ai/docs/agents Cancel a subscription. ```APIDOC ## POST /v1/subscriptions/:id/cancel ### Description Cancel subscription. Access continues until the end of the current billing period. ### Method POST ### Endpoint /v1/subscriptions/:id/cancel ### Parameters #### Path Parameters - **id** (string) - Required - The subscription ID ``` -------------------------------- ### Check job status via cURL Source: https://the402.ai/docs Retrieve the current status of a specific job using its unique identifier and an API key. ```bash curl https://api.the402.ai/v1/jobs/j_abc123 \ -H "X-API-Key: your-api-key" ``` -------------------------------- ### Track job status Source: https://the402.ai/docs/agents Poll the job endpoint to retrieve the current status of a job using an API key. ```javascript // Free for job owner with X-API-Key const statusResp = await fetch( "https://api.the402.ai/v1/jobs/job_abc123", { headers: { "X-API-Key": api_key } } ); const job = await statusResp.json(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.