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

# Replace Document

> Replace an existing knowledge document (atomic backup/restore on failure).



## OpenAPI

````yaml /api-reference/openapi-oss.json put /api/v1/knowledge/documents/{doc_id}
openapi: 3.1.0
info:
  title: everos
  description: md-first memory extraction framework
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/knowledge/documents/{doc_id}:
    put:
      tags:
        - knowledge
      summary: Replace Document
      description: >-
        Replace an existing knowledge document (atomic backup/restore on
        failure).
      operationId: replace_document_route_api_v1_knowledge_documents__doc_id__put
      parameters:
        - name: doc_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^d_[a-f0-9]{12,32}$
            title: Doc Id
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_replace_document_route_api_v1_knowledge_documents__doc_id__put
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessEnvelope_DocumentCreateResponse_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_replace_document_route_api_v1_knowledge_documents__doc_id__put:
      properties:
        file:
          type: string
          contentMediaType: application/octet-stream
          title: File
        title:
          type: string
          minLength: 1
          pattern: \w
          title: Title
        source_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Type
        category_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Category Id
        app_id:
          type: string
          title: App Id
          default: default
        project_id:
          type: string
          title: Project Id
          default: default
      type: object
      required:
        - file
        - title
      title: Body_replace_document_route_api_v1_knowledge_documents__doc_id__put
    SuccessEnvelope_DocumentCreateResponse_:
      properties:
        request_id:
          type: string
          title: Request Id
        data:
          $ref: '#/components/schemas/DocumentCreateResponse'
      type: object
      required:
        - request_id
        - data
      title: SuccessEnvelope[DocumentCreateResponse]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    DocumentCreateResponse:
      properties:
        doc_id:
          type: string
          title: Doc Id
        category_id:
          type: string
          title: Category Id
        topic_count:
          type: integer
          title: Topic Count
        source_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Name
        md_path:
          type: string
          title: Md Path
        original_file_path:
          anyOf:
            - type: string
            - type: 'null'
          title: Original File Path
      type: object
      required:
        - doc_id
        - category_id
        - topic_count
        - source_name
        - md_path
        - original_file_path
      title: DocumentCreateResponse
      description: Response for POST/PUT /documents.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````