@canva/cli

中文文档
2.18.0发布于 2026/11/09SEE LICENSE IN LICENSE.mdTypeScriptESM + CJS近 30 天下载 4.9万

The official Canva CLI.

原始使用文档
文档目录21 节
  1. Table of contents
  2. Introduction
  3. Requirements
  4. Quickstart
  5. Use the Canva CLI
  6. Step 1: Install and log in
  7. Step 2: Create your app
  8. Step 3: Preview your app
  9. Step 4: Run a health check on your app
  10. Log out, auth token storage, and removal
  11. Token Location
  12. Removing the Token
  13. CLI Reference
  14. Flags
  15. Commands
  16. Next Steps
  17. Limitations
  18. Updates
  19. Contributions
  20. Privacy
  21. License

@canva/cli

CLI for creating and managing Canva Apps, and working with Canva.

Table of contents

Introduction

@canva/cli is a command line tool designed for creating and managing Canva Apps. Use @canva/cli to get started creating and testing your app. The Canva CLI allows you to create apps from the command line, to use Canva's recommended development tools and templates, and to work with Canva from your machine.

To learn more about app development, visit the official documentation.

Requirements

Before using the CLI, make sure that you have the following:

  • Node.js v24

  • npm v11

  • A Canva account.

    Note: If you are using a version manager such as nvm, run the nvm install 24 command to make sure you have the correct Node.js version.

Quickstart

The following commands create a new Canva app using the Canva CLI.

npm install -g @canva/cli@latest
canva login
canva apps create "My New App" --template="hello_world" --distribution="public" --git --installDependencies
cd my-new-app
canva apps start

Use the Canva CLI

Step 1: Install and log in

Installing the Canva CLI allows you to create new apps from the command line.

To get started:

  1. Install the Canva CLI globally.

    npm install -g @canva/cli@latest
    
  2. Log in to the Canva CLI. The Canva CLI then opens an access request page in your browser.

    canva login
    
  3. In your browser, click Allow to grant the Canva CLI access to manage apps and work with your designs on your behalf. When you grant access, the Canva CLI generates an auth token and stores it locally. For more information on the auth token, read the following section on auth token storage and removal.

  4. Follow the login instructions in the terminal. Local browser logins complete automatically; if the CLI uses manual mode, copy the confirmation code shown in your browser and paste it into the CLI.

Step 2: Create your app

After you log in to the Canva CLI and authorize it, you can create your app.

To create a new app:

  1. Run the canva apps create command. The flags in the following code snippet are optional, and you can instead configure these settings during the apps creation process. See the CLI Reference for more information on each flag.

    canva apps create "My New App" --template="hello_world" --distribution="public" --git --installDependencies
    

    Note: You can't change the distribution type after creating an app.

Step 3: Preview your app

When your new app is ready, the Canva CLI automatically opens the Developer Portal to your new app's configuration page in your browser. You can then continue to preview and manage your new app.

To preview your app:

  1. Change into your new app's folder.

    cd my-new-app
    
  2. Run the following command to start your app.

    canva apps start
    
  3. The preview URL will be generated and opened automatically in your browser.

  4. If this is the first time previewing your app, click Open to preview your new app.

Step 4: Run a health check on your app

After creating your app, you can diagnose potential issues using:

canva apps doctor

This checks for missing dependencies, outdated packages, and other issues.

Log out, auth token storage, and removal

When you log in to the Canva CLI using the canva login command, and then grant the Canva CLI access to manage apps in your Canva account, an auth token is encrypted and stored locally on your machine. The token provides authentication for future requests so you don't need to grant the Canva CLI access each time it sends a request.

When you log out of the Canva CLI with the canva logout command, the auth token is revoked, and deleted.

Token Location

The auth token is located in your home directory under the .canva-cli folder.

If you use more than one profile, each one has its own token file: the default profile is stored in credentials, and every other profile in profiles/<name>.json. Logging out of one profile leaves the others in place, unless you pass --all to remove every one of them.

Removing the Token

To delete the token, there are two options. However, only the canva logout command revokes and deletes the token. If there's a copy of the token, it's possible to reconnect the Canva CLI to your account's apps using the token.

