Skip to main content
This functionality is currently in beta. By participating in this beta, you agree to HubSpot’s Developer Terms and Developer Beta Terms. Note that the functionality is still under active development: commands, flags, and behavior may change without notice.Write operations (create, update, and delete) can modify or permanently delete live data in your account. If you run the CLI against a production account, you accept the risk of unintended changes, including data loss. It’s strongly recommended that you use the --dry-run flag before applying mutations and test in a sandbox account whenever possible.
The HubSpot Agent CLI is a command-line tool designed primarily for AI agents, such as Claude Code, Claude Cowork, and OpenAI Codex. Agents can install and use the CLI to work directly with your HubSpot CRM data and operate on your behalf. You can also run the Agent CLI yourself on your local computer to test it out and leverage the functionality for custom scripting.

Installation

Install via an AI agent

If you’re setting up the Agent CLI for use with an AI agent, such as Claude Code, Claude Cowork, or Codex, the agent should be able to discover the CLI capabilities on its own using the --help flag. Relevant information will be provided to the agent down through the command tree, and your agent can then read output shapes and compose the corresponding pipelines for each command. The prompt below provides a starting point you can use with your AI agent:
If you’re using Claude Cowork in a Team or Enterprise account, your organization’s admin may need to allowlist api.hubapi.com before the CLI can install or run. Check out the Using the CLI with Claude Cowork section below for setup instructions.

Install the Agent CLI manually

The Agent CLI is packaged as a single binary with no runtime dependencies, and is supported for macOS, Linux, and Windows.
The installer adds the CLI to your PATH. After installation, open a new terminal window or tab so the PATH change takes effect. You can verify that the installation was successful by running the command below:

Add HubSpot Agent CLI Skills

If you installed the Agent CLI manually for use in an AI-agent workspace, install HubSpot Agent CLI Skills in that same workspace using the command below:
After installation, ask your agent to use HubSpot Agent CLI Skills when planning HubSpot CRM tasks. The skills include guidance for bulk operations, CRM lookup, data quality, workflow automation, and other common tasks. Use the public GitHub repository hubspot/agent-cli-skills to inspect the skills that will be installed and available to your agent. Then use npx skills update to keep your skills library up to date in the installed agent workspace.

Authenticate with your HubSpot account

During beta testing, it’s recommended that admins also participate in App Governance (Beta). App Governance gives Super Admins control over who can connect the Agent CLI through hubspot auth login. Users without install access can request approval before connecting. Learn more about controlling access with App Governance.
Once installed, you can authenticate the CLI with your HubSpot account. Most users should use OAuth login, while service key tokens are available for admin, schema, destructive, or automation workflows that need account-level API access.

Standard mode via OAuth login

If you plan on using the Agent CLI based on the scopes your HubSpot user has access to, such as reading owned records, running searches, or creating and updating records for standard and custom CRM objects, authenticate via OAuth login by running the command below:
This will open a browser window for you to authorize the CLI with your HubSpot account. The resulting token is scoped to your user-level permissions, which mirrors the same access you have when accessing your account through the HubSpot UI. The token will be refreshed automatically. If you ever need to clear cached credentials, run the following command:
Current OAuth limitations: during the beta, some account-level metadata, schema, relationship, activity, and destructive operations are not supported with OAuth login alone and require a service key token. Some destructive commands also require a local --dry-run safety digest before they execute. These operations are detailed in the Auth-sensitive commands section below.

Admin mode via service key token

To perform account-level operations and bypass OAuth for API requests, you can set up a service key as an environment variable.
You can also add the service key in a .env file at ~/.hubspot/.env or ~/.config/hubspot/.env. When HUBSPOT_ACCESS_TOKEN is set, the Agent CLI uses it for HubSpot API requests before checking cached OAuth credentials. To return to OAuth mode in the same shell, run unset HUBSPOT_ACCESS_TOKEN. Once set up, the Agent CLI can perform operations that user-level OAuth tokens may not be able to perform, such as writing schema metadata, deleting records, reading and writing custom object schemas, and calling account-level relationship or activity endpoints. The exact commands available depend on the scopes and permissions granted to the service key.
Please note: use admin mode with caution. The token has broader permissions and will not include a per-user audit trail.

