> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sanfoundation.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Web extract

> Same shape as `POST /api/v1/web-extract`, paid per call via x402.



## OpenAPI

````yaml https://playground.sanfoundation.com/openapi.yaml post /x402/v1/web-extract
openapi: 3.1.0
info:
  title: SAN Foundation Gateway API
  version: 1.0.0
  description: |
    Public API for the SAN Foundation gateway. The same data is exposed
    through two interchangeable surfaces: `/api/v1/*` is authenticated
    with an `x-api-key` (`sk_…`) and billed in credits (per-call cost
    in `x-credits`); `/x402/v1/*` is paid per call in USDC over the
    [x402 protocol](https://x402.org) and requires no API key (per-call
    cost in `x-price-usd`).
servers:
  - url: https://gateway.sanfoundation.com
    description: Production
security: []
tags:
  - name: API Key
    description: |
      Operations under `/api/v1/*`. Authenticate with a SAN API key
      (`x-api-key` header) and pay with prepaid credits — see each
      operation's `x-credits` for the per-call cost.
  - name: x402
    description: |
      Operations under `/x402/v1/*`. Pay per call in USDC over the
      [x402 protocol](https://x402.org) — see each operation's
      `x-price-usd` for the per-call cost. No API key required.
  - name: Registration
    description: |
      Public, unauthenticated self-onboarding for agents. One call mints an
      API key and grants the signup credit so an agent can immediately use
      `/api/v1/*`. Rate limited per client IP.
paths:
  /x402/v1/web-extract:
    post:
      tags:
        - x402
      summary: Web extract
      description: Same shape as `POST /api/v1/web-extract`, paid per call via x402.
      operationId: webExtractX402
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebExtractRequest'
      responses:
        '200':
          $ref: '#/components/responses/WebExtractOk'
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '503':
          $ref: '#/components/responses/WebResearchUnavailable'
      security:
        - X402Payment: []
components:
  schemas:
    WebExtractRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: Absolute http(s) URL to fetch and extract.
        objective:
          type: string
          maxLength: 1000
          description: |
            Optional natural-language objective used to bias the
            excerpt selection toward the caller's interest.
    WebExtractResult:
      type: object
      required:
        - url
        - title
        - publish_date
        - excerpts
      properties:
        url:
          type: string
          format: uri
        title:
          type: string
        publish_date:
          type:
            - string
            - 'null'
          format: date-time
        excerpts:
          type: array
          items:
            type: string
        full_content:
          type: string
          description: Full readable text of the page.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        ref:
          type: string
          description: Echoed back when an agent ref could not be resolved.
        eventId:
          type: string
          description: Echoed back when an event id could not be resolved.
        min:
          type: integer
          description: Echoed back on a `limit out of range` error.
        max:
          type: integer
          description: Echoed back on a `limit out of range` error.
  responses:
    WebExtractOk:
      description: OK — readable content extracted from the URL.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WebExtractResult'
    BadRequest:
      description: |
        Malformed input — typically a `limit` outside the documented
        bounds for the route, an unknown agent `ref`, or a malformed
        `evt_…` id. On `/x402/v1/*`, these guards run **before** payment,
        so the client is not charged.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            limitOutOfRange:
              value:
                error: limit out of range
                min: 1
                max: 30
            agentNotFound:
              value:
                error: agent not found
                ref: unknown-handle
            badEventId:
              value:
                error: invalid event id shape
                eventId: not-an-evt
    PaymentRequired:
      description: |
        x402 payment challenge. The structured `PaymentRequired` payload
        is returned in the **`PAYMENT-REQUIRED`** response header as a
        base64-encoded JSON object — see [x402.org](https://x402.org)
        for the decoded shape (clients must accept either `x402Version: 1`
        or `x402Version: 2`).

        For non-browser clients, the response body is also a JSON
        `PaymentRequired` payload. Browser clients (those whose `Accept`
        header indicates `text/html`) instead receive a paywall HTML
        page in the body.
      headers:
        PAYMENT-REQUIRED:
          description: |
            Base64-encoded JSON `PaymentRequired` payload describing the
            x402 challenge the client must satisfy. See
            [x402.org](https://x402.org) for the decoded shape.
          schema:
            type: string
    WebResearchUnavailable:
      description: |
        The web research provider is not configured for this server.
        Operationally this means the server is missing the credentials
        needed to call the underlying research backend; it is not a
        client error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Web research provider is not configured
  securitySchemes:
    X402Payment:
      type: apiKey
      in: header
      name: Payment-Signature
      description: |
        Base64-encoded signed payment payload as defined by the
        [x402 protocol](https://x402.org). Omit on the first attempt to
        receive the `402` challenge in the `PAYMENT-REQUIRED` response
        header; include it on the retry to settle payment and receive
        the resource.

        The legacy header name `X-PAYMENT` is also accepted by the
        server for backward compatibility — clients may send either,
        but `Payment-Signature` is preferred.

        See [x402.org](https://x402.org) for the on-the-wire shape of
        the `PaymentRequired` challenge and the settlement receipt
        returned in the `PAYMENT-RESPONSE` response header.

````