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

# Rerank documents

> Reranks candidate snippets for a query.



## OpenAPI

````yaml POST /v1/rerank
openapi: 3.1.0
info:
  title: SHARC MCP Backend API
  version: 1.0.0
  description: >-
    HTTP endpoints used by the SHARC MCP server for indexing and semantic search
    workflows.
servers:
  - url: https://api.sharc.sh
    description: Production
security: []
paths:
  /v1/rerank:
    post:
      tags:
        - MCP backend
      summary: Rerank candidate documents
      description: Reranks candidate snippets for a query.
      operationId: rerankDocuments
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RerankRequest'
      responses:
        '200':
          description: Rerank results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RerankResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - apiKey: []
components:
  schemas:
    RerankRequest:
      type: object
      properties:
        query:
          type: string
        documents:
          type: array
          items:
            oneOf:
              - type: string
              - type: object
                properties:
                  text:
                    type: string
                required:
                  - text
          maxItems: 1000
      required:
        - query
        - documents
    RerankResponse:
      type: object
      properties:
        results:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              relevance_score:
                type: number
            required:
              - index
              - relevance_score
      required:
        - results
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type:
                - string
                - 'null'
            code:
              type:
                - string
                - 'null'
          required:
            - message
            - type
      required:
        - error
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Pass your key in Authorization: Bearer <key>.'

````