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

# Ingest context vault document

> Adds workspace knowledge from extracted text, a public file URL, or a
documentation/web URL.

Use `content` when your app already has clean text or Markdown. Use
`uri` with a file `sourceType` for public PDF, DOCX, Markdown, TXT, CSV,
or image URLs. Use `sourceType: url` for documentation sites and web
pages.




## OpenAPI

````yaml /openapi.yaml post /api/context-vault/documents
openapi: 3.1.0
info:
  title: MemContext API
  version: 1.1.0
  description: |
    REST API for persistent, evolving AI memory. Save, search, and manage
    memories with automatic deduplication, version chains, and hybrid retrieval.
servers:
  - url: https://api.memcontext.in
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Memories
    description: Save, search, list, update, and delete memories.
  - name: History
    description: Inspect how memories evolve over time.
  - name: Feedback
    description: Rate retrieval quality to improve future results.
  - name: Profiles
    description: Pre-aggregated user context from memory.
  - name: Workspaces
    description: >-
      Company/team account boundaries for billing, members, API keys, and
      vaults.
  - name: API Keys
    description: Workspace-bound API keys for server-side integrations.
  - name: Subscription
    description: Workspace-owned billing and member-memory limits.
  - name: Context Vault
    description: Document ingestion and workspace RAG retrieval.
paths:
  /api/context-vault/documents:
    post:
      tags:
        - Context Vault
      summary: Ingest context vault document
      description: |
        Adds workspace knowledge from extracted text, a public file URL, or a
        documentation/web URL.

        Use `content` when your app already has clean text or Markdown. Use
        `uri` with a file `sourceType` for public PDF, DOCX, Markdown, TXT, CSV,
        or image URLs. Use `sourceType: url` for documentation sites and web
        pages.
      operationId: ingestContextVaultDocument
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IngestContextVaultDocumentRequest'
      responses:
        '202':
          description: Document accepted and added to the workspace document list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IngestContextVaultDocumentResponse'
      security:
        - ApiKeyAuth: []
        - CookieAuth: []
components:
  schemas:
    IngestContextVaultDocumentRequest:
      type: object
      required:
        - workspaceId
        - title
      properties:
        workspaceId:
          type: string
          format: uuid
        vaultId:
          type: string
          format: uuid
          description: >-
            Optional vault inside the workspace. Defaults to the workspace's
            default vault.
        title:
          type: string
          maxLength: 200
        content:
          type: string
          maxLength: 250000
          description: >-
            Extracted text/Markdown for v1 JSON ingestion. Required unless `uri`
            is provided.
        sourceType:
          $ref: '#/components/schemas/DocumentSourceType'
        scope:
          type: string
          maxLength: 200
        project:
          type: string
          maxLength: 100
        mimeType:
          type: string
        originalFilename:
          type: string
        uri:
          type: string
          format: uri
          description: >-
            Public documentation/web URL or public file URL. Set `sourceType`
            for file URLs such as `pdf`, `docx`, `markdown`, `text`, `csv`, or
            an image type.
        crawlSubpages:
          type: boolean
          default: true
          description: >-
            Crawl linked subpages from a documentation/web URL. For docs sites
            with `llms.txt`, MemContext discovers canonical pages first and
            ingests only priority pages. Ignored for remote file URL ingestion.
        priorityPageLimit:
          type: integer
          minimum: 1
          maximum: 25
          default: 15
          description: >-
            Maximum priority pages to fetch from a discovered docs index such as
            `llms.txt`.
        subpageTarget:
          type: array
          maxItems: 8
          items:
            type: string
            maxLength: 100
          description: Terms to prioritize when crawling subpages.
        category:
          $ref: '#/components/schemas/MemoryCategory'
    IngestContextVaultDocumentResponse:
      type: object
      required:
        - document
        - chunkCount
        - extractedCount
        - status
        - message
      properties:
        document:
          $ref: '#/components/schemas/ContextVaultDocument'
        chunkCount:
          type: integer
        extractedCount:
          type: integer
        status:
          type: string
          enum:
            - accepted
        message:
          type: string
    DocumentSourceType:
      type: string
      enum:
        - pdf
        - markdown
        - text
        - docx
        - html
        - url
        - csv
        - png
        - jpg
        - jpeg
        - webp
        - tiff
    MemoryCategory:
      type: string
      enum:
        - preference
        - fact
        - decision
        - context
      description: |
        - `preference` - User likes or dislikes (e.g. "prefers dark mode").
        - `fact` - Objective information (e.g. "uses macOS").
        - `decision` - Choices made (e.g. "chose the new billing provider").
        - `context` - Background information (e.g. "working on e-commerce app").
    ContextVaultDocument:
      type: object
      required:
        - id
        - sourceType
        - status
        - chunkCount
        - extractedCount
        - totalChunks
        - processedChunks
        - createdAt
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
          nullable: true
        sourceType:
          type: string
        status:
          $ref: '#/components/schemas/ContextVaultDocumentStatus'
        chunkCount:
          type: integer
        extractedCount:
          type: integer
        totalChunks:
          type: integer
        processedChunks:
          type: integer
        processingPhase:
          type: string
          nullable: true
        heartbeatAt:
          type: string
          format: date-time
          nullable: true
        scope:
          type: string
          nullable: true
        project:
          type: string
          nullable: true
        createdAt:
          type: string
          format: date-time
        completedAt:
          type: string
          format: date-time
          nullable: true
        error:
          type: string
          nullable: true
        publicUrl:
          type: string
          nullable: true
    ContextVaultDocumentStatus:
      type: string
      enum:
        - pending
        - processing
        - retrying
        - completed
        - failed
        - cancelled
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >
        API key created from the MemContext dashboard. Keys are prefixed with
        `mc_`, bound to one workspace, and API-key requests cannot override that
        workspace.
    CookieAuth:
      type: apiKey
      in: cookie
      name: better-auth.session_token
      description: Dashboard session cookie used for workspace/company endpoints.

````