Overview of HubSpot CLI
main@hubspot/cli is the official command-line interface for HubSpot developers. It is designed to enable local development workflows and automation for building on the HubSpot platform.repository·main·Indexed 42 days ago
https://github.com/hubspot/hubspot-cliThe official command-line interface for HubSpot developers, version 8.15.0. It enables local development workflows and automation for the HubSpot platform, providing tools for authentication, account management, project and app management, and CMS content interaction (including HubDB and File Manager).
@hubspot/cli is the official command-line interface for HubSpot developers. It is designed to enable local development workflows and automation for building on the HubSpot platform.Install the @hubspot/cli globally using npm to enable local development and automation for HubSpot developers.
If you prefer not to install it globally, you can run commands using npx (for npm users) or yarn (for yarn users) by prefixing the command.
npm install -g @hubspot/clihs init command to begin the configuration and authentication process.hs initThe HubSpot CLI is a command-line interface used to interact with HubSpot services. It supports a wide range of commands for managing authentication, configuration, projects, CMS content (like HubDB and File Manager), and more.
To use the CLI, you must provide at least one command. Running the CLI without a command will display the help menu.
# Example usage (command required)
# hs <command> [options]
# To see all available commands:
# hs --helpWhen working with HubSpot CMS fields, you can use the --convert-fields flag to automatically convert JavaScript-based field definitions into the required .json format during the upload process.
When this flag is used:
theme.json).FieldsJs process to handle the conversion.fields.json to ensure compatibility.--save-output is also provided, the resulting converted files are saved to your local disk.hubspot cms upload ./my-fields.js /path/on/hubspot --convert-fields --save-outputThe server provides tools organized into two main functional categories:
registerProjectTools. These are used for managing HubSpot projects, builds, deploys, and project-level configurations.registerCmsTools. These are used for managing CMS assets like modules, templates, and serverless functions.For non-legacy projects, the CLI supports Project Profiles. A profile allows you to map a project to a specific HubSpot account.
When running hs project upload:
--profile is provided, the CLI loads and validates that profile to determine the targetAccountId.--profile option conflicts with the global --account option; you must choose one or the other.You can preview a project build without deploying it to your main environment by using the --preview flag. This requires providing a specific portal ID via the --target flag.
Requirements:
--preview if you provide a --target.--target if you use --preview.When a preview is triggered, the CLI will poll the build and return a preview object in the JSON output containing the releaseTag and succeeded status.
# Preview the build on a specific portal
$ hs project upload --preview --target 1234567The get-started command provides an interactive workflow to help you set up a new HubSpot development project. It allows you to choose between creating a Private App or a CMS-based project.
If you choose a Private App, the command will:
If you choose CMS, the command provides guidance and an option to open the HubSpot Design Manager in your browser.
hubspot get-startedThe unified project development flow is a comprehensive CLI command that sets up a local development environment for HubSpot projects. It automates several complex steps:
This flow is designed to provide a seamless 'edit-and-see' experience locally before deploying to HubSpot.
Key behaviors:
hs-settings.json, the CLI will use those linked accounts.Ctrl+C or q in the terminal.# Note: This is a programmatic entrypoint for the 'project dev' command.
# Usage typically involves:
# hubspot project dev [options]
# Example conceptual invocation:
# hubspot project dev --auto-upload --port 3000The HubSpot CLI MCP Server exposes the HubSpot CLI (hs) through the Model Context Protocol. It is designed to assist with local development of HubSpot projects, apps, and CMS assets by handling configuration loading, authentication, platform-version flags, and providing structured output.
hsproject.json or *-hsmeta.json files) or scaffolding a new one.auth-account. This opens a browser tab for authorization; no Personal Access Key is required initially.search-docs first, followed by fetch-doc on relevant results, before writing code or answering platform questions.find-projects before running tools that require a project path.*-hsmeta.json files, call get-feature-config-schema first to identify allowed fields and values.get-build-status to see error messages. Use get-build-logs only for deeper troubleshooting.list-cms-serverless-functions to find endpoint paths, then use get-cms-serverless-function-logs to read logs.get-apps-info to find appId values before calling get-api-usage-patterns-by-app-id.To ensure that the destination folder on HubSpot exactly matches your local source (by removing files that exist on HubSpot but not locally), use the --clean flag.
Behavior:
--clean is used, the CLI will first attempt to delete the destination path on HubSpot.--force is not used, the CLI will prompt you for confirmation before deleting the remote files.--force is used, the deletion happens automatically without a prompt.Warning: This will permanently delete files at the specified dest on HubSpot.
hubspot cms upload ./local-folder /remote-folder --clean --force