Skip to content

CLI

Every supatype command, grouped by what it is for. Descriptions are the ones supatype --help prints.

Pre-1.0: APIs and config may change between releases.

Install and help

Terminal window
$ npm install -g @supatype/cli
$ supatype --help
$ supatype push --help

The npm package needs Node.js 18 or later. It is the install to use on Windows.

The npm package runs the same program as the standalone install, so the React version your app uses, or any other package it installs, has no effect on the CLI. The first run of each version downloads that program from releases.supatype.com into ~/.supatype/cache/cli/<version>/ and checks it against the release’s signed checksums. In a scaffolded project that happens during npm install, when the prepare script runs supatype generate. A production install with --omit=dev leaves the CLI out, and prepare then generates nothing and succeeds, since the build that needed the generated files ran with everything installed. If that site is not answering (a 5xx, or no connection), the CLI downloads the same files from the release’s page on GitHub Releases, says so in one line, and still checks them against the signed checksums. A 404 or a checksum failure is never retried elsewhere. Releases published after v0.9.2 carry the files there. To use a mirror of the site instead, set SUPATYPE_CDN_BASE to its address; a mirror is used on its own, with no fallback to GitHub. A CLI built from source has no release public key embedded and refuses the download; set SUPATYPE_RELEASE_PUBLIC_KEY to the release minisign public key to verify the checksums against it. When set, it takes the place of the embedded key. The program is built for Linux and macOS on x64 and arm64, and for Windows on x64.

On a Linux or macOS machine without Node, such as a CI image or a server, install the standalone binary instead, with the script or with Homebrew:

Terminal window
$ curl -fsSL https://supatype.com/install.sh | bash
$ brew install supatype/tap/supatype

The script installs one binary to ~/.supatype/bin and adds that directory to your shell profile. It checks the release signature with openssl before installing. Where openssl is missing or cannot check ed25519 signatures, as with the LibreSSL macOS ships, it says so and checks only the SHA256. On Alpine it installs the musl build, which needs apk add libstdc++ libgcc. The components dev downloads are built for glibc only, so run local stacks on a glibc image. supatype self-update updates a standalone install.

Run commands from the project directory, where supatype.config.ts is. Every command also takes --project-name <name>, which names the project for this run over supatype.config.ts. supatype --version prints the CLI version.

--project-name is the same as setting SUPATYPE_PROJECT_NAME, and it writes no file. The Compose project, the native database and the state directory under ~/.supatype/projects/ all follow it. Use it to run two stacks of one project side by side, each with its own SUPATYPE_KONG_PORT. The name may use lower case letters, digits, - and _, and must start with a letter or digit.

Many commands that reach a database take --connection <url> to override the config, and --env <name> to pick an environment when the project is linked.

Commands that use Docker first check that it answers. A Docker that says it cannot be reached fails the command at once. A Docker that is running but slow to answer, as on a machine carrying many containers, is waited for, with a line saying so, for up to 60 seconds in all; set SUPATYPE_DOCKER_TIMEOUT to a whole number of seconds to wait longer or shorter.

Project and local development

CommandDescriptionUseful flags
init [name]Scaffold a new Supatype project-y, --defaults, --no-install, --no-keys, --admin-email, --admin-password, --no-admin
devStart local Postgres, apply schema, and run supatype-server--no-watch, --stream, --port <port>, --reset-db (Docker only), --yes, --overwrite-drift
keysGenerate ANON_KEY and SERVICE_ROLE_KEY JWTs from your JWT_SECRET and fill the blank ones in .env (printed instead when there is no .env, or with —print)--print [target], --env <name> and --allow-local (with --print frontend), --force, --secret <secret>, --exp-years <years> (default 10), --write
statusShow linked target status or local stack services--env <name>
logsTail logs from the local stack--service <name>, --since <duration> (default 5m), -f, --follow
mcpStart an MCP server over stdio so a coding agent can read this project’s schema, diff, status and logs, push the schema, generate types and search the docs. Run it from the project directory. It prints nothing itself. See MCP servers
app add [dir]Configure app routing: --static for a built site, or proxy to a dev server--static, --port <port> (default 3000), --upstream <url>
app removeSet app.mode=none in supatype.config.ts
admin create-userCreate an admin user for the admin panel--email, --password (asked for if left out), --role (default admin)
admin set-roleChange an existing user’s admin role--email and --role, both required
admin list-usersList users with Studio access--connection <url>
pg startStart Postgres for the current projectNative provider only
pg stopStop Postgres for the current project
pg resetStop Postgres, wipe the data directory, and re-initialise--force
pg psql [dbname]Open a psql shell connected to the project database

