The draftbase command ships with @draftbase/sdk — login, content-type codegen, and migration from another CMS, all in one bin.
npm install -g @draftbase/sdk # or: pnpm add -g @draftbase/sdk / yarn global add @draftbase/sdk draftbase login
No install: since the package name (@draftbase/sdk) differs from the bin name (draftbase), plain npx draftbase ... won't resolve — use npx -p @draftbase/sdk draftbase ... instead.
Every command accepts either a logged-in session (draftbase login, OAuth 2.1 + PKCE, same auth server as the MCP server) or an explicit --api-key <management-key> (or DRAFTBASE_API_KEY).
Open the browser for OAuth login; stores a refreshable session under ~/.draftbase.
draftbase login
Clear the stored session.
draftbase logout
Codegen a .d.ts with one interface per content type, from the org's live schema.
draftbase types --out src/types/draftbase.d.ts # or with an API key instead of a login session: draftbase types --api-key <management-key> --out src/types/draftbase.d.ts
Resumable content-model/entry/media migration from Contentful or WordPress. Progress is checkpointed after every item — stop with Ctrl+C and rerun the same command to resume, nothing recreated twice.
# Contentful — from a `contentful space export` JSON dump draftbase migrate --source contentful --file export.json --checkpoint ./migration.json # WordPress — reads posts/pages straight from the live REST API draftbase migrate --source wordpress --url https://example.com --checkpoint ./migration.json # Preview counts without writing anything draftbase migrate --source contentful --file export.json --checkpoint ./migration.json --dry-run