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.- macOS/Linux
- Windows PowerShell
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:npx skills update to keep your skills library up to date in the installed agent workspace.
Authenticate with your HubSpot account
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: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..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.
Check your session status
You can verify the authenticated user, token type, and authenticated HubSpot account ID by running the following command: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 ofhubspot <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
Useobjects types to list the CRM object types available in the connected account, including custom objects and newer standard CRM object types.
--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:
Filter and search
Use theobjects 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 theproperties 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:
--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:
- Search for a contact by their email, pipe the output to update the
tierproperty of the matched contact to gold. - The corresponding output is first saved to a
plan.jsonlfile where the forthcoming results could first be reviewed. - Once reviewed, the
plan.jsonlfile could then be piped directly into theobjects updatecommand without the--dry-runflag 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
Useviews 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:
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
Usereports 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:
Activity transcripts
Useactivities transcript get to fetch the transcript for a call or meeting activity ID returned by activities list.
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 orHUBSPOT_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: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: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:- macOS/Linux
- Windows PowerShell
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 viaapi.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.
- In your Claude account, navigate to Organization settings > Capabilities.
- Confirm Code execution and file creation is toggled on.
- Under Allow network egress, select Allow network egress to package managers and specific domains.
- Add
api.hubapi.comto the allowed domains list and save.
Control access with App Governance (Beta)
Most users should authenticate the Agent CLI withhubspot 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.