--role is admin, developer, editor or viewer. See Studio roles. The first-run steps are in Local development.

keys fills the blank keys in .env when there is one, and prints them when there is none or with --print. Add --force to replace keys already there. --write is kept for older scripts. keys --print frontend prints a deployment’s API URL and anon key instead, under every framework’s name, one NAME=value line each, for a host’s settings or $GITHUB_ENV. It reads them as build does, below, and takes --allow-local for a local stack’s values.

dev and self-host compose up refuse a JWT_SECRET shorter than 32 characters before starting anything, because the REST API cannot start with one. init generates a 64-character secret. To replace a short one, generate a longer secret (for example with openssl rand -base64 48), put it in .env as JWT_SECRET, then run supatype keys --write --force to sign new keys with it.

Schema and database

CommandDescriptionUseful flags
pushPush schema to the database: diff, prompt for destructive changes, apply migration, generate types. With --dry-run it prints the change list and the full SQL the push would apply, then stops: nothing is applied, asked or recorded, and no --yes is needed. Supatype Cloud and a linked self-host server cannot write SQL without applying it, so there it prints the change list and says so--yes, --dry-run, --connection <url>, --env <name>, --direct (alias --local), --overwrite-drift, --run-hooks
diffShow planned schema changes without applying them (dry run). With --sql it then prints the SQL a push would apply, as migrate writes it--sql, --connection <url>, --env <name>, --direct
generateRegenerate TypeScript types without running a migration
migrateWrite the SQL a push would apply, without applying it (to preview it on screen, supatype diff --sql or supatype push --dry-run print the same SQL after the change list). Plain, it takes no lock your application waits on and the file records nothing: applied by hand, the next push finds the tables unmanaged. With --record the file also records the migration as a push does-o, --output <file>, --record, --force
migrations listList applied migrations with schema snapshot metadata--connection <url>, --env <name>
rollbackRoll back the last applied migration--sync-schema, --no-sync-schema
resetDrop every managed table and its rows, apply the schema again, then run the seeds (destructive)--yes, --no-seed, --connection <url>
rename [from] [to]Record a rename in supatype/renames.json, so every push applies it as a rename and keeps the data: supatype rename member.name member.title, or supatype rename member members for a table--prune
doctorReport schema drift between schema/index.ts and the live database--strict, --rebaseline, --accept-access-drift, --yes
adoptHand Supatype the objects a push refuses because their names are taken; take objects back with --release, and hand them back with --reclaim--release <object...>, --reclaim <object...>, --key <object...>, --adopt-none, --yes
pullScaffold schema/index.ts from live database introspection (draft, review before push)--connection <url>, --out <path>, --dry-run
introspectIntrospect the live Postgres database (JSON or summary)--json, --out <path>
db checkCheck whether a database meets Supatype’s requirements (for external Postgres)--connection <url>, --schema <name>, --emit, --fix, --authenticator-password <password>
types checkValidate generated client augmentation wiring

--direct skips the control plane of a linked project and runs the schema engine on this machine. generate reads only the schema, so it needs no database. In a Next.js app it also replaces the app/supatype-env.js route init 0.9.1 wrote, whose export const dynamic line Next refuses under cacheComponents, while that route is still as init wrote it, and warns about one changed since (Next.js). pull prints its draft unless you pass --out. migrations list shows each migration’s author, how many schema files its snapshot holds and their compressed size, and the renames it applied.

A push never guesses a rename. A column that disappears while a new one appears is a drop and an add, and the drop loses data. In a terminal the push asks whether you meant a rename and records a yes in supatype/renames.json. Anywhere else it refuses and prints the supatype rename command that records it.

An object passed to adopt is named as doctor names it: kind:table.name, or kind:name for a table. Studio shows the result under Schema objects.

Data and seeds

