Skip to main content

Use cases

Documents that change, and the memories derived from them

Write the document as a file and keep writing to the same path. Every write keeps a version you can compare and restore, the service distills memories again from the new version, and each distilled memory names the version and the quoted words it rests on.

Last updated Markdown

Example

FILES="https://api.mirabase.io/v2/spaces/default/files"

# 1. Write the file, then write it again with a change. Each response carries a version_id.
curl -s -X PUT "$FILES?path=/notes/plan.md" \
  -H "Authorization: Bearer $MIRABASE_API_KEY" \
  -H "Content-Type: text/markdown" \
  --data-binary $'# Plan\n\nWe ship on Friday.\n'

curl -s -X PUT "$FILES?path=/notes/plan.md" \
  -H "Authorization: Bearer $MIRABASE_API_KEY" \
  -H "Content-Type: text/markdown" \
  --data-binary $'# Plan\n\nWe ship on Thursday.\n'

# 2. List the versions, newest first.
curl "$FILES/versions?path=/notes/plan.md" \
  -H "Authorization: Bearer $MIRABASE_API_KEY"

# 3. Compare an older version with the latest.
curl "$FILES/diff?path=/notes/plan.md&from=$OLD_VERSION_ID" \
  -H "Authorization: Bearer $MIRABASE_API_KEY"

# 4. Restore the older version. Its content is written as a new version; history is not rewritten.
curl -X POST "$FILES/revert?path=/notes/plan.md" \
  -H "Authorization: Bearer $MIRABASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"version_id": "'$OLD_VERSION_ID'"}'

To see what a memory rests on, list the memories from the file's Entry and read one memory's provenance. The ID of a distilled memory contains colons, so URL-encode it.

curl "https://api.mirabase.io/v2/memories?entry_id=$ENTRY_ID" \
  -H "Authorization: Bearer $MIRABASE_API_KEY"

curl "https://api.mirabase.io/v2/memories/$MEMORY_ID/provenance" \
  -H "Authorization: Bearer $MIRABASE_API_KEY"

Each source in the response carries entry_id and version_id, and a distilled memory also carries the verbatim quote. See Compare and revert versions and Memory.

Limits

  • After a new version is written, memories from the earlier version stay in effect until the new distillation finishes. For a short time retrieval can still return one of them. See Memories after their source changes.
  • A memory written directly has no quote; only distilled memories do.
  • Deleting a file moves it to the trash, from which it can be restored. Erasing it is a separate, permanent step. See Delete and erase.
  • A single write accepts at most 16 MiB; larger files require a multipart upload.
  • Forgetting a memory is permanent: editing or restoring the source does not bring it back.