Log out

  1. Use the canva logout command to revoke access and delete the stored token.

    canva logout
    

Delete the file manually

  1. Locate the credentials file, which is stored in the following locations:

    • macOS and Linux: The token is stored in ~/.canva-cli/credentials.
    • Windows: The token is stored in %USERPROFILE%\.canva-cli\credentials.

    Tokens for named profiles sit alongside it in the profiles folder, one JSON file per profile.

  2. Delete the file. To remove every stored login, delete the whole .canva-cli folder.

CLI Reference

After installation, you can use the Canva CLI by running:

canva <command-name>

Flags

Top-level flags applicable to commands:

  • --help: Show help information about commands and flags.
  • --lite: Enable a simplified CLI interface for enhanced accessibility.
  • --profile: Run the command as a named stored login. See profile.
  • --version: Show the CLI version number.

Commands

welcome

Show the welcome page and general information.

canva welcome

tip

Print a random development tip for working with the Apps SDK.

canva tip
  • Aliases:
    • tips: Also prints a random development tip.

bug

Raise an issue with the Canva CLI on GitHub.

canva bug

login

Log in to the Canva CLI.

canva login
  • Flags:
    • --china, --cn: Login to canva.cn, this will use canva.cn for all subsequent commands until you log out.

    • --mode: The authentication mode or flow to use when logging in.

      Available modes:

      • "auto": Uses manual when running remotely, such as over SSH or in a container, and callback otherwise (default).
      • "callback": Runs a local server to receive the auth code.
      • "manual": Prompts you to copy and paste the auth code manually.
    • --profile: Store this login under a named profile instead of the current one, leaving your other logins in place. Commands keep using your current profile until you run canva profile switch. See profile.

logout

Log out of the Canva CLI, and delete the saved auth token:

canva logout

Only the profile you are currently using is affected. To log out of a different one, name it:

canva logout --profile work

To log out of every profile at once, pass --all. It reports each profile separately, forgets the profile chosen with canva profile switch, and succeeds only if every profile was fully logged out, so a partial failure is still a failure:

canva logout --all

--all and --profile cannot be combined, since one covers every profile and the other names a single one.

The stored token is always deleted from your machine. The CLI also asks Canva to revoke it, but that part needs a working connection: if the request fails, the command reports the deletion, warns that the token stays valid until it expires, and fails, since you are not fully logged out. The deletion still stands, so running canva logout again reports that you are not logged in.

  • Flags:
    • --all: Log out of every stored profile, not just the current one.
    • --profile: Log out of the named profile instead of the current one.

profile

Manage the stored logins the CLI can run as. Each profile holds its own auth token and its own Canva environment, so you can keep a login for your real account and a login for a test account side by side and switch between them without logging in again.

canva profile <subcommand>

To remove a profile, log out of it with canva logout --profile <name>, or remove them all with canva logout --all.

To create a profile, log in with it:

canva login --profile work
canva profile switch work

Any command accepts --profile <name> to run against one profile just once, without changing which profile is selected:

canva apps list --profile work

Setting CANVA_CLI_PROFILE picks a profile for a whole shell session, which is useful for scripts and agents:

CANVA_CLI_PROFILE=work canva apps list --print

When more than one is set, --profile wins, then CANVA_CLI_PROFILE, then the profile chosen with canva profile switch, and finally the default profile.

Profile names may contain letters, numbers, hyphens and underscores, must start with a letter or number, and may be up to 64 characters long.

list

Show every stored login, and mark the one in use.

canva profile list
switch

Make <name> the profile later commands run as. The choice persists until you switch again.

canva profile switch work

Leave <name> out to pick from your stored logins instead:

canva profile switch

The interactive list places a visual marker on the profile the command is currently running as. Note that --profile and CANVA_CLI_PROFILE both override that profile. If using either of those options, selecting the marked profile makes the override permanent.

The interactive switcher does not work when running headlessly.

mcp

Start the canva MCP server. This is usually called by your MCP client, such as Claude Desktop, Cursor, or other compatible tools. For more information on how to configure your MCP client to use the Canva Dev MCP server, please see Dev MCP server in the developer documentation.

