# BCMS CLI

The BCMS CLI (@thebcms/cli) helps you create projects from starters, log in to your BCMS account, and pull types, entries, and media to your local machine.

## Install

Install globally:

```BASH

npm i -g @thebcms/cli

```

Or add it to a project:

```BASH

npm i @thebcms/cli

```

List available commands:

```BASH

bcms help

```

## Login

Most commands need a logged-in BCMS account. Login opens a browser magic-link flow and stores credentials under ~/.bcms.

```BASH

bcms login
bcms logout

```

## Create a project

Scaffold a starter and create a matching BCMS instance. Supported frameworks: next, nuxt, gatsby, svelte, astro.

```BASH

bcms create next
bcms create nuxt --project-name my-site --starter blog

```

If you omit flags, the CLI prompts for project name, framework, and starter. It clones from the BCMS starters repo, creates an instance, generates API keys, and writes a .env file.

## Pull data

Pull content and generated types from an instance into your project:

```BASH

bcms pull types
bcms pull types --language ts
bcms pull entries
bcms pull media
bcms pull types,entries,media

```

Useful options:

- --output / --out: output directory (defaults: bcms/types, bcms/entries, bcms/media)

- --language / --lng: type language (ts or gql)

- --instance-id / --iid: skip the instance picker

## API key auth (no browser login)

For CI or local scripts, authenticate with an API key instead of bcms login. See [Working with API keys](https://thebcms.com/docs/inside-bcms/api-keys.md).

Option 1: environment variable

```BASH

export BCMS_API_KEY="keyId.secret.instanceId"
bcms pull types --language ts

```

Option 2: bcms.config.js / bcms.config.cjs / bcms.config.mjs in the project root:

```JAVASCRIPT

module.exports = {
  client: {
    // origin: 'https://app.thebcms.com',
    apiKey: process.env.BCMS_API_KEY,
  },
};

```

## Common flags

- --api-origin: API origin (default https://app.thebcms.com)

- --verbose: print verbose errors

- --version / -v: print the installed CLI version

## Related

- [BCMS MCP](https://thebcms.com/docs/getting-started/mcp.md): manage content from AI assistants

- Source: [github.com/bcms/utils/cli](https://github.com/bcms/utils/tree/main/cli)