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

# Insert Data to a User

Insert new memory data (blob) for a specific user. This endpoint handles the storage of memory data and automatically updates the user's memory buffer.

The inserted data will be processed and integrated into the user's long-term memory profile.

Memobase plans to support the following blob types:

* `ChatBlob`: ✅ [supported](/api-reference/blobs/modal/chat).
* `SummaryBlob`: ✅ [supported](/api-reference/blobs/modal/summary).
* `DocBlob`: 🚧 in progress
* `ImageBlob`: 🚧 in progress
* `CodeBlob`: 🚧 in progress
* `TranscriptBlob`: 🚧 in progress


## OpenAPI

````yaml post /api/v1/blobs/insert/{user_id}
openapi: 3.1.0
info:
  title: Memobase API
  summary: APIs for Memobase, a user memory system for LLM Apps
  version: 0.0.40
servers:
  - url: https://api.memobase.dev
  - url: https://api.memobase.cn
security:
  - BearerAuth: []
paths:
  /api/v1/blobs/insert/{user_id}:
    post:
      tags:
        - blob
      summary: Insert Blob
      operationId: insert_blob_api_v1_blobs_insert__user_id__post
      parameters:
        - name: user_id
          in: path
          required: true
          schema:
            anyOf:
              - type: string
                format: uuid4
              - type: string
                format: uuid5
            description: The ID of the user to insert the blob for
            title: User Id
          description: The ID of the user to insert the blob for
        - name: wait_process
          in: query
          required: false
          schema:
            type: boolean
            description: Whether to wait for the blob to be processed
            default: false
            title: Wait Process
          description: Whether to wait for the blob to be processed
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BlobData'
              description: The blob data to insert
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlobInsertResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-code-samples:
        - lang: python
          source: >+
            # To use the Python SDK, install the package:

            # pip install memobase


            from memobase import MemoBaseClient

            from memobase.core.blob import ChatBlob


            client = MemoBaseClient(project_url='PROJECT_URL',
            api_key='PROJECT_TOKEN')


            b = ChatBlob(messages=[
                {
                    "role": "user",
                    "content": "Hi, I'm here again"
                },
                {
                    "role": "assistant",
                    "content": "Hi, Gus! How can I help you?"
                }
            ])

            u = client.get_user(uid)

            bid = u.insert(b)

          label: Python
        - lang: javascript
          source: >+
            // To use the JavaScript SDK, install the package:

            // npm install @memobase/memobase


            import { MemoBaseClient, Blob, BlobType } from '@memobase/memobase';


            const client = new MemoBaseClient(process.env.MEMOBASE_PROJECT_URL,
            process.env.MEMOBASE_API_KEY);

            const user = await client.getUser(userId);


            const blobId = await user.insert(Blob.parse({
              type: BlobType.Enum.chat,
              messages: [
                {
                  role: 'user',
                  content: 'Hi, I'm here again'
                },
                {
                  role: 'assistant',
                  content: 'Hi, Gus! How can I help you?'
                }
              ]
            }));

          label: JavaScript
        - lang: go
          source: >+
            // To use the Go SDK, install the package:

            // go get
            github.com/memodb-io/memobase/src/client/memobase-go@latest


            import (
                "fmt"
                "log"

                "github.com/memodb-io/memobase/src/client/memobase-go/blob"
                "github.com/memodb-io/memobase/src/client/memobase-go/core"
            )


            func main() {
                projectURL := "YOUR_PROJECT_URL"
                apiKey := "YOUR_API_KEY"
                // Initialize the client
                client, err := core.NewMemoBaseClient(
                    projectURL,
                    apiKey,
                )
                if err != nil {
                    log.Fatalf("Failed to create client: %v", err)
                }

                // Get a user
                userID := "EXISTING_USER_ID" // Replace with an actual user ID
                user, err := client.GetUser(userID, false)
                if err != nil {
                    log.Fatalf("Failed to get user: %v", err)
                }

                // Create a chat blob
                chatBlob := &blob.ChatBlob{
                    BaseBlob: blob.BaseBlob{
                        Type: blob.ChatType,
                    },
                    Messages: []blob.OpenAICompatibleMessage{
                        {
                            Role:    "user",
                            Content: "Hello, I am Jinjia!",
                        },
                        {
                            Role:    "assistant",
                            Content: "Hi there! How can I help you today?",
                        },
                    },
                }

                // Insert the blob
                blobID, err := user.Insert(chatBlob, false)
                if err != nil {
                    log.Fatalf("Failed to insert blob: %v", err)
                }
                fmt.Printf("Successfully inserted blob with ID: %s
            ", blobID)

            }

          label: Go
components:
  schemas:
    BlobData:
      properties:
        blob_type:
          $ref: '#/components/schemas/BlobType'
        blob_data:
          additionalProperties: true
          type: object
          title: Blob Data
        fields:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Fields
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
      type: object
      required:
        - blob_type
        - blob_data
      title: BlobData
    BlobInsertResponse:
      properties:
        data:
          anyOf:
            - $ref: '#/components/schemas/BlobInsertData'
            - type: 'null'
          description: Response containing blob insert data
        errno:
          $ref: '#/components/schemas/CODE'
          description: Error code, 0 means success
          default: 0
        errmsg:
          type: string
          title: Errmsg
          description: Error message, empty when success
          default: ''
      type: object
      title: BlobInsertResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    BlobType:
      type: string
      enum:
        - chat
        - summary
        - doc
        - image
        - code
        - transcript
      title: BlobType
    BlobInsertData:
      properties:
        id:
          anyOf:
            - type: string
              format: uuid4
            - type: string
              format: uuid5
          title: Id
          description: The UUID identifier
        chat_results:
          anyOf:
            - items:
                $ref: '#/components/schemas/ChatModalResponse'
              type: array
            - type: 'null'
          title: Chat Results
          description: List of chat modal data
      type: object
      required:
        - id
      title: BlobInsertData
    CODE:
      type: integer
      enum:
        - 0
        - 400
        - 401
        - 403
        - 404
        - 405
        - 409
        - 422
        - 500
        - 501
        - 502
        - 503
        - 504
        - 520
      title: CODE
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ChatModalResponse:
      properties:
        event_id:
          anyOf:
            - type: string
              format: uuid4
            - type: string
              format: uuid5
            - type: 'null'
          title: Event Id
          description: The event's unique identifier
        add_profiles:
          anyOf:
            - items:
                anyOf:
                  - type: string
                    format: uuid4
                  - type: string
                    format: uuid5
              type: array
            - type: 'null'
          title: Add Profiles
          description: List of added profiles' ids
        update_profiles:
          anyOf:
            - items:
                anyOf:
                  - type: string
                    format: uuid4
                  - type: string
                    format: uuid5
              type: array
            - type: 'null'
          title: Update Profiles
          description: List of updated profiles' ids
        delete_profiles:
          anyOf:
            - items:
                anyOf:
                  - type: string
                    format: uuid4
                  - type: string
                    format: uuid5
              type: array
            - type: 'null'
          title: Delete Profiles
          description: List of deleted profiles' ids
      type: object
      required:
        - event_id
        - add_profiles
        - update_profiles
        - delete_profiles
      title: ChatModalResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````