Importing
tapedb cms import brings content in from any system that can write JSON: an export from another CMS, a spreadsheet converted to records, a script over an old database.
npx @tapedb/cli cms import records.ndjson --workspace <id> --dev importer --publishRecords
Section titled “Records”One record per line (NDJSON), or a JSON array of the same:
{ "type": "author", "id": "ada", "fields": { "name": "Ada Lovelace" } }{ "type": "post", "id": "hello", "fields": { "title": "Hello", "slug": "hello", "body": { "markdown": "Some **bold** text.\n\n## A heading" }, "author": { "ref": "ada" }, "cover": { "url": "https://<your-old-site>/cover.jpg", "alt": "The cover" } } }typeis a content type;fieldsare its fields by name.idis the record’s id in the source system. The document keeps it when it is a valid TapeDB id, and otherwise gets a stable id derived from it, so importing the same file again updates the documents instead of duplicating them.- References are
{ "ref": "<source id>" }, or just the source id, to a record of the referenced type in the same file or imported before. Documents are written in reference order, so authors exist before the posts that name them. - Rich text is ProseMirror JSON,
{ "markdown": "…" }, or plain text, where blank lines separate paragraphs. - Images are
{ "path": "public/…" }for a file already in the workspace, or{ "url": … }/{ "file": … }with optionalalt,xandy, to upload into the media library underpublic/media/. - Other fields take their stored form: strings, numbers, booleans, a select option,
"2026-11-28"for a date.
Checked before anything is written
Section titled “Checked before anything is written”Every record is checked against your content types first: unknown types and fields, values of the wrong kind, references to records that do not exist, required fields missing when publishing. Every problem is listed at once, with the record’s line, type and id. If there is any problem, nothing is written.
--dry-run stops after the check, to try a file without touching the workspace.
Options
Section titled “Options”| Option | |
|---|---|
--workspace <id> |
the workspace to import into |
--url <origin> |
the Worker; defaults to tapedb dev at http://localhost:8787 |
--token <claim> |
an editor’s claim, for a deployed Worker |
--dev <name> |
a development claim with that name, for tapedb dev and other non-production Workers |
--publish |
publish each document after writing it; without it, documents arrive as drafts for review |
--dry-run |
check everything and write nothing |
--content <file> |
the file exporting content; defaults to cms.content.ts, then tapedb.schema.ts |
The import runs through the same rules as the studio, in the claim holder’s name: drafts and revisions carry it, publishing needs an editor, and each document is one transaction. At the end it reports how many documents were created, updated and published and how many images were uploaded.
From code
Section titled “From code”@tapedb/cms/import does the same from your own script, with a TapeDB client:
import { importContent, parseRecords } from "@tapedb/cms/import";import { content } from "./cms.content";
const records = parseRecords(await readFile("records.ndjson", "utf8"));const report = await importContent(db, content, records, { sub: "importer", publish: true, readFile: async (path) => new Blob([await readFile(path)]), onProgress: (done, total) => console.log(`${done}/${total}`),});
report.problems; // [] when everything was writtenreport.created; report.updated; report.published; report.images;fromMarkdown(text) converts Markdown to the CMS’s rich text on its own, for content you transform before importing.