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

# Retrieve page contents

> Retrieves clean HTML or Markdown content from a list of URLs. Supports up to 20 URLs per request (public API limit). Specify which formats to return: `html`, `markdown`, `metadata`.



## OpenAPI

````yaml /openapi/source/external/web-search/web-search.json post /web_search/contents
openapi: 3.1.0
info:
  version: 1.0.0
  title: Telnyx API
  x-latency-category: interactive
  x-endpoint-cost: light
  description: >-
    Real-time web search, page content retrieval, and deep research with
    citations, exposed through the Telnyx API Gateway and powered by the
    `telnyx-agent-web-search` service.


    ## Authentication


    All endpoints require a Telnyx API key sent as a Bearer token in the
    `Authorization` header. The API Gateway validates the key and forwards the
    verified identity to the backend service as `Telnyx-Auth-Rev2`.


    ## Rate Limits


    Default rate limit: 60 requests per minute per API key.


    ## Error Responses


    Errors follow the format `{ "error": { "message": string, "details": object
    } }`.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: Web Search
    description: Real-time web search returning structured, LLM-ready JSON results.
  - name: Contents
    description: Page content retrieval for URLs.
  - name: Research
    description: Deep research with citations and async task polling.
paths:
  /web_search/contents:
    post:
      tags:
        - Contents
      summary: Retrieve page contents
      description: >-
        Retrieves clean HTML or Markdown content from a list of URLs. Supports
        up to 20 URLs per request (public API limit). Specify which formats to
        return: `html`, `markdown`, `metadata`.
      operationId: CreateWebSearchContents
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContentsRequest'
            example:
              urls:
                - https://en.wikipedia.org/wiki/Artificial_intelligence
              formats:
                - markdown
                - metadata
              crawl_timeout: 10
              max_age: null
      responses:
        '200':
          description: Successful content retrieval response.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ContentsResponse'
              example:
                data:
                  results:
                    - url: https://en.wikipedia.org/wiki/Artificial_intelligence
                      title: Artificial intelligence - Wikipedia
                      markdown: |-
                        # Artificial intelligence

                        Artificial intelligence (AI) is...
                      metadata:
                        site_name: Wikipedia
                        favicon_url: >-
                          https://cdn.telnyx.com/favicon?domain=en.wikipedia.org&size=128
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '502':
          $ref: '#/components/responses/ProviderError'
        '504':
          $ref: '#/components/responses/ProviderTimeout'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.webSearch.contents({
              urls: ["https://en.wikipedia.org/wiki/Artificial_intelligence"],
            });

            console.log(response.data);
        - lang: Python
          source: |
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.web_search.contents(
                urls=["https://en.wikipedia.org/wiki/Artificial_intelligence"],
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.WebSearch.Contents(\n\t\tcontext.TODO(),\n\t\ttelnyx.WebSearchContentsParams{\n\t\t\tUrls: \"['https://en.wikipedia.org/wiki/Artificial_intelligence']\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.webSearch.WebSearchContentsParams;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    WebSearchContentsParams params = WebSearchContentsParams.builder()
                        .urls(["https://en.wikipedia.org/wiki/Artificial_intelligence"])
                        .build();
                    var response = client.webSearch().contents(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            response = telnyx.web_search.contents(urls:
            ["https://en.wikipedia.org/wiki/Artificial_intelligence"])


            puts(response)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $response = $client->webSearch->contents(
                urls: ["https://en.wikipedia.org/wiki/Artificial_intelligence"],
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx web-search contents \
              --api-key 'My API Key' \
              --urls https://en.wikipedia.org/wiki/Artificial_intelligence
components:
  schemas:
    ContentsRequest:
      type: object
      required:
        - urls
      properties:
        urls:
          type: array
          items:
            type: string
            format: uri
          minItems: 1
          maxItems: 20
          description: List of URLs to retrieve content from (max 20 for public API).
          example:
            - https://en.wikipedia.org/wiki/Artificial_intelligence
        formats:
          type: array
          items:
            type: string
            enum:
              - html
              - markdown
              - metadata
          maxItems: 3
          description: >-
            Content formats to return. If omitted, `html` and `metadata` are
            returned by default. Retrieval is best-effort per URL: a format
            field appears only when that content could be produced, and a
            freshly crawled page may also include `html` even when not
            requested.
          example:
            - markdown
            - metadata
        crawl_timeout:
          type: integer
          minimum: 1
          maximum: 60
          description: Timeout for crawling each URL, in seconds (1-60).
          example: 10
        max_age:
          type:
            - integer
            - 'null'
          minimum: 0
          description: Maximum age of cached content in seconds. `null` means no limit.
          example: null
    ContentsResponse:
      type: object
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/ContentResult'
    ContentResult:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: The source URL.
        title:
          type: string
          description: Page title (if available).
        html:
          type: string
          description: >-
            Cleaned HTML content (if `html` format requested; may also be
            present on freshly crawled pages).
        markdown:
          type: string
          description: Markdown content (if `markdown` format requested).
        metadata:
          type: object
          properties:
            site_name:
              type: string
              description: Site name. Often empty.
            favicon_url:
              type: string
              format: uri
              description: Favicon URL (if available).
          additionalProperties: true
          description: Page metadata (if `metadata` format requested).
    WebSearchError:
      type: object
      properties:
        error:
          type: object
          required:
            - message
          properties:
            message:
              type: string
              description: Human-readable error message.
            details:
              type: object
              additionalProperties: true
              description: Additional error details (e.g. validation field errors).
    GatewayError:
      type: object
      description: >-
        Standard Telnyx JSON:API error envelope returned by the API Gateway for
        authentication failures (401).
      required:
        - errors
      properties:
        errors:
          type: array
          items:
            type: object
            required:
              - code
              - title
            properties:
              code:
                type: string
                description: Telnyx error code.
              title:
                type: string
                description: Error title.
              detail:
                type: string
                description: Human-readable error detail.
              source:
                type: object
                properties:
                  pointer:
                    type: string
              meta:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
  responses:
    BadRequest:
      description: Invalid request — validation error or invalid parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WebSearchError'
          example:
            error:
              message: Validation error
              details: {}
    Unauthorized:
      description: >-
        Unauthorized — missing or invalid API key.


        The API Gateway returns this response before the request reaches the
        backend service. The error format follows the standard Telnyx JSON:API
        error envelope with `errors[]`, not the backend-level `WebSearchError`
        shape.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GatewayError'
          example:
            errors:
              - code: '10009'
                title: Authentication failed
                detail: Could not find any usable credentials in the request.
                meta:
                  url: https://developers.telnyx.com/docs/overview/errors/10009
    InternalServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WebSearchError'
          example:
            error:
              message: Internal server error
    ProviderError:
      description: The upstream search provider returned an error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WebSearchError'
          example:
            error:
              message: Provider request failed
    ProviderTimeout:
      description: The upstream search provider timed out.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/WebSearchError'
          example:
            error:
              message: Provider request timed out
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Telnyx API key

````