CLI reference
1c is the @1consent/cli command-line interface. Manage 1Consent designs, themes, and generated integration types locally.
npm install --save-dev --save-exact @1consent/cliFor the Vite 8 Design Kit, use Node.js 22.12 or newer. A global install is optional;
npx can run the scoped package directly. Never use npx 1c, which resolves an
unrelated package. See the complete custom-design workflow,
or request get_1cl_reference with topic: "cli" through 1Consent MCP. Local
commands run in your terminal or your assistant's authorized terminal. MCP OAuth
approval does not provide the separate CLI API key.
Run the command examples below with npx @1consent/cli in place of 1c. For example:
npx @1consent/cli typegen --app YOUR_APP_IDAuthentication and workspace
Create an API key with the Designs and themes permission in the dashboard under workspace Settings → Developers (a key for one site: that site's Settings → Developers), then expose it as ONECONSENT_TOKEN. 1c init writes the key to .env and the resolved public scope to .1consentrc. Resources owned by the 1Consent workspace live at the root of the local folder; project and site resources mirror the hierarchy below projects/{project-id}/. Existing project-slug directories remain push-compatible when the slug identifies exactly one project. Pull and push reject symbolic links anywhere in synchronized workspace paths so checkout files cannot redirect reads or writes outside the workspace.
| Environment variable | Required | Purpose |
|---|---|---|
ONECONSENT_TOKEN | Yes | Customer API key used by init, pull, and push. |
ONECONSENT_ENV | No | Environment selected by init: local, develop, or production. Defaults to production. |
NEXT_PUBLIC_1CONSENT_APP_ID | No | Public site ID fallback used by typegen. |
Customer push synchronizes draft assets. Activate the resulting CMP configuration through the Dashboard publication workflow.
1c connect
Connect an AI assistant to the hosted 1Consent MCP.
Choose Codex, Claude Code or Cursor, configure only that client's oneconsent entry, and complete signup or login with the client's own OAuth flow. No API key is required. The first read happens in your assistant; configuration alone is not an authenticated connection.
Options
| Option | Description | Default |
|---|---|---|
--client <client> | Client: codex, claude-code or cursor. | — |
--env <environment> | Service environment: production, develop or local. | production |
--no-login | Write configuration only; leave authentication to the client. | — |
--check | Inspect configuration without changing it. Does not verify authentication. | — |
--remove | Remove only the selected client's matching entry. Account access must be revoked separately. | — |
Examples
1c connect1c connect --client codex1c connect --client cursor --check1c connect --client codex --remove1c init
Initialize a project with the 1Consent CLI.
Scaffolds a Design Kit workspace. Connected mode validates ONECONSENT_TOKEN or prompts for the API key with hidden input and saves the connection locally. Local preview mode uses files and sample data.
Options
| Option | Description | Default |
|---|---|---|
-f, --force | Force reinitialization even when .1consentrc already exists. | — |
--local-preview | Scaffold a Design Kit preview without network access or an API key. | — |
Examples
1c init1c init --local-previewONECONSENT_ENV=develop 1c init --force1c pull
Download designs and themes from the platform.
Reads the hierarchy visible to the configured API key and mirrors authorized resources into the local workspace. Workspace keys (scope org) use projects/{projectId}/apps/{appId}; project keys place child apps in apps/{appId}; app keys use the workspace root.
Options
No command-specific options.
Examples
1c pull1c push
Upload local designs and themes to the platform.
Synchronizes customer draft collections, themes, and existing pulled standalone designs using the same credential-scoped layout as pull. The complete authorized checkout is parsed, metadata-resolved, and contract-validated before the first upload starts. Existing resource IDs and Dashboard display metadata are preserved while local files and theme tokens are updated; new collections, collection designs, and themes use their directory names. Publishing the resulting CMP configuration remains an explicit Dashboard action.
Options
No command-specific options.
Examples
1c push1c status
Show the configured scope and local resource counts.
Prints the active scope, endpoint, and collection, design, and theme counts throughout the local hierarchy.
Options
No command-specific options.
Examples
1c status1c typegen
Generate typed consent names and framework build stamps.
Fetches every published framework for a site and generates TypeScript service/category unions, ID maps, and framework-associated fast-path versions. The module types the names for every adapter (@1consent/nextjs, @1consent/react) declared by the project that contains the output file: the nearest package.json with a name or dependencies. Under pnpm and Yarn Plug'n'Play a project can only type a package it declares itself.
Options
| Option | Description | Default |
|---|---|---|
-a, --app <shortId> | Public site ID. Falls back to NEXT_PUBLIC_1CONSENT_APP_ID. | — |
-e, --env <environment> | 1Consent service environment: local, develop, or production. | production |
-u, --url <baseUrl> | Override the CMP API base URL. | — |
-o, --out <file> | Output file. Defaults to src/1consent.gen.ts when src exists, otherwise 1consent.gen.ts. | — |
--check | Fail when the generated file is missing or stale (CI mode). | — |
Examples
1c typegen --app app_demo1c typegen --app app_demo --check1c typegen --app app_demo --env develop --out src/consent.gen.ts