Check your session status

You can verify the authenticated user, token type, and authenticated HubSpot account ID by running the following command:
With OAuth login, whoami shows the authenticated user, account ID, and granted scopes. With HUBSPOT_ACCESS_TOKEN, it validates the token and shows the account ID, but user and OAuth scope details are not available.

Run commands

After you authenticate, the Agent CLI can run commands to perform actions in your account.

Command structure

Commands follow the pattern of hubspot <noun> <verb>. To get more information about a given command, run --help at any level.

Core commands

The current data and automation commands are detailed in the table below:
The currently supported top-level command groups are objects, pipelines, properties, associations, owners, workflows, views, schemas, activities, reports, history, and feedback. The auth, whoami, upgrade, and help commands are covered in the relevant sections of this guide.

Object types

Use objects types to list the CRM object types available in the connected account, including custom objects and newer standard CRM object types.
For commands that accept --type, use the name value returned by objects types. Custom objects discovered this way work through the same object and property commands as other CRM object types, subject to the auth-sensitive operations listed below.

Output formats

The CLI defaults to JSONL, which is a UTF-8 encoded text format where each line is a valid independent JSON object, separated by newline characters (\n). Though JSONL is the format that AI agents work best with, you can also use the --format flag to format the output of a command in standard JSON with metadata or a human-readable ASCII table:
Use the objects search command in tandem with the --filter flag to search your account for records that meet the criteria you specify. The code block below provides examples of how to filter by email address or filter by multiple properties:

Properties

By default, object read commands return the raw API response, including the properties object. You can request specific properties by including the --properties flag. This will flatten the requested properties so each property appears as a top-level field, prefixed with prop_. For example, the following command would retrieve contacts and only list their email address, first name, and last name:

Using the dry run flag

Every write command supports the --dry-run flag, which will display a preview of what will happen without making any changes. For example, the code block below demonstrates a dry run of updating a specific contact to change its lifecycle stage to customer:
The output of a command run with the --dry-run flag is shape-compatible with the input to subsequent commands, so you can review a plan then execute it. The example below highlights chained commands with the --dry-run flag:
  1. Search for a contact by their email, pipe the output to update the tier property of the matched contact to gold.
  2. The corresponding output is first saved to a plan.jsonl file where the forthcoming results could first be reviewed.
  3. Once reviewed, the plan.jsonl file could then be piped directly into the objects update command without the --dry-run flag to actually make the change.

Piping and bulk operations

One of the main strengths of the Agent CLI is the ability to compose commands through standard Unix pipes. Mutation commands (create, update, and delete) accept JSONL on stdin, so omit any positional arguments and pipe in one record per line. Check out the examples in the sections below.

Find contacts by email address and update a property

The example below retrieves all contacts with an email containing .edu and updates their segment property to be academic.

Create contacts from a .jsonl file

The example below bulk-creates contacts from a .jsonl file:

Bulk delete bounced contacts

The code block below retrieves all contacts who bounced on a sent email and bulk-deletes them from your CRM:

CRM saved views

Use views commands to inspect and manage saved CRM index-page views. Supported object type values include contacts, companies, deals, tickets, or a raw object type ID such as 0-1. List views for an object type:
Create a view with an ordered column list:
Preview column changes before writing them:
Replace a property in the view’s columns and sort:
The replace-field command preserves the property’s column position and sort when it can. Filters are left unchanged. If the original property is still used in a filter, the command returns a filter warning so you can review that filter separately. Delete a saved view by running a dry run first, then re-running the command with the digest and confirmation value returned by the dry run:

Reports

Use reports commands to create reports from CRM SQL, retrieve saved report configuration, fetch report datasets, and manage report favorites. Create a saved report from a CRM SQL query:
You can filter report data by owner or team:
List and fetch saved reports:
Clone a report and manage favorites:
Generate AI insights for a saved report:
Delete a saved report by running a dry run first, then re-running the command with the digest and report name returned by the dry run. This is expected to require the appropriate elevated privileges for destructive report operations.

Activity transcripts

