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

# Search knowledge

> Run a natural-language query over your extracted knowledge.

Runs your question through the full [hybrid query pipeline](/platform/query): structured, full-text, and semantic signals fused, reranked, and graph-expanded over the active knowledge library. Returns ranked rule hits.

Leave `strategy` at its default (`auto`) unless you have a reason to force one. Pass `include=explain` to get per-result signal attribution, the same data the dashboard's Query Explorer shows.


## OpenAPI

````yaml openapi.yaml GET /v1/knowledge/query
openapi: 3.1.0
info:
  title: Seyn API
  version: 1.0.0
  description: >
    Programmatic access to Seyn for your organization.


    - **Ingest** data from any source with the Ingestion endpoints (requires a
    key with the `ingest` scope).

    - **Read** extracted process knowledge: search, rules, libraries,
    provenance, and metrics.


    Authenticate with a bearer API key (`sk_live_*`); each key is scoped to a
    single organization.
  contact:
    name: Seyn Support
    email: support@seynlabs.com
    url: https://seynlabs.com
servers:
  - url: https://api.seynlabs.com
    description: Production
  - url: https://api-dev.seynlabs.com
    description: Staging
security:
  - bearerAuth: []
tags:
  - name: Ingestion
    description: >-
      Push data into Seyn from any source: register a custom source and stream
      records to it
  - name: Knowledge
    description: Natural-language search over extracted knowledge
  - name: Rules
    description: Process rules, the atomic knowledge units extracted by the pipeline
  - name: Libraries
    description: Versioned snapshots of extracted knowledge for your organization
  - name: Patterns
    description: Aggregate pipeline analytics
paths:
  /v1/knowledge/query:
    get:
      tags:
        - Knowledge
      summary: Search knowledge
      description: >-
        Run a natural-language query over the organization's knowledge base.
        Returns ranked rule hits.
      operationId: knowledgeQuery
      parameters:
        - name: q
          in: query
          required: true
          schema:
            type: string
            minLength: 1
          description: The natural-language query.
          example: When does a loan need senior approval?
        - name: strategy
          in: query
          schema:
            type: string
            enum:
              - auto
              - structured
              - hybrid
              - graph
          description: Retrieval strategy. Defaults to `auto` (the analyzer picks).
        - name: topK
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 50
            default: 10
          description: Maximum number of hits to return (1–50). Defaults to 10.
        - name: libraryId
          in: query
          schema:
            type: string
            format: uuid
          description: Restrict search to a specific knowledge library.
        - name: include
          in: query
          schema:
            type: string
          description: >-
            Comma-separated list of optional fields to include. Currently only
            `explain` is supported.
          example: explain
      responses:
        '200':
          description: Search results.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessEnvelope_KnowledgeQueryResult'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    SuccessEnvelope_KnowledgeQueryResult:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/KnowledgeQueryResult'
        meta:
          allOf:
            - $ref: '#/components/schemas/Meta'
            - type: object
              properties:
                total:
                  type: integer
                strategy:
                  type: string
      required:
        - success
        - data
        - meta
    KnowledgeQueryResult:
      type: object
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/KnowledgeQueryHit'
        explain:
          $ref: '#/components/schemas/RetrievalExplain'
      required:
        - results
    Meta:
      type: object
      properties:
        requestId:
          type: string
          description: Per-request UUID; quote in support tickets.
      additionalProperties: true
      required:
        - requestId
    ErrorBody:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - MISSING_AUTH_HEADER
                - INVALID_API_KEY
                - KEY_REVOKED
                - RATE_LIMITED
                - NOT_FOUND
                - LIBRARY_NOT_FOUND
                - SOURCE_NOT_FOUND
                - VALIDATION_ERROR
                - INSUFFICIENT_SCOPE
                - PAYLOAD_TOO_LARGE
                - INTERNAL_ERROR
            message:
              type: string
          required:
            - code
            - message
      required:
        - success
        - error
    KnowledgeQueryHit:
      type: object
      properties:
        ruleId:
          type: string
          format: uuid
        description:
          type: string
        processId:
          type:
            - string
            - 'null'
        processName:
          type:
            - string
            - 'null'
        step:
          type:
            - string
            - 'null'
        confidence:
          type: number
        score:
          type: number
      required:
        - ruleId
        - description
        - processId
        - processName
        - step
        - confidence
        - score
    RetrievalExplain:
      type: object
      properties:
        strategy:
          type: string
        sqlHitCount:
          type: integer
        bm25HitCount:
          type: integer
        vectorHitCount:
          type: integer
        graphTraversalDepth:
          type: integer
        rerankerUsed:
          type: string
        latencyMs:
          type: integer
  responses:
    ValidationError:
      description: Request parameters failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          examples:
            validationError:
              value:
                success: false
                error:
                  code: VALIDATION_ERROR
                  message: Query parameter 'q' is required
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          examples:
            missing:
              summary: No Authorization header
              value:
                success: false
                error:
                  code: MISSING_AUTH_HEADER
                  message: 'Authorization: Bearer <api-key> header is required'
            invalid:
              summary: Unrecognized key
              value:
                success: false
                error:
                  code: INVALID_API_KEY
                  message: API key is invalid or unrecognized
    Forbidden:
      description: API key was revoked.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          examples:
            revoked:
              value:
                success: false
                error:
                  code: KEY_REVOKED
                  message: API key has been revoked
    RateLimited:
      description: Per-key rate limit exceeded (default 60 req/min/key).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
          examples:
            rateLimited:
              value:
                success: false
                error:
                  code: RATE_LIMITED
                  message: Rate limit exceeded for this API key
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: sk_live_*
      description: |
        Bearer token from `app.seynlabs.com` → Settings → API Keys.
        Send as `Authorization: Bearer sk_live_...`.

````