api

Call the Canva REST APIs using your Canva CLI login. Commands are grouped by the resource they act on, such as canva api designs create, and --help works at every level to show the available groups, commands, and flags. For more information on making REST API requests from the CLI, please see Making Canva REST API requests from the CLI in the developer documentation.

Each call writes one JSON object to stdout and nothing else, so the output can be piped straight into jq or read by an agent. Missing arguments and unknown flags print a usage error to stderr instead of that object.

canva api designs get DAF123abc
canva api designs get --design-id DAF123abc
canva api designs create --design-type preset --design-type-name presentation --title "Q3 Review"
canva api designs get DAF123abc --dry-run
canva api designs list | jq '.data.items[].id'

Path parameters can be passed as positional arguments or as flags, such as --design-id. Every query parameter and request body field is a flag too; run canva api <group> <command> --help to see them.

You can pass input with operation flags (recommended) or with --body (advanced) when flags cannot express a nested payload:

canva api designs create --body @payload.json

--body also accepts inline JSON, or - to read stdin. It is only available on operations that send a JSON request body. Operations that upload a file, such as canva api assets create-upload, take --file instead.

  • Flags:
    • --dry-run: Validate the arguments and print the response object without sending the request.
    • --body: Request body as @path/to/file.json, inline JSON, or - for stdin. Use this when operation flags cannot express the payload.
    • --file: Request body from a file's bytes, or - for stdin. Only on operations that upload a file.

Example success output:

{
  "ok": true,
  "data": {
    "design": {
      "id": "DAF123abc"
    }
  },
  "next": [],
  "meta": {
    "status": 200,
    "durationMs": 12
  }
}

When a call fails, error takes the place of data and carries a code and message, meta.status is the HTTP status (or 0 when no request was sent), and next suggests the command to run, such as canva login when the stored token is missing a scope.

If you logged in with a CLI version older than the api command, run canva login again so your stored token carries the REST API scopes.

describe

Show the contract for one REST API command as JSON: its method and path, the scopes and capabilities it needs, every flag with its summary, the rate limit, a link to the reference documentation, and the commands that usually follow it.

canva api describe designs get
canva api describe exports create
request

Send a raw request to a REST path. Use this for an endpoint canva api has no generated command for. One command exists per HTTP method: get, post, put, patch, and delete.

canva api get /v1/users/me
canva api get "/v1/designs?query=Q3"
canva api post /v1/designs --body @body.json
canva api post /v1/asset-uploads --file ./photo.jpg --header "Asset-Upload-Metadata: {\"name_base64\": \"cGhvdG8=\"}"
  • Flags:
    • --body: Request body as @path/to/file.json, inline JSON, or - for stdin. Only on post, put, and patch.
    • --file: Request body from a file's bytes, or - for stdin. Only on post, put, and patch, and cannot be combined with --body.
    • --header: An extra request header as '<name>: <value>'. Repeat the flag for more than one.

apps

Manage your Canva apps.

canva apps
create

Create a new Canva app.

canva apps create "My New App" --template="hello_world" --distribution="public" --git --installDependencies
  • Arguments:
    • name: Sets the app's name, for example canva apps create "My New App".
  • Flags:
    • --template: Specifies the starting template for the app. Templates are pre-built starter projects that demonstrate common use cases and best practices. For a complete list of available templates, see App templates.

    • --distribution: Sets the app's distribution type.

      Available types:

      • "public": Available to all Canva users, subject to Canva review.

      • "private": Only available to your team on an Enterprise plan, and requires team admin approval.

        Note: You can't change the distribution setting after creating a new app with the canva apps create command.

    • --git: Initializes a Git repository in the project directory.

    • --installDependencies: Automatically installs necessary npm dependencies during the app creation process.

    • --strict: Uses the strict Canva app linting configuration in the generated project.

    • --optionalConfig: Optional configuration files to be created in the project directory.

      Available options:

      • "vscode": Adds a .vscode folder to the project directory.
      • "cursor": Adds a .cursor folder to the project directory.
      • "agents.md": Adds a AGENTS.md file to the project directory.
      • "claude": Adds a CLAUDE.md file to the project directory.
    • --offline: Scaffold the app locally without also creating an app in the Developer Portal.

    • --yes: Automatically accept the default option for any prompts and run non-interactively.

