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

# Migrate

> Import markdown files (e.g., OpenClaw memory files) as MemoClaw memories.

Parses markdown files, splits by `##` headers, auto-detects importance and memory type, and stores each section as a separate memory. Idempotent — duplicate content is deduplicated via content hashing.

## Request Body

<ParamField body="files" type="array" required>
  Array of file objects to import. Maximum **50 files** per request.

  <Expandable title="File object">
    <ParamField body="filename" type="string" required>
      Original filename (e.g., `2026-01-30.md`). Dates in `YYYY-MM-DD` format are extracted and added as tags.
    </ParamField>

    <ParamField body="content" type="string" required>
      Raw markdown content of the file.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="files_processed" type="integer">
  Number of files successfully processed.
</ResponseField>

<ResponseField name="memories_created" type="integer">
  Number of new memories stored.
</ResponseField>

<ResponseField name="memories_deduplicated" type="integer">
  Number of memories skipped due to duplicate content.
</ResponseField>

<ResponseField name="errors" type="array">
  Present only if some files failed. Each entry has `filename` and `error`.
</ResponseField>

<RequestExample>
  ```bash curl theme={null}
  curl -X POST https://api.memoclaw.com/v1/migrate \
    -H "Content-Type: application/json" \
    -d '{
      "files": [
        {
          "filename": "2026-01-30.md",
          "content": "## Project Setup\nDecided to use PostgreSQL with pgvector.\n\n## Config\nUser prefers dark mode."
        }
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "files_processed": 1,
    "memories_created": 2,
    "memories_deduplicated": 0
  }
  ```
</ResponseExample>

## How parsing works

1. Each file is split on `## ` headers
2. Each section becomes one memory with:
   * **content**: header + body text (max 8,000 chars)
   * **importance**: 0.6–0.9 based on keyword heuristics (decisions=0.9, preferences=0.8, etc.)
   * **memory\_type**: auto-detected (`decision`, `preference`, `correction`, `project`, `observation`, `general`)
   * **tags**: header words + `date:YYYY-MM-DD` from filename + `migrated` + `openclaw`
3. Content is SHA-256 hashed for intra-batch and cross-request deduplication
4. Files without `##` headers are stored as a single memory

## Pricing

| Endpoint           | Cost               |
| ------------------ | ------------------ |
| `POST /v1/migrate` | \$0.01 per request |
