> ## 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

> Fetches a single URL and returns its `title`, `publish_date` (when known), the most relevant `excerpts[]` (optionally biased by a natural-language `objective`), and the page's `full_content` as a bare object.



## OpenAPI

````yaml https://gateway.sanfoundation.com/openapi.yaml post /api/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.
paths:
  /api/v1/web-extract:
    post:
      tags:
        - API Key
      summary: Web extract
      description: >-
        Fetches a single URL and returns its `title`, `publish_date` (when
        known), the most relevant `excerpts[]` (optionally biased by a
        natural-language `objective`), and the page's `full_content` as a bare
        object.
      operationId: webExtract
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebExtractRequest'
            examples:
              basic:
                value:
                  url: https://example.com/article
                  objective: summarize the key findings
      responses:
        '200':
          $ref: '#/components/responses/WebExtractOk'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '503':
          $ref: '#/components/responses/WebResearchUnavailable'
      security:
        - ApiKeyAuth: []
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
    Unauthorized:
      description: Missing, invalid, or revoked API key (only emitted by `/api/v1/*`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missing:
              value:
                error: Missing or invalid x-api-key header
            invalid:
              value:
                error: Invalid API key
    Forbidden:
      description: |
        The API key is valid but its owning account has no active Stripe
        subscription (status is not `active` or `trialing`). Only
        emitted by `/api/v1/*`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: >-
              Active subscription required. Please set up billing at your
              dashboard.
    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:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: |
        SAN-issued API key (`sk_…`) issued from the SAN Agents Dashboard
        (Settings → API Keys). Used by every `/api/v1/*` endpoint; usage
        is billed in credits against the owning account's active Stripe
        subscription.

````