list

List your Canva apps, including apps using the Apps SDK, REST APIs, or MCP.

canva apps list

Use canva apps list --print in scripts or other non-interactive environments. Add --all to list every app without pagination.

  • Flags:
    • --app-id: Specifies an App ID to select.
    • --all, -a: Lists all apps at once without pagination.
    • --print, -p: Prints the list of apps to the console without interactivity.
preview

Preview your app.

canva apps preview
  • Flags:
    • --intent: App intent to preview when the app has multiple intents enrolled.
    • --target: Canva target to preview in (editor or canva_ai), for intents that run in more than one location.
    • --source: Load the app from its development URL (url) or uploaded bundle (bundle). Defaults to the development URL when the app version has one.
    • --no-open: Print the preview URL without opening a browser.
start

Start the local development server for the app in the current directory, powered by @canva/app-scripts.

canva apps start
  • Flags:

    • --config: Path to a canva-app config file, resolved from the project root (default: canva-app.config.ts).
    • --entry: Entry file for the app (default: src/index.tsx).
    • --backend-entry: Entry file for a backend run alongside the dev server.
    • --use-https: Serve the frontend over HTTPS.
    • --override-frontend-port: Override the frontend dev-server port.
    • --tunnel: Expose the backend through a public HTTPS tunnel.
    • --preview: Open the app preview in Canva once the server starts.
  • Examples:

    canva apps start
    canva apps start --preview
    canva apps start --use-https --tunnel
    
build

Build the app for production and extract its translations, powered by @canva/app-scripts.

canva apps build
  • Flags:

    • --config: Path to a canva-app config file, resolved from the project root (default: canva-app.config.ts).
    • --entry: Entry file for the app (default: src/index.tsx).
    • --output-dir: Build output directory (default: dist).
  • Examples:

    canva apps build
    canva apps build --output-dir out
    
upload

Build the app and upload its JavaScript bundle and translations to the Developer Portal, as an alternative to uploading the bundle yourself.

canva apps upload

The app is built the same way as canva apps build. The bundle and translations are then uploaded from the outputDir set in the canva-app config file, or from dist/ for apps that don't use @canva/app-scripts. To upload the output of a previous build instead, pass --prebuilt.

Bundle uploads require at least one enrolled Inside Canva intent. Apps using only REST APIs or MCP don't need a bundle upload.

  • Flags:

    • --app-id: App ID to upload assets for. Defaults to the app linked in the current directory's .env file.
    • --dry-run: Preview what would be uploaded without building or uploading anything.
    • --prebuilt: Upload existing build output without building the app or extracting its translations.
    • --drift-strategy: Preselect how to resolve local canva-app.json differences from the Developer Portal. One of push, skip, or abort.
    • --config: Path to a canva-app config file, resolved from the project root (default: canva-app.config.ts).
  • Examples:

    canva apps upload
    canva apps upload --app-id AAEuu...
    canva apps upload --dry-run
    canva apps upload --prebuilt
    canva apps upload --drift-strategy skip
    
doctor

Run diagnostics on your Canva App to identify and fix issues.

canva apps doctor
  • Flags:
    • --fix: Automatically apply fixes for issues where possible.
    • --report: Output check results without prompting for fixes.
    • --verbose: Show detailed diagnostic output optimized for AI agent assistance.
    • --check: Specify a specific check to run.
migrate

Run specific code migrations to update your app to newer patterns and APIs.

