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

# Create Memory Export

> Submit an export job to create a structured memory export using a customizable Pydantic schema and filters.

Submit a job to create a structured export of memories using a customizable Pydantic schema. This process may take some time to complete, especially if you're exporting a large number of memories. You can tailor the export by applying various filters (e.g., `user_id`, `agent_id`, `app_id`, or `run_id`) and by modifying the Pydantic schema to ensure the final data matches your exact needs.


## OpenAPI

````yaml post /v1/exports/
openapi: 3.0.1
info:
  title: Mem0 API Docs
  description: mem0.ai API Docs
  contact:
    email: support@mem0.ai
  license:
    name: Apache 2.0
  version: v1
servers:
  - url: https://api.mem0.ai/
security:
  - ApiKeyAuth: []
paths:
  /v1/exports/:
    post:
      tags:
        - exports
      summary: Create an export job with schema
      description: Create a structured export of memories based on a provided schema.
      operationId: exports_create
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - schema
              properties:
                schema:
                  type: object
                  description: Schema definition for the export
                filters:
                  type: object
                  properties:
                    user_id:
                      type: string
                    agent_id:
                      type: string
                    app_id:
                      type: string
                    run_id:
                      type: string
                  description: >-
                    Filters to apply while exporting memories. Available fields
                    are: user_id, agent_id, app_id, run_id.
                org_id:
                  type: string
                  description: Filter exports by organization ID.
                project_id:
                  type: string
                  description: Filter exports by project ID.
        required: true
      responses:
        '201':
          description: Export created successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: >-
                      Memory export request received. The export will be ready
                      in a few seconds.
                  id:
                    type: string
                    format: uuid
                    example: 550e8400-e29b-41d4-a716-446655440000
                required:
                  - message
                  - id
        '400':
          description: Bad Request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Schema is required and must be a valid object
      x-code-samples:
        - lang: Python
          source: |-
            # To use the Python SDK, install the package:
            # pip install mem0ai

            from mem0 import MemoryClient

            client = MemoryClient(api_key="your_api_key")

            json_schema = {pydantic_json_schema}
            filters = {
                "AND": [
                    {"user_id": "alex"}
                ]
            }

            response = client.create_memory_export(
                schema=json_schema,
                filters=filters
            )
            print(response)
        - lang: JavaScript
          source: |-
            // To use the JavaScript SDK, install the package:
            // npm i mem0ai

            import MemoryClient from 'mem0ai';
            const client = new MemoryClient({ apiKey: "your-api-key" });

            const jsonSchema = {pydantic_json_schema};
            const filters = {
              AND: [
                {user_id: 'alex'}
              ]
            };

            client.createMemoryExport({
              schema: jsonSchema,
              filters: filters
            })
              .then(result => console.log(result))
              .catch(error => console.error(error));
        - lang: cURL
          source: |-
            curl --request POST \
              --url 'https://api.mem0.ai/v1/exports/' \
              --header 'Authorization: Token <api-key>' \
              --header 'Content-Type: application/json' \
              --data '{
                "schema": {pydantic_json_schema},
                "filters": {
                  "AND": [
                    {"user_id": "alex"}
                  ]
                }
              }'
        - lang: Go
          source: "package main\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\turl := \"https://api.mem0.ai/v1/exports/\"\n\n\tfilters := map[string]interface{}{\n\t\t\"AND\": []map[string]interface{}{\n\t\t\t{\"user_id\": \"alex\"},\n\t\t},\n\t}\n\n\tdata := map[string]interface{}{\n\t\t\"schema\": map[string]interface{}{}, // Your schema here\n\t\t\"filters\": filters,\n\t}\n\n\tjsonData, _ := json.Marshal(data)\n\n\treq, _ := http.NewRequest(\"POST\", url, bytes.NewBuffer(jsonData))\n\n\treq.Header.Add(\"Authorization\", \"Token <api-key>\")\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(string(body))\n}"
        - lang: PHP
          source: |-
            <?php

            $curl = curl_init();

            $filters = [
              'AND' => [
                ['user_id' => 'alex']
              ]
            ];

            $data = array(
              "schema" => array(), // Your schema here
              "filters" => $filters
            );

            curl_setopt_array($curl, [
              CURLOPT_URL => "https://api.mem0.ai/v1/exports/",
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_ENCODING => "",
              CURLOPT_MAXREDIRS => 10,
              CURLOPT_TIMEOUT => 30,
              CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
              CURLOPT_CUSTOMREQUEST => "POST",
              CURLOPT_POSTFIELDS => json_encode($data),
              CURLOPT_HTTPHEADER => [
                "Authorization: Token <api-key>",
                "Content-Type: application/json"
              ],
            ]);

            $response = curl_exec($curl);
            $err = curl_error($curl);

            curl_close($curl);

            if ($err) {
              echo "cURL Error #:" . $err;
            } else {
              echo $response;
            }
        - lang: Java
          source: >-
            import com.mashape.unirest.http.HttpResponse;

            import com.mashape.unirest.http.JsonNode;

            import com.mashape.unirest.http.Unirest;

            import org.json.JSONObject;

            import org.json.JSONArray;


            JSONObject filters = new JSONObject()
                .put("AND", new JSONArray()
                    .put(new JSONObject().put("user_id", "alex")));

            JSONObject data = new JSONObject()
                .put("schema", new JSONObject()) // Your schema here
                .put("filters", filters);

            HttpResponse<JsonNode> response =
            Unirest.post("https://api.mem0.ai/v1/exports/")
              .header("Authorization", "Token <api-key>")
              .header("Content-Type", "application/json")
              .body(data.toString())
              .asJson();
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Prefix your Mem0 API key with 'Token '. Example:
        'Token your_api_key'

````