---
title: "Import a previously exported memory envelope"
description: "Import an exported envelope into the caller's own memory graph.\n\nThe envelope's ``source_user_id`` is remapped to the authenticated\nuser. MERGE semantics: records with UUIDs already present in the\ntarget graph are skipped. Embedding regeneration runs asynchronously;\npoll ``GET /memories/import/{import_id}`` to track progress."
---

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

Path: AI Gateway API › Memory

`POST /memories/import`

Import an exported envelope into the caller's own memory graph.

The envelope's ``source_user_id`` is remapped to the authenticated
user. MERGE semantics: records with UUIDs already present in the
target graph are skipped. Embedding regeneration runs asynchronously;
poll ``GET /memories/import/{import_id}`` to track progress.

## Authentication

- `HTTPBearer`, http, header `Authorization`

## Header parameters

- `X-On-Behalf-Of` (`import_memories.header.X-On-Behalf-Of`; any of, optional)
  - any of: `string`, `null`
- `X-External-User-Id` (`import_memories.header.X-External-User-Id`; any of, optional)
  - any of: `string`, `null`
- `X-App-Id` (`import_memories.header.X-App-Id`; any of, optional)
  - any of: `string`, `null`

## Request body

_Required._

- `schema_version` (`import_memories.schema_version`; string, required)
- `source_user_id` (`import_memories.source_user_id`; string, required)
- `exported_at` (`import_memories.exported_at`; any of, optional)
  - any of: `string`, `null`
- `counts` (`import_memories.counts`; any of, optional)
  - any of: `map<integer>`, `null`
- `entity_nodes` (`import_memories.entity_nodes`; array<object>, optional)
- `entity_edges` (`import_memories.entity_edges`; array<object>, optional)
- `episodes` (`import_memories.episodes`; array<object>, optional)

## Example request

```json
{
  "schema_version": "string",
  "source_user_id": "string",
  "exported_at": "string",
  "counts": {
    "property1": 0,
    "property2": 0
  },
  "entity_nodes": [
    {}
  ],
  "entity_edges": [
    {}
  ],
  "episodes": [
    {}
  ]
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://truememory-api.mvstg.com/memories/import \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "schema_version": "string",
  "source_user_id": "string",
  "exported_at": "string",
  "counts": {
    "property1": 0,
    "property2": 0
  },
  "entity_nodes": [
    {}
  ],
  "entity_edges": [
    {}
  ],
  "episodes": [
    {}
  ]
}
'
```

### TypeScript

```typescript
const url = 'https://truememory-api.mvstg.com/memories/import';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    schema_version: 'string',
    source_user_id: 'string',
    exported_at: 'string',
    counts: {property1: 0, property2: 0},
    entity_nodes: [{}],
    entity_edges: [{}],
    episodes: [{}]
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://truememory-api.mvstg.com/memories/import"

payload = {
    "schema_version": "string",
    "source_user_id": "string",
    "exported_at": "string",
    "counts": {
        "property1": 0,
        "property2": 0
    },
    "entity_nodes": [{}],
    "entity_edges": [{}],
    "episodes": [{}]
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 202

Successful Response

#### Example

```json
{
  "status": "processing",
  "import_id": "string",
  "nodes_written": 0,
  "edges_written": 0,
  "episodes_written": 0,
  "edges_skipped": [
    "string"
  ]
}
```

- `import_id` (`import_memories.response.202.import_id`; string, required) — Poll GET /memories/import/{import_id} with this.
- `nodes_written` (`import_memories.response.202.nodes_written`; integer, required)
- `edges_written` (`import_memories.response.202.edges_written`; integer, required)
- `episodes_written` (`import_memories.response.202.episodes_written`; integer, required)
- `edges_skipped` (`import_memories.response.202.edges_skipped`; array<string>, required) — Ids of edges that were not imported.
- `status` (`import_memories.response.202.status`; string, optional)
  - default `"processing"`

### 422

Validation Error

#### Example

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

- `detail` (`import_memories.response.422.detail`; array<object>, optional)
  - `loc` (`import_memories.response.422.detail.loc`; array<any of>, required)
    - any of: `string`, `integer`
  - `msg` (`import_memories.response.422.detail.msg`; string, required)
  - `type` (`import_memories.response.422.detail.type`; string, required)
  - `input` (`import_memories.response.422.detail.input`; unknown, optional)
  - `ctx` (`import_memories.response.422.detail.ctx`; object, optional)


Source: https://truememory-docs.mvstg.com/api/memories/import/create/index.md