canva apps migrate <migrationName>
  • Arguments:

    • migrationName: Name of the migration to run.

      Available migrations:

      • "apps-sdk-v1-v2": Migrates apps using the Apps SDK v1 packages to v2.
      • "app-ui-kit-v5": Migrates apps using App UI Kit v4 to v5.
      • "design-editor-intent": Migrates from direct render pattern to design intents pattern.
      • "webpack-to-app-scripts": Migrates apps on a hand-rolled webpack config and scripts/start/ runner to @canva/app-scripts.
  • Flags:

    • --dry-run: Preview changes without modifying files. Generates a markdown preview file showing all proposed changes.
    • --debug: Show detailed debug output.
    • --force: Proceed even when project validation warns.
  • Examples:

    canva apps migrate apps-sdk-v1-v2
    canva apps migrate app-ui-kit-v5
    canva apps migrate design-editor-intent
    canva apps migrate apps-sdk-v1-v2 --dry-run
    canva apps migrate apps-sdk-v1-v2 --debug
    canva apps migrate webpack-to-app-scripts
    
config

Manage your App Configuration.

canva apps config

The CLI supports Inside Canva configuration and Outside Canva settings in canva-app.json, including:

  • outside_canva.rest_api: REST API enrollment, scopes, and return navigation.
  • outside_canva.mcp: MCP enrollment.
  • outside_canva.redirect_urls: OAuth redirect URLs shared by REST APIs and MCP.

For REST API authentication, copy CANVA_CLIENT_ID and a generated CANVA_CLIENT_SECRET into your project's .env file from Outside Canva → Configuration → .env file in the Developer Portal. Config pull and push do not populate these credentials. See REST API authentication for the OAuth setup steps.

For --strategy, pull accepts remote and push accepts local; both accept manual to write conflict markers for editing. --force and --strategy cannot be combined.

pull

Fetch the canva-app.json config from the Developer Portal.

canva apps config pull
  • Flags:
    • --force, -f: Force pull the app config, overwriting any local changes
    • --strategy: Preselect the resolution strategy for conflicts, allowing the command to run without user input
push

Submit the local canva-app.json to the Developer Portal.

canva apps config push
  • Flags:
    • --force, -f: Force push the app config, overwriting any remote changes
    • --strategy: Preselect the resolution strategy for conflicts, allowing the command to run without user input
status

Report on the status and validity of the canva-app.json config.

canva apps config status

Link your local project to an existing Canva app by updating the .env file

canva apps link
  • Flags:
    • --app-id: Specifies an App ID to select.
    • --force: Write .env without confirmation.

Next Steps

Limitations

You must manage your new app created through the Canva CLI through the Developer Portal. You can't manage apps completely through the Canva CLI.

canva api calls the REST APIs through Canva's own OAuth client. To build a product that calls Canva on your users' behalf, please see create your own app with REST API access in the developer documentation.

Updates

To update the CLI to the latest version, run:

npm update -g @canva/cli@latest

Contributions

Currently the Canva CLI doesn't accept third-party contributions. Please submit any feature requests through the Canva Developers Community or raise an issue on Github.

Privacy

The Canva CLI collects anonymized analytics and diagnostic data to help improve product reliability. This data is handled in accordance with Canva's Privacy Policy.

To disable collection, set CANVA_CLI_DISABLE_TELEMETRY=true in your environment. For example:

export CANVA_CLI_DISABLE_TELEMETRY=true

License

Refer to the LICENSE.md file for more information.

版本与发布记录

@canva/cli 共发布 93 个版本,首次发布于 2024/09/20;过去 12 个月发布了 43 个版本。

版本发布日期距今
2.18.0latest2026/11/09今天
2.17.02026/11/027 天前
2.16.02026/10/2812 天前
2.15.02026/10/2218 天前
2.14.12026/10/1426 天前
2.14.02026/10/071 个月前

关于 @canva/cli 的常见问题

@canva/cli 是什么?

The official Canva CLI.

如何安装 @canva/cli?

在项目目录运行 npm install @canva/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 canva,可以用 npx canva 直接运行。

@canva/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@canva/cli 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@canva/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@canva/cli 可以商用吗?

@canva/cli 使用 SEE LICENSE IN LICENSE.md 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@canva/cli 的下载量有多少?

根据 npm 官方下载统计,@canva/cli 在 2026/10/09 – 2026/11/07 这 30 天内被下载 49,440 次,日均约 1,648 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@canva/cli 还在维护吗?

最新版本 2.18.0 发布于 2026/11/09(今天);至今共发布 93 个版本,其中过去 12 个月发布了 43 个;首次发布于 2024/09/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。