Use activities transcript get to fetch the transcript for a call or meeting activity ID returned by activities list.
Transcript output can include enriched fields when that data is available: recordingUrl, aiSummary, transcriptStatus, numUtterances, and transcriptionProvider. To request only specific enriched fields, use --fields:

Auth-sensitive commands

Most read and non-destructive write commands can run with either OAuth login or HUBSPOT_ACCESS_TOKEN, as long as the token has the required scopes. Some commands are auth-sensitive because they call account-level endpoints, require service key permissions, or need a local --dry-run safety digest before the CLI can execute the operation. Use the table below to choose an auth mode for common command groups: If a command fails with a missing-scope error, the auth mode is usually supported but the token needs additional scopes. With OAuth login, run hubspot auth login --force and approve the requested scopes. With HUBSPOT_ACCESS_TOKEN, update the service key scopes, export the updated token, and retry. If a command fails with an account-level endpoint error, such as User level OAuth token is not allowed for this endpoint, set HUBSPOT_ACCESS_TOKEN to a service key token with the required permissions. Some destructive commands require a local safety digest from a --dry-run before they execute. If you are using HUBSPOT_ACCESS_TOKEN and a safety digest command asks you to run hubspot auth login, sign in once with OAuth, keep HUBSPOT_ACCESS_TOKEN set, and retry the dry-run and apply flow.

Keep the CLI up to date

Choose an option below based on whether you installed the CLI manually on your computer or the CLI is installed in an agent workspace:

Installed on your computer

To download and install the latest Agent CLI binary, run:
If you also installed HubSpot Agent CLI Skills in this workspace, run npx skills update to keep your skills library up to date.

Installed in an agent workspace

Provide the prompt below to your AI agent to initiate the update process:

Disable automatic upgrades

Technical users who rely on generated scripts can disable automatic upgrade checks to keep CLI behavior consistent and reduce the risk that future breaking changes are installed automatically before those scripts are reviewed. To disable automatic upgrade checks for normal commands, set:
To confirm which CLI version your scripts will use, run:
This setting applies to automatic upgrade checks for normal commands. You can still install an update explicitly with hubspot upgrade.

Uninstall the Agent CLI

To manually uninstall the Agent CLI, run the command for your operating system to remove the binary and local configuration:
Then, remove the PATH entry that was added as part of the initial installation (e.g., from ~/.zshrc, ~/.bashrc, ~/.config/fish/config.fish, or your Windows user PATH).

Using the CLI with Claude Cowork

The CLI communicates with HubSpot via api.hubapi.com. In Claude Team and Enterprise accounts, outbound network access is restricted by default, which will cause install and upgrade commands to fail with a network error. This only affects organizations where an admin has not yet configured network egress permissions. If the CLI fails to install or run inside a Cowork session, have your Claude organization admin complete the steps below. Note that your admin will need a Team/Enterprise Owner or Primary Owner role in Claude.
  1. In your Claude account, navigate to Organization settings > Capabilities.
  2. Confirm Code execution and file creation is toggled on.
  3. Under Allow network egress, select Allow network egress to package managers and specific domains.
  4. Add api.hubapi.com to the allowed domains list and save.
Once saved, users in the organization can install and run the CLI from Cowork without additional configuration.

Control access with App Governance (Beta)

Most users should authenticate the Agent CLI with hubspot auth login. This starts the OAuth app install flow for HubSpot Agent CLI. Super Admins can use App Governance (Beta) to control who can connect the Agent CLI to a HubSpot account. This does not control whether someone can download the local hubspot binary, but it does control whether the CLI can be authorized to access account data. To manage access, go to Settings > Integrations > Connected Apps > Approved apps, then find HubSpot Agent CLI. From there, Super Admins can approve the connector, choose who can install it, and configure optional data permissions. Learn more about managing access to apps. If a user does not have install access, a request screen will appear after they execute the hubspot auth login command. The user can request approval from an account admin, optionally select approvers, add a due date, and include a message. After they’re approved, they can continue connecting the Agent CLI. For admin or automation workflows that use a service key token, see Admin mode via service key token. Service key token access is separate from the user-level OAuth install flow and should be limited to trusted admin-controlled environments. App Governance controls access to the OAuth connector, but does not remove current service key requirements for Admin mode operations.
Last modified on July 2, 2026