<!-- source: https://cli.dreamlake.ai/notes/archival @ 0.134.0 99837ab -->

# Archive memos and folders

Archive is a separate lifecycle state, represented by `archivedAt`. Null or a
missing field means active. Tags remain independent. Archiving keeps content,
shares and project filings; [deleting a memo](/notes/deletion.md) has different
consequences. These commands require CLI 0.97.0+ and a compatible server.

```bash cli-help="memos archive"
dl memos archive MEMO_ID --json
# With a slug or exact title, select its owning namespace.
dl memos archive release-plan --namespace acme
```

```bash cli-help="memos unarchive"
dl memos unarchive MEMO_ID --json
# Archived titles and slugs remain resolvable.
dl memos unarchive release-plan --namespace acme
```

These commands send only `{archived: true}` or `{archived: false}` in a metadata
PATCH, with no body revision required. An ID resolves the owner; `--namespace`
then asserts it. A slug/title lookup includes archived memos and follows catalog
pages; prefer full IDs in scripts because titles can repeat. The server requires permission to
rename the memo, not merely to read its body. Archiving can return 409 if the live
body cannot be safely saved; a failed request does not claim archival succeeded.
`--json` prints the server's updated memo metadata, including `archivedAt`.

`memos list`, `memos search`, `memos grep`, and `memos list --shared` omit archived
memos by default. Pass `--include-archived` to include both active and archived
memos. Direct reads remain available and do not change archival state.

```bash
dl memos list --include-archived --json
dl memos search "release plan" --include-archived
dl memos grep TODO --include-archived --json
dl memos list --shared --include-archived
```

## Folders and saved edits

```bash cli-help="folders list"
# List immediate contents at a project root or inside a folder.
dl folders list --project project-slug --namespace acme --include-archived --json
dl folders list --parent-id FOLDER_ID --include-archived --page 1 --page-size 50
```

```bash cli-help="folders archive"
dl folders archive FOLDER_ID --json
```

```bash cli-help="folders unarchive"
dl folders unarchive FOLDER_ID --json
```

Folder commands use node IDs and the server's folder write permission. Archiving
a folder hides its subtree from ordinary tree listings without deleting or
individually archiving its children. The listing returns all immediate contents,
including memos and files, with server pagination. `--include-archived` reveals
archived paths; it does not include deleted records. An explicit recursive
`dl download` includes retained files beneath archived paths so a full
folder export is not silently incomplete.

A successful saved edit to an archived memo or folder restores it and its
archived ancestor folders. Editing a file inside an archived folder restores its
folder path as well. Explicit unarchive restores the path too. Independently
archived siblings remain archived. Reading, viewing presence, no-op edits and
failed saves leave the archive state unchanged. The server owns these rules;
clients must not emulate them by recursively clearing unrelated folders.

## TypeScript

```ts
import {createClient} from '@dreamlake/dreamlake-cli/api';
const dl = createClient({remote: 'https://api.dreamlake.ai', token});
const notes = dl.notes('acme');
await notes.archive(noteId);
await notes.unarchive(noteId);
await notes.list({includeArchived: true});
await notes.search('release plan', 50, 0, {includeArchived: true});
await notes.find({q: 'TODO', includeArchived: true});
await notes.shared({includeArchived: true});
await dl.nodes.children({namespace: 'acme', project: 'project-slug', includeArchived: true});
await dl.projects('acme').resourceList('project-slug', {includeArchived: true, bindr: bindrId});
await dl.nodes.descendants(folderId, {includeArchived: true});
await dl.nodes.contents(folderId, {includeArchived: true});
await dl.nodes.episodes(projectId, {includeArchived: true});
await dl.nodes.list({namespace: 'acme', project: 'project-slug', includeArchived: true});
await dl.nodes.archive(folderId);
await dl.nodes.unarchive(folderId);
```

`NoteRow.archivedAt` and `NodeRow.archivedAt` are `string | null | undefined` to
support older servers. Archive operations remain separate from `delete` and
from editing methods. Server permission, validation and save failures propagate
as API errors; the SDK does not retry an archive write or convert it into delete.
See the [shared API contract](https://docs.dreamlake.ai/notes/api/resources/) for
HTTP and other client interfaces.

### Retained inventory compatibility

Starting in 0.97.1, TypeScript `nodes.contents(id)` and CLI asset listings send
`includeArchived: false` explicitly for active discovery. TypeScript
`nodes.descendants(id)` also uses active discovery. For a complete retained
inventory or export, pass `{includeArchived: true}`; recursive CLI downloads
already do this.

The underlying HTTP `/nodes/:id/contents` and `/nodes/:id/descendants` routes
preserve their historical complete-inventory behavior when the flag is omitted,
so older installed download clients do not silently lose archived files. New
browsers should send `includeArchived=false`; exporters should send
`includeArchived=true`. Both modes still exclude deleted records.
