> ## 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.

# Save a memory

> Save a durable preference, fact, decision, or piece of context. If
similar content already exists, MemContext may update, extend, or
deduplicate it instead of creating a separate memory.




## OpenAPI

````yaml /openapi.yaml post /api/memories
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/memories:
    post:
      tags:
        - Memories
      summary: Save a memory
      description: |
        Save a durable preference, fact, decision, or piece of context. If
        similar content already exists, MemContext may update, extend, or
        deduplicate it instead of creating a separate memory.
      operationId: saveMemory
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SaveMemoryRequest'
      responses:
        '201':
          description: Memory saved, updated, extended, or deduplicated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SaveMemoryResponse'
        '202':
          description: Memory accepted for asynchronous extraction into atomic memories.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SaveMemoryResponse'
        '403':
          description: Memory limit exceeded for the current plan.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SaveMemoryRequest:
      type: object
      required:
        - content
      properties:
        content:
          type: string
          maxLength: 10000
          description: >-
            The memory content. Write as a clear, complete, searchable
            statement.
        category:
          $ref: '#/components/schemas/MemoryCategory'
        scope:
          type: string
          maxLength: 200
          description: >-
            Hard isolation boundary for the memory container. Use a stable user
            or tenant ID from your app.
        project:
          type: string
          maxLength: 100
          description: >-
            Grouping filter inside the selected scope. Format: lowercase, no
            spaces (e.g. `memcontext`).
        source:
          $ref: '#/components/schemas/MemorySource'
        validUntil:
          type: string
          format: date-time
          description: >-
            ISO 8601 datetime when this memory expires. Omit for permanent
            memories.
    SaveMemoryResponse:
      type: object
      required:
        - status
      properties:
        id:
          type: string
          format: uuid
          description: ID of the saved or matched memory for synchronous results.
        jobId:
          type: string
          format: uuid
          description: Job/source ID for tracking accepted long-content extraction.
        status:
          type: string
          enum:
            - saved
            - updated
            - extended
            - duplicate
            - accepted
          description: >
            - `saved` - New memory created.

            - `updated` - New memory superseded an existing one.

            - `extended` - New memory extends an existing one (relation
            created).

            - `duplicate` - Content already exists; no new memory created.

            - `accepted` - Large content was accepted for asynchronous
            extraction into atomic memories.
        superseded:
          type: string
          format: uuid
          description: ID of the memory that was superseded (when status is `updated`).
        existingId:
          type: string
          format: uuid
          description: ID of the existing duplicate (when status is `duplicate`).
        message:
          type: string
          description: Optional human-readable acknowledgement for asynchronous extraction.
        reservedSlots:
          type: integer
          minimum: 0
          description: Number of memory slots reserved while a long-content job is pending.
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
        code:
          type: string
          description: Machine-readable error code (e.g. `HTTP_404`, `INTERNAL_ERROR`).
        requestId:
          type: string
          description: >-
            Unique request ID for tracing. Also returned in the `X-Request-Id`
            response header.
        errorId:
          type: string
          description: Unique error ID for support reference (format `ERR_XXXXXXXX`).
    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").
    MemorySource:
      type: string
      enum:
        - mcp
        - web
        - api
        - openclaw
      description: |
        Where the memory originated.
        - `mcp` - Saved via MCP tool.
        - `web` - Saved from the dashboard.
        - `api` - Saved via REST API (default).
        - `openclaw` - Saved via OpenClaw integration.
  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.

````