Skip to main content

Create a Mem

Overview#

Get started in just 2 minutes! Then check out our other examples below for more advanced use cases.

First, you'll need an API Access Token from our new API Flow in the Mem app. You'll be able to make authorized requests to the API with this token.

Using the Mem Node.js client: @mem-labs/mem-node

Set up the client
import { MemClient } from "@mem-labs/mem-node";
const memClient = new MemClient({
apiAccessToken: "<Replace this with your access token>"
});
Create a mem
memClient.createMem({
content: "Hello there! I am a new mem."
});

Parameters#

You can create a mem by using the Node.js client, or by making a request to our REST API.

Keep it as simple as only specifying the mem's content, or as customized as including the exact time to surface the mem to a user. You decide!

POST
https://api.mem.ai/v0/mems
NameTypeDescription
contentstringRequired The contents of the mem. The string should be in a markdown-compatible format. For more details, see the Mem Markdown Format.
isReadbooleanOptional Indicates whether the mem should be automatically marked as "read" (unread mems are highlighted within the default views in the product UI). Defaults to false.
isArchivedbooleanOptional Indicates whether the mem should be automatically marked as "archived" (archived mems are hidden from the default views in the product UI). Defaults to false.
scheduledForstringOptional Specify a time that this mem will resurface at (similar to the "snooze" button in the product UI). This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
createdAtstringOptional Specify the time that the mem was created at. Defaults to the current time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ

Usage Limits#

  • The content of a mem is limited to roughly 100,000 characters

Examples#

Start Simple#

When creating new mems, the content parameter represents the initial content of the new mem. We will automatically perform some mem-specific processing on the content.

For more details and examples, take a look at our documentation for the Mem Markdown Format.

memClient.createMem({
content: "Hello there! I am a new mem."
});

Mark as Read#

memClient.createMem({
content: "Hello there! I am a new mem.",
isRead: true
});

Mark as Archived#

memClient.createMem({
content: "Hello there! I am a new mem.",
isArchived: true
});

Schedule for a Future Date#

memClient.createMem({
content: "Hello there! I am a new mem.",
scheduledFor: "2032-08-02T08:15:30-05:00"
});

Set a Custom Creation Date#

memClient.createMem({
content: "Hello there! I am a new mem.",
createdAt: "1994-11-05T08:15:30-05:00"
});

Putting it All Together#

This will create a mem which:

  • Is already marked as read
  • Is already archived (hidden from your inbox)
  • Is marked as "created" in 1994
  • Will re-appear in your inbox in 2032
memClient.createMem({
content: "Hello there! I am a new mem.",
isRead: true,
isArchived: true,
scheduledFor: "2032-08-02T08:15:30-05:00"
createdAt: "1994-11-05T08:15:30-05:00",
});

Extended Functionality#

We also support a few specialized use-cases.

Plaintext Content-Type#

If you'd like to create mems without converting your content to JSON first, you can do so by POST-ing file content with the text/plain content-type. This can be useful if you'd like to directly upload markdown files from your computer.

curl \
-X POST \
-H "Content-Type: text/plain" \
-H "Authorization: ApiAccessToken <Replace this with your access token>" \
--data-binary "@./path/to/filename.md" \
https://api.mem.ai/v0/mems