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:| Command | Description |
|---|---|
objects types | List available CRM object types for the account. |
objects list | List CRM records (contacts, companies, deals, tickets, custom objects). |
objects get <id> | Fetch a single record by ID. |
objects search | Filter records with search criteria. |
objects create | Create one or many records. |
objects update <id> | Update one or many records. |
objects merge | Merge two records. The secondary record is folded into the primary record and deleted. |
objects upsert | Create or update records by a unique property value. |
objects delete <id> | Delete one or many records. May require Admin mode via service key token and a --dry-run safety digest. |
pipelines list | List pipelines for an object type. |
pipelines get | Fetch a single pipeline by ID. |
pipelines create | Create a pipeline from JSON. |
pipelines update | Update a pipeline’s label. |
pipelines delete | Delete a pipeline. Requires a --dry-run safety digest and may require Admin mode via service key token. |
pipelines stages | List stages in a pipeline. |
pipelines stages-get | Fetch a single pipeline stage. |
pipelines stages-create | Create a pipeline stage from JSON. |
pipelines stages-update | Update a pipeline stage’s label. |
pipelines stages-delete | Delete a pipeline stage. Requires a --dry-run safety digest and may require Admin mode via service key token. |
properties list | List properties for an object type. |
properties get | Fetch a single property by name. |
properties create | Create a custom property. Requires property or schema write access for the object type. |
properties update | Update a property’s label or group. Requires property or schema write access for the object type. |
properties delete | Archive a property. Requires a --dry-run safety digest and may require Admin mode via service key token. |
properties batch-read | Batch read properties by name. |
properties batch-create | Batch create properties from JSONL. Requires property or schema write access for the object type. |
properties batch-archive | Batch archive properties by name. Requires a --dry-run safety digest and may require Admin mode via service key token. |
associations list | List associations between records. |
associations create | Create associations between records. Requires association write access to the participating object types. |
associations delete | Remove all associations between two records. Requires association write access to the participating object types. |
associations batch-read | Batch read associations from piped record IDs. |
associations batch-delete | Batch remove all associations from JSONL. Requires a --dry-run safety digest and may require Admin mode via service key token. |
associations batch-delete-labels | Batch remove specific labeled associations from JSONL. Requires a --dry-run safety digest and may require Admin mode via service key token. |
associations labels-list | List association label types between two object types. |
associations labels-create | Create a custom association label type. May require Admin mode via service key token. |
associations labels-update | Update a custom association label’s name. May require Admin mode via service key token. |
associations labels-delete | Delete a custom association label type. Requires a --dry-run safety digest and may require Admin mode via service key token. |
associations limits-list | List association limit configurations. |
associations limits-get | Get association limits between two object types. |
associations limits-create | Batch create association limits from JSONL. May require Admin mode via service key token. |
associations limits-update | Batch update association limits from JSONL. May require Admin mode via service key token. |
associations limits-delete | Batch delete association limits from JSONL. Requires a --dry-run safety digest and may require Admin mode via service key token. |
owners list | List HubSpot users. Requires owner read access. |
schemas list | List custom object schemas. Requires Admin mode via service key token. |
schemas get <objectType> | Fetch a single custom object schema. Requires Admin mode via service key token. |
schemas create | Create a custom object schema from JSON. Requires Admin mode via service key token. |
schemas update <objectType> | Update custom object schema metadata from JSON. Requires Admin mode via service key token and a --dry-run safety digest. |
schemas delete <objectType> | Delete a custom object schema and its records. Requires Admin mode via service key token and a --dry-run safety digest. |
workflows list | List workflows. |
workflows get <flowId> | Fetch one or more workflows by flow ID. |
workflows create | Create a workflow from JSON. |
workflows update <flowId> | Replace a workflow from JSON. Requires the automation scope and a --dry-run safety digest. |
workflows delete <flowId> | Delete a workflow. Requires the automation scope and a --dry-run safety digest. |
activities list | List activity history for a CRM record. |
activities transcript get | Fetch the transcript for a call or meeting activity. May require Admin mode via service key token. |
activities transcript delete | Delete the transcript for a call or meeting activity. Requires a --dry-run safety digest and may require Admin mode via service key token. |
activities emails threads get | Fetch all messages in the thread for an email engagement. May require Admin mode via service key token. |
activities calls dispositions list | List available call disposition labels for the account. |
history | View the local audit log for destructive operations. |
The currently supported top-level command groups are
objects, pipelines, properties, associations, owners, workflows, schemas, activities, and history. 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.
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:
| Command group | OAuth login support | When to use HUBSPOT_ACCESS_TOKEN |
|---|---|---|
objects list, objects get, objects search | Supported with object read scopes. | Use a service key when reading object types or custom object metadata that OAuth cannot access. |
objects create, objects update, objects merge, objects upsert | Supported with object write scopes for normal writes. Large bulk updates, merges, or upserts may require a safety digest. | Use a service key when the API requires account-level access or when automation needs account-level permissions. |
objects delete | May be blocked by account-level endpoint permissions. Bulk or GDPR deletes require a safety digest. | Use a service key with object write/delete permission for delete operations. |
pipelines list, pipelines get, pipelines stages, pipelines stages-get | Supported with pipeline and object read access. | Use a service key if a pipeline metadata endpoint returns an account-level auth error. |
pipelines create, pipelines update, pipelines stages-create, pipelines stages-update | Supported with pipeline write access. | Use a service key if OAuth cannot write pipeline metadata. |
pipelines delete, pipelines stages-delete | Requires a safety digest and may require account-level access. | Use a service key for destructive pipeline operations. |
properties list, properties get, properties batch-read | Supported with property or schema read access. | Use a service key if OAuth cannot read property metadata for the object type. |
properties create, properties update, properties batch-create | Supported when OAuth has the required property or schema write scopes. | Use a service key for account-level schema or property administration. |
properties delete, properties batch-archive | Requires a safety digest and may require account-level access. | Use a service key for destructive property operations. |
associations list, associations batch-read | Supported with object and association read access. | Use a service key if label or association metadata endpoints return account-level auth errors. |
associations create, associations delete, associations labels-create, associations labels-update, associations limits-create, associations limits-update | Supported when OAuth has the required object and association permissions; some label or limit endpoints may require account-level access. | Use a service key for account-level association definition or limit changes. |
associations batch-delete, associations batch-delete-labels, associations labels-delete, associations limits-delete | Requires a safety digest and may require account-level access. | Use a service key for destructive association metadata or bulk association removal. |
owners list | Supported with owner read access. | Use a service key if OAuth cannot access owner metadata. |
schemas list, schemas get, schemas create | Requires account-level custom schema access. | Use a service key with custom schema read or write scopes. |
schemas update, schemas delete | Requires account-level custom schema access and a safety digest. | Use a service key with custom schema write scopes. |
workflows list, workflows get, workflows create | Supported with the automation scope. | Use a service key for account-level workflow automation tasks or unattended automation. |
workflows update, workflows delete | Requires the automation scope and a safety digest. | Use a service key when the workflow operation needs account-level automation access. |
activities list | Supported when OAuth can read the base record and associated activity object types. | Use a service key if activity object reads are blocked by scopes or account-level permissions. |
activities transcript get, activities transcript delete, activities emails threads get, activities calls dispositions list | Some activity media and thread endpoints may require account-level access. Transcript delete requires a safety digest. | Use a service key with the relevant calling transcript, email, or activity scopes. |
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.
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:
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.
Bulk delete bounced contacts
The code block below retrieves all contacts who bounced on a sent email and bulk-deletes them from your CRM:Create contacts from a .jsonl file
The example below bulk-creates contacts from a.jsonl file:
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.
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.