Ask Fern API

Fern's hosted public REST API for the AI-powered "Ask Fern" documentation search. Index a documentation website, poll indexing job status, and query the indexed content for grounded, hallucination-resistant answers to build your own support integrations. Authenticated with a Bearer token from `fern token`; available on Team and Enterprise plans. The website index/status endpoints are grounded in the published reference; the /ask query shape is modeled.

OpenAPI Specification

fern-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Fern Ask Fern API
  description: >-
    The Ask Fern API is Fern's hosted, public REST surface for the "Ask Fern"
    AI documentation-search feature. It lets you index a documentation website
    and then query it programmatically, so you can build your own support
    integrations on top of Fern's AI-powered, docs-grounded answers. This is the
    primary documented hosted REST API that Fern exposes to customers; the rest
    of the Fern platform (SDK generation, docs generation, API-reference builds)
    is driven through the open-source `fern` CLI and the Fern dashboard rather
    than a public REST API. Requests are authenticated with a Bearer token
    generated by the `fern token` CLI command; the Ask Fern API is available on
    the Team and Enterprise plans. The website index/status endpoints are
    grounded in Fern's published API reference; the /ask query endpoint shape is
    modeled from the documented feature and should be reconciled against the live
    reference. Not all fields are exhaustively documented here.
  version: '1.0'
  contact:
    name: Fern
    url: https://buildwithfern.com
  license:
    name: Apache-2.0
    url: https://github.com/fern-api/fern/blob/main/LICENSE
servers:
  - url: https://fai.buildwithfern.com
    description: Ask Fern API (production)
security:
  - bearerAuth: []
tags:
  - name: Website Sources
    description: Index documentation websites and check indexing job status.
  - name: Ask
    description: Query indexed documentation for AI-generated, grounded answers.
paths:
  /sources/website/{domain}/index:
    post:
      operationId: indexWebsite
      tags:
        - Website Sources
      summary: Index a documentation website
      description: >-
        Start an indexing job that crawls and indexes the pages of a
        documentation website so its content can be queried through Ask Fern.
        Returns a job_id used to poll indexing status. (Path and body modeled
        from the documented feature; reconcile against the live reference.)
      parameters:
        - name: domain
          in: path
          required: true
          description: The documentation domain to index (for example, docs.example.com).
          schema:
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                base_url:
                  type: string
                  description: Base URL to begin crawling from.
      responses:
        '200':
          description: Indexing job accepted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  job_id:
                    type: string
                    description: Identifier of the indexing job to poll for status.
        '401':
          $ref: '#/components/responses/Unauthorized'
  /sources/website/{domain}/status:
    get:
      operationId: getWebsiteStatus
      tags:
        - Website Sources
      summary: Get website indexing status
      description: >-
        Return the status of a website indexing job, including how many pages
        were indexed or failed.
      parameters:
        - name: domain
          in: path
          required: true
          description: The documentation domain being indexed.
          schema:
            type: string
        - name: job_id
          in: query
          required: true
          description: The job ID returned from the index endpoint.
          schema:
            type: string
      responses:
        '200':
          description: Indexing job status.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebsiteStatus'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /ask:
    get:
      operationId: askFern
      tags:
        - Ask
      summary: Ask a question against indexed documentation
      description: >-
        Submit a natural-language question and receive an AI-generated answer
        grounded in the indexed documentation. (Query-parameter shape modeled
        from the documented Ask Fern feature; reconcile against the live
        reference. Some deployments expose the ask endpoint under
        https://buildwithfern.com/learn/api/fern-docs/ask.)
      parameters:
        - name: q
          in: query
          required: true
          description: URI-encoded natural-language question.
          schema:
            type: string
      responses:
        '200':
          description: A grounded answer with source references.
          content:
            application/json:
              schema:
                type: object
                properties:
                  answer:
                    type: string
                  sources:
                    type: array
                    items:
                      type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token generated with the `fern token` CLI command. Passed as
        `Authorization: Bearer YOUR_API_TOKEN`. Tokens are scoped to your
        organization and do not expire.
  responses:
    Unauthorized:
      description: Missing or invalid API token.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
  schemas:
    WebsiteStatus:
      type: object
      properties:
        job_id:
          type: string
        status:
          type: string
          description: 'Job status: PENDING, PROCESSING, COMPLETED, or FAILED.'
          enum:
            - PENDING
            - PROCESSING
            - COMPLETED
            - FAILED
        base_url:
          type: string
        pages_indexed:
          type: integer
          description: Count of successfully indexed pages.
        pages_failed:
          type: integer
          description: Count of pages that failed to index.
        error:
          type: string
          nullable: true
          description: Error message if the job failed.