CommandDescriptionUseful flags
seed [file]Run database seeds: optional single file; else all seeds/*.ts (alphabetical); else seed.ts--status, --atomic, --connection <dsn>, --environment <name>, --env <name>, --local, --confirm-production
cache rest listList cached REST GET entries--table <name>, --json
cache rest get <key>Show one cache entry (full key)--json
cache rest delete <key>Delete one cache entry
cache rest flushFlush REST cache entries--table <name>, --yes

seed on a linked project (Supatype Cloud, or a server linked with supatype link) sends the seeds to that server instead of connecting to the database. --local seeds the local stack instead, and --force is refused. See Seeding.

Switching the server cache on

A model’s cache block says which tables may be cached. It does not switch anything on: the running stack keeps its own allowlist, cache_tables, and a table is served from the cache only when both agree. push and dev add each newly declared table to that allowlist through the running stack and never change an entry that already exists. If the stack is not answering they create .supatype/api-config.json from the server’s default shape and write the entry there.

Both print a note while cache_max_ttl is 0, which it is until you set it: with a TTL of 0 nothing is cached. Set it under API, REST, Settings in Studio, or with the admin API, which is what the CLI calls:

PATCH /admin/v1/config/rest Authorization: Bearer <service role key> { “cache_max_ttl”: 60, “cache_tables”: { “posts”: { “enabled”: true, “allow_public”: false } } } All three fields are optional, and schema and max_rows are left alone when absent. cache_max_ttl is 0 to 86400 seconds. cache_tables replaces the whole map, so read it with GET /admin/v1/config/rest and send back the entries you want to keep. The schema’s declaration is a ceiling: a table it does not declare, or declares with enabled: false, is switched off and listed in the answer’s adjusted array, and a cache_max_ttl above a declared maxTtl is lowered to it. Every Cloud plan runs the cache, Free included. Free’s is smaller: 10,000 entries of up to 1,024 bytes each, and no row cache. On Cloud, push stores the declaration but does not switch tables on, so enable them in Studio or with this call; against a local or self-hosted stack, push and dev do it for you.

reset drops only the tables your schema manages. Sign-ins, Studio users and stored files are kept. It then clears the record of past seed runs, so a runOnce seed runs again, and runs the seeds unless you pass --no-seed. To start the whole database again, use supatype dev --reset-db.

Functions and hooks

CommandDescriptionUseful flags
functions new <name>Scaffold a new edge function
functions serveStart a local Deno server that serves all functions with hot reload--port <port> (default 18472), --env-file <path> (default .env.local)
functions invoke <name>Invoke a local or deployed function; exits 1 when it answers 400 or above--data <json>, --auth, --local (a running functions serve if one answers, else the dev API), --port <port> (of that serve, default 18472)
functions deployDeploy all functions (or --only <name> for one) to the linked project--only <name>, --env <name>, --dry-run
functions list CloudList all deployed functions for the linked project
functions delete <name>Remove a deployed function and its env values from the linked project, on Cloud or on a self-hosted server. On a project that is not linked it removes nothing and says so
functions logs <name> CloudTail logs for a deployed function--since <duration> (default 1h)
functions env list, set <KEY=value>, unset <key> CloudManage function environment variables--function <name> (one function’s own values, which override a shared one)
hooks new <name>Scaffold a hook handler
hooks listShow the hooks the schema declares and whether each one can run

On an unlinked project with a self-hosted Compose stack, functions deploy uploads nothing: the worker serves functions/ from disk, so it lists the functions and prints the command that restarts the worker. Otherwise it deploys to the linked project, or to Supatype Cloud. On a self-hosted stack, read function logs in Studio. See Functions.

Single sign-on

CommandDescriptionUseful flags
sso add <name>Register a SAML identity provider. <name> is how every other sso command refers to it--metadata-url <url> or --metadata-file <path> (one is required), --domains <list>, --attribute-mapping-file <path>, --name-id-format <format>
sso listList the SAML identity providers
sso show <name>Show one SAML identity provider
sso update <name>Change a SAML identity provider in place. Only the flags given change; —domains replaces the list. New metadata must keep the provider’s entity IDThe flags of add, all optional
sso remove <name>Remove a SAML identity provider. Users who signed in through it can no longer sign in that way-y, --yes
sso infoPrint the service provider values to give an identity provider: entity ID, ACS URL, NameID, metadata, and the signing certificate (the next one too during a key rotation), read from the served metadata
sso verify-domain <name> <domain>Prove this project owns <domain>, one of provider <name>‘s domains, with a DNS TXT record: prints the record to add and checks it. Exits 1 while the domain is not verified
sso rotate-keyRotate the SAML signing key: create SUPATYPE_SAML_NEXT_PRIVATE_KEY in .env, published beside the current key while identity providers take the new certificate; then —promote makes it the current key--promote, -y, --yes

Turn SAML on with auth.sso.saml.enabled in supatype.config.ts first. The sso commands reach the linked self-hosted deployment, or else the local stack, which must be running; they do not work against Supatype Cloud yet. Each one warns while SAML is off. The server, not the CLI, fetches --metadata-url, and refuses one it cannot reach with saml_metadata_fetch_failed, naming the host and the reason. See Single sign-on.

Self-host and deploy

CommandDescriptionUseful flags
self-host compose renderRender deterministic self-host compose artifacts
self-host compose upRender and start compose services-d, --detach (on by default)
self-host compose downStop compose services (volumes are kept unless --volumes)--volumes, -y, --yes
self-host compose restart <service>Recreate one service with the current config and .env, leaving the others running
self-host compose statusShow compose service status
self-host compose logsTail compose logs--service <name>, -f, --follow
add domain [domain]Add a custom domain with automatic HTTPS (self-host)--email <email> for Let’s Encrypt
linkLink this project to cloud or self-host (unified .supatype/link.json). Refuses a different project or host than the one already linked, unless --force--url <url>, --token <token>, --env <name>, --fix-gitignore, --force
unlinkRemove this folder’s link (.supatype/link.json, and the legacy cloud.json and linked.json if present) and say what was removed
envs listList linked environments, and the default commands use: environments in supatype.config.ts when it names one, else this checkout’s
envs use <name>Set this checkout’s default environment. environments.default in supatype.config.ts wins over it, and envs use says so
build [command...]Run your app’s production build with the deployment’s API URL and anon key under every front-end name (VITE_, PUBLIC_, NEXT_PUBLIC_, EXPO_PUBLIC_). Runs the package.json build script unless a command follows —. Refuses to start when either value is missing--env <name>, --allow-local, -- <command...>
deployDeploy schema and app, Supatype Cloud by default when linked (supatype link); pass --local for engine + your database--env <name> (default production), --schema-only, --app-only, --skip-build, --preview, --yes, --overwrite-drift, --allow-local
deploy rollbackRoll back to the previous static site deployment--to <id>, --env <name>
deploy statusShow current deployment status--env <name>
deploy logs [version]Show build logs for a deployment--env <name>

Every self-host compose command renders .supatype/self-host/docker-compose.yml again before it runs. The file names each bind mount by its absolute path on this machine, and names its Compose project supatype- plus project.name. So docker compose -f .supatype/self-host/docker-compose.yml run by hand reaches the same stack, and a project moved to another folder is picked up by the next command.

A render keeps the stack in the mode it runs in. While supatype dev runs for the project, commands such as push, update and self-host compose render dev mode. Otherwise they use the mode of the running server container, so a push to a production stack leaves it standalone.

Commands that reach the local stack’s database or API need that stack running: push, diff, adopt, doctor, seed, migrate, migrations list, rollback, reset, introspect, pull, admin, cache rest, and functions invoke when no functions serve answers. With it stopped they start nothing and refuse with The local stack isn't running. Start it with supatype dev, or supatype self-host compose up -don a server, then runsupatype push again., naming the command run. seed exits 2, the others 1. A linked project, --connection, connection in the config and an external database are reached as they are, and so is an API address named by SUPATYPE_URL or SUPATYPE_API_URL in .env.

build takes each value from the first of: the environment (SUPATYPE_URL, SUPATYPE_ANON_KEY or any framework’s name), the /supatype-env.json of the server the environment’s URL names (for the anon key only, so CI can set just SUPATYPE_URL), the linked environment, and a .env that records a deployment (PUBLIC_SUPATYPE_URL or API_EXTERNAL_URL, and ANON_KEY). An anon key counts only for the URL being built for; one a source holds for another deployment is listed as skipped. It refuses a local address unless you pass --allow-local, never gives the build the service role key, writes no file, and exits with the build’s own code. A package.json build script that is itself supatype build is refused rather than run again. deploy builds the app the same way. See Deploy your frontend.

For a self-hosted stack, link --url takes the stack’s gateway URL and --token its SERVICE_ROLE_KEY. The link is made to the project the server says it serves, whatever this folder is called.

A folder holds one link, to Supatype Cloud or to a self-hosted server, and envs use chooses between environments of that one link. link to a different project, or to the other kind of host, refuses and names the link that is there: run supatype unlink to remove it, or pass --force to replace it with a fresh one. Linking the same project again (to refresh a token, or to add an environment with --env) always works. To work against both hosts at once, keep a folder for each (a second clone or a git worktree) and link each to its own host. The full walkthrough is in Self-host and Deploy to a VM with GitHub Actions.

Supatype Cloud

All of these need Supatype Cloud, which is in closed beta (request access).

CommandDescriptionUseful flags
loginSign in to Supatype Cloud in your browser. It opens the accounts site, you approve, and type the code shown there into the terminal; the CLI stores a personal access token (spt_...) for push and deploy. The URL is always printed. The CLI asks the control plane where the accounts site is (GET /api/v1/cli/login/config), or you set SUPATYPE_ACCOUNTS_URL; if neither gives an address, login stops and says so. A Cloud behind a bot check refuses the CLI with captcha_failed; login then says that sign-in works only through the browser and points to --token for CI. Any other refusal prints the control plane’s own message and exits 1. A new Cloud account cannot create a project until it is approved (closed beta)--api-url <url> (a Cloud other than supatype.com; SUPATYPE_API_URL sets it too),--name <name> (the token’s name, default cli_<hostname>_<time>), --no-browser, --token <spt_...> (store a token made in your account instead of signing in, for CI; SUPATYPE_ACCESS_TOKEN takes one too)
logoutClear stored Supatype Cloud credentials
whoamiShow the current Supatype Cloud session, checked against the control plane. Exit 0 when valid, 1 when rejected, 2 when the control plane cannot be reached
link --project <slug>Link this project to cloud or self-host (unified .supatype/link.json). A cloud link asks the Cloud you signed in to with login, unless --api-url or SUPATYPE_API_URL names another--api-url <url>, --token <token>, --env <name>
projects listList your projects. In a linked project it lists that project’s organisation; before a link it lists every organisation you belong to (just the one, if you have one)--org <slug> (one organisation only)
projects create <name>Create a new project, in your only organisation, or the one --org names (required when you belong to several and nothing is linked)--tier <tier>, --region <region>, --org <slug>
projects pause <slug>Pause a project--org <slug>
projects resume <slug>Resume a paused project--org <slug>
domains list, add <domain>, remove <domainId>, verify <domainId>Manage custom domains for a project
envs create <name>Create a cloud environment (staging/preview)
db connection-stringShow the database connection string for the linked project--transaction, --env <name>
db reset-passwordReset the database password for the linked project--env <name>

Binaries and updates

CommandDescriptionUseful flags
self-updateUpdate the supatype CLI (npm or standalone CDN binary)--force
updateDownload the latest component binaries and update versions in supatype.config.ts. On a Docker project it checks for a newer CLI release first and says to upgrade the CLI when one exists, because the image pins come from the CLI version, then pulls the images this CLI pins. --check reports the running CLI, the latest release and whether an upgrade would move the pins, and pulls nothing--check
engine statusRun the host engine binary’s --version and show which binary answered
cache listList cached component binaries and their sizes--project <path>
cache clean [component] [version]Remove cached binaries not pinned by local project configs, and CLI programs of other versions (cache clean cli for those alone)--dry-run, --force, --project <path>
migrate-from-v1Codemod runtime model() schema DSL into RFC v2 Model<> type aliases--schema <path>, --write

Binaries are cached in ~/.supatype/cache/. cache clean --force removes every cached binary, pinned or not.

Upgrading an npm install leaves the previous version’s program in ~/.supatype/cache/cli/, since another project may still use it. Once the programs of other versions take more than 250 MB, the CLI says so when it starts, at most once a day. cache clean removes them, and never the running version; a project still on a removed version downloads it again on its next command.