{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentSearch Web Render",
    "version": "0.1.4",
    "description": "JavaScript page renderer and screenshot service for AI agents (headless Chromium), served on Pocket Network as agentsearch-web-render-v1. All inputs travel in the JSON body; every response is a JSON object. Target-site failures return HTTP 200 with an error object; bad input, policy refusals (URL_NOT_ALLOWED, ROBOTS_DISALLOWED) and deadlines with no usable content (TARGET_DEADLINE) return 4xx. Hard render deadline 4.2 s. When to use: the page needs JavaScript (SPA or client-rendered content), Extract returned empty or partial text, or you need a screenshot. Prefer Extract for static pages (faster). Pricing: $0.010 per call in USDC on Base via the direct x402 API at https://api.agentsearchhq.com/x402/v1/render (primary; settled only on success; docs https://agentsearchhq.com/docs/x402), or $0.005 per call via x402 on the Pocket Agentic Portal (no account, no API key). An unpaid request gets HTTP 402 with x402 v2 terms in the PAYMENT-REQUIRED header; retry with PAYMENT-SIGNATURE. A paid 200 is wrapped as {\"portal\": {...}, \"data\": <this service's response>}. Only 2xx answers are settled: 402, 4xx and 5xx are not charged; HTTP 200 answers with a non-null `error` are charged. Docs: https://agentsearchhq.com/agents.md",
    "contact": {
      "name": "AgentSearch",
      "url": "https://agentsearchhq.com/",
      "email": "AgentSearchhq@gmail.com"
    },
    "x-pocket-service-id": "agentsearch-web-render-v1"
  },
  "servers": [
    {
      "url": "https://api.agentsearchhq.com/x402",
      "description": "Direct x402 API on Base (USDC), $0.010 per call, settled only on success. Primary paid route. Docs: https://agentsearchhq.com/docs/x402; accepts {\"url\"} only, other fields are Pocket-route options"
    },
    {
      "url": "https://agent.pocket.network/v1/agentsearch-web-render-v1",
      "description": "Also on Pocket Network: Agentic Portal (x402, $0.005 per call)"
    }
  ],
  "paths": {
    "/v1/render": {
      "post": {
        "operationId": "render",
        "summary": "Render a URL in headless Chromium",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderRequest"
              },
              "examples": {
                "default": {
                  "summary": "Markdown of a page",
                  "value": {
                    "url": "https://example.com",
                    "formats": [
                      "markdown"
                    ],
                    "max_chars": 5000,
                    "viewport": {
                      "width": 1280,
                      "height": 800
                    }
                  }
                },
                "text": {
                  "value": {
                    "url": "https://example.com/",
                    "formats": [
                      "text"
                    ],
                    "max_chars": 500
                  }
                },
                "screenshot": {
                  "value": {
                    "url": "https://react.dev/",
                    "formats": [
                      "markdown"
                    ],
                    "screenshot": true,
                    "screenshot_format": "jpeg"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rendered page, or a target-site failure with error set (content empty or partial).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RenderResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Rendered page",
                    "value": {
                      "request_id": "r1a2",
                      "url": "https://example.com/",
                      "status_code": 200,
                      "title": "Example Domain",
                      "meta": {
                        "render_ms": 820,
                        "fetched_at": "2026-10-15T12:00:00Z",
                        "chars": 167,
                        "truncated": false,
                        "js": true,
                        "content_type": "text/html",
                        "lang": "en"
                      },
                      "error": null,
                      "warnings": [],
                      "links": [
                        {
                          "text": "More information...",
                          "href": "https://www.iana.org/domains/example"
                        }
                      ],
                      "markdown": "# Example Domain\n\nThis domain is for use in illustrative examples in documents. ..."
                    }
                  },
                  "partial_deadline": {
                    "summary": "Deadline hit with partial content (HTTP 200, charged)",
                    "value": {
                      "request_id": "r3b4",
                      "url": "https://slow-spa.example.net/",
                      "status_code": 200,
                      "title": "Dashboard",
                      "meta": {
                        "render_ms": 4200,
                        "fetched_at": "2026-10-15T12:00:04Z",
                        "chars": 1840,
                        "truncated": false
                      },
                      "error": {
                        "code": "TARGET_DEADLINE",
                        "message": "Render deadline reached; returning partial content.",
                        "retryable": true
                      },
                      "warnings": [],
                      "links": [],
                      "markdown": "# Dashboard\n\n..."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or URL not allowed (INVALID_REQUEST, URL_NOT_ALLOWED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "URL_NOT_ALLOWED",
                    "message": "Private, metadata and non-http(s) URLs are not allowed.",
                    "retryable": false
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required (Agentic Portal only). x402 v2 terms (scheme exact, network eip155:8453, asset USDC, amount 5000 = $0.005 on the Pocket portal; on the direct x402 API the amount is 10000 = $0.010) are in the base64 PAYMENT-REQUIRED header. Not charged.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "description": "Base64-encoded JSON x402 payment terms.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "Body over 8 KB (REQUEST_TOO_LARGE).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Not settled by the portal (caller is not charged). ROBOTS_DISALLOWED: robots.txt disallows the URL for AgentSearchRender (retryable only when robots.txt answered with a 5xx); refused before any fetch. TARGET_DEADLINE (0.1.4, retryable): the render deadline was hit with no usable content (no screenshot and fewer than 40 non-whitespace characters of text/markdown). A deadline with meaningful partial content still returns 200 with error TARGET_DEADLINE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "robots": {
                    "summary": "robots.txt refusal (not charged)",
                    "value": {
                      "error": {
                        "code": "ROBOTS_DISALLOWED",
                        "message": "robots.txt disallows this URL for AgentSearchRender.",
                        "retryable": false
                      }
                    }
                  },
                  "deadline": {
                    "summary": "Nothing usable rendered in time (not charged)",
                    "value": {
                      "error": {
                        "code": "TARGET_DEADLINE",
                        "message": "Render deadline reached with no usable content.",
                        "retryable": true
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "CAPACITY_LIMIT, APPLICATION_RATE_LIMITED or HOST_RATE_LIMITED (retryable).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "CAPACITY_LIMIT",
                    "message": "Busy; retry shortly.",
                    "retryable": true
                  }
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR (backend fault only).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Render one public URL in headless Chromium within a 4.2 s deadline and return title, rendered markdown/text, optional HTML, links and screenshot. robots.txt is honored (token AgentSearchRender); no logins, clicks or form submission. Target-site failures return HTTP 200 with a non-null `error` (charged through the portal). ROBOTS_DISALLOWED and a deadline with no usable content return 422 and are not charged."
      }
    },
    "/v1/version": {
      "get": {
        "operationId": "version",
        "responses": {
          "200": {
            "description": "Identity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "service": {
                      "const": "agentsearch-web-render-v1"
                    },
                    "version": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Service name and version",
        "description": "Service name and version. Free to call directly on a relay; returns JSON."
      }
    },
    "/v1/health": {
      "get": {
        "operationId": "health",
        "responses": {
          "200": {
            "description": "Ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "const": "ok"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Chromium pool or egress filter not ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "const": "degraded"
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Readiness check",
        "description": "Readiness check. Free to call directly on a relay; returns JSON."
      }
    },
    "/v1/capabilities": {
      "get": {
        "operationId": "capabilities",
        "responses": {
          "200": {
            "description": "Limits, formats and error codes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "summary": "Limits, formats and error codes",
        "description": "Limits, formats and error codes. Free to call directly on a relay; returns JSON."
      }
    }
  },
  "components": {
    "schemas": {
      "RenderRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 4096,
            "description": "Public http(s) URL on port 80/443.",
            "example": "https://example.com",
            "examples": [
              "https://example.com"
            ]
          },
          "formats": {
            "type": "array",
            "items": {
              "enum": [
                "markdown",
                "text",
                "html",
                "links"
              ]
            },
            "default": [
              "markdown"
            ],
            "example": [
              "markdown"
            ]
          },
          "max_chars": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000,
            "default": 20000,
            "example": 5000,
            "description": "Cap on returned characters. 0 or a negative value means the default (20000); values over 100000 are clamped."
          },
          "screenshot": {
            "type": "boolean",
            "default": false,
            "example": false
          },
          "screenshot_format": {
            "enum": [
              "png",
              "jpeg"
            ],
            "default": "png",
            "description": "A PNG that is over 1 MB or would not finish within the deadline is returned as JPEG (warning SCREENSHOT_RECOMPRESSED_JPEG); a full page that cannot be captured in time falls back to a viewport image (warning SCREENSHOT_HEIGHT_CLIPPED). Omitted only if no image fits (SCREENSHOT_TOO_LARGE) or the page cannot paint in time (SCREENSHOT_SKIPPED).",
            "example": "png"
          },
          "full_page": {
            "type": "boolean",
            "default": false,
            "description": "Height clipped to 4000 px.",
            "example": false
          },
          "viewport": {
            "type": "object",
            "properties": {
              "width": {
                "type": "integer",
                "minimum": 320,
                "maximum": 1920,
                "default": 1280,
                "example": 1280
              },
              "height": {
                "type": "integer",
                "minimum": 240,
                "maximum": 1600,
                "default": 800,
                "example": 800
              }
            },
            "default": {
              "width": 1280,
              "height": 800
            },
            "example": {
              "width": 1280,
              "height": 800
            },
            "description": "Viewport in pixels. 0 or missing means the default 1280x800; other values are clamped to 320-1920 x 240-1600."
          },
          "wait_until": {
            "enum": [
              "domcontentloaded",
              "load",
              "networkidle"
            ],
            "default": "domcontentloaded",
            "example": "domcontentloaded"
          },
          "wait_for_selector": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300,
            "description": "CSS selector waited for at most 1.5 s. If it never appears the page is still returned, with warning WAIT_CONDITION_NOT_MET. Empty or the placeholder \"string\" is ignored.",
            "example": "body"
          },
          "wait_ms": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1500,
            "default": 0,
            "example": 0
          },
          "block": {
            "type": "array",
            "items": {
              "enum": [
                "image",
                "media",
                "font",
                "stylesheet"
              ]
            },
            "default": [
              "media",
              "font"
            ],
            "example": [
              "media",
              "font"
            ]
          }
        },
        "example": {
          "url": "https://example.com",
          "formats": [
            "markdown"
          ],
          "max_chars": 5000,
          "viewport": {
            "width": 1280,
            "height": 800
          }
        },
        "examples": [
          {
            "url": "https://example.com",
            "formats": [
              "markdown"
            ],
            "max_chars": 5000,
            "viewport": {
              "width": 1280,
              "height": 800
            }
          }
        ],
        "description": "A render request. Only url is required; omit the other fields to get the defaults. Schema-generated placeholder values (0 for sizes, \"string\" for strings or enums) are replaced by the defaults, and the response then carries warning INPUT_NORMALIZED. Other invalid values return 400 INVALID_REQUEST."
      },
      "RenderResponse": {
        "type": "object",
        "required": [
          "request_id",
          "url",
          "meta",
          "error"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "requested_url": {
            "type": "string"
          },
          "status_code": {
            "type": [
              "integer",
              "null"
            ]
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "meta": {
            "type": "object",
            "properties": {
              "render_ms": {
                "type": "integer"
              },
              "fetched_at": {
                "type": "string",
                "format": "date-time"
              },
              "chars": {
                "type": "integer"
              },
              "truncated": {
                "type": "boolean"
              },
              "js": {
                "type": "boolean"
              },
              "robots": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "blocked_requests": {
                "type": "integer"
              },
              "content_type": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "lang": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "error": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "message",
                  "retryable"
                ],
                "properties": {
                  "code": {
                    "enum": [
                      "TARGET_HTTP_ERROR",
                      "TARGET_DEADLINE",
                      "TARGET_DNS_ERROR",
                      "TARGET_UNREACHABLE",
                      "TARGET_TLS_ERROR",
                      "TARGET_TOO_MANY_REDIRECTS",
                      "TARGET_REDIRECT_BLOCKED",
                      "TARGET_BOT_WALL",
                      "UNSUPPORTED_CONTENT",
                      "RENDER_FAILED"
                    ]
                  },
                  "message": {
                    "type": "string"
                  },
                  "retryable": {
                    "type": "boolean"
                  },
                  "upstream_status": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "request_id": {
                    "type": "string"
                  }
                }
              }
            ]
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Warning codes: SCREENSHOT_HEIGHT_CLIPPED, SCREENSHOT_RECOMPRESSED_JPEG, SCREENSHOT_TOO_LARGE, SCREENSHOT_SKIPPED, WAIT_CONDITION_NOT_MET, WAIT_CONDITION_INVALID, MARKDOWN_FALLBACK_TEXT, RESPONSE_TRIMMED, INPUT_NORMALIZED (placeholder or out-of-range input replaced by defaults)."
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "href": {
                  "type": "string"
                }
              }
            }
          },
          "text": {
            "type": "string"
          },
          "markdown": {
            "type": "string"
          },
          "html": {
            "type": "string"
          },
          "screenshot": {
            "type": "object",
            "properties": {
              "format": {
                "enum": [
                  "png",
                  "jpeg"
                ]
              },
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "bytes": {
                "type": "integer",
                "maximum": 1000000
              },
              "base64": {
                "type": "string"
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "retryable"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              },
              "upstream_status": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "request_id": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Agent notes, quickstart, error codes and pricing",
    "url": "https://agentsearchhq.com/agents.md"
  },
  "security": []
}
