GuideDeveloperSmart CRM

HubSpot Agent CLI: install it, sign in, and run your first safe commands

The Agent CLI is a command-line tool made for AI agents like Claude Code. It is separate from the hs developer CLI, and it can change live data.

Subscription
Beta; available with all products and plans
Permissions
Your HubSpot user permissions; Super Admin approval if App Governance is on
Time
10 min · Advanced
Validated

Short answer

The HubSpot Agent CLI is a beta command-line tool, run as hubspot, that lets AI agents such as Claude Code, Claude Cowork and Codex read and change CRM data using your HubSpot permissions. Install it with HubSpot's script, sign in with hubspot auth login, add the skills with npx skills add hubspot/agent-cli-skills, and use --dry-run before any write. It is not the hs CLI that builds apps, themes and modules. Write commands can delete live data, so start with reads and test in a sandbox when you can.

1. What it is, and what it is not

HubSpot's docs describe the Agent CLI as a command-line tool designed primarily for AI agents. An agent installs it, then uses it to work with your CRM on your behalf. You can also run it yourself in a terminal for scripting. It works with the permissions of the connected HubSpot user, so depending on your access it can create, update or delete records.

It is a different tool from hs, the @hubspot/cli developer CLI that builds apps, themes and modules. The Agent CLI is the hubspot command. If you only want one-off questions or drafts from your HubSpot data, HubSpot points to the Claude and ChatGPT connectors, which need no CLI install. See use the HubSpot connector in Claude.

Beta, and it can delete

HubSpot's developer page says commands, flags and behavior may change without notice, and that create, update and delete can modify or permanently delete live data. It strongly recommends --dry-run before changes and testing in a sandbox account when you can.

2. Install it

The easiest route is to paste HubSpot's prompt into your agent, which installs the CLI, signs in, adds the skills and explores hubspot --help. To do it by hand, the installer runs from HubSpot's API host. Read the script first if you prefer.

# macOS, Linux, WSL, Bash
curl -fsSL https://api.hubapi.com/hub/cli/backend/hub-cli/latest/install.sh | sh

# Windows PowerShell
irm https://api.hubapi.com/hub/cli/backend/hub-cli/latest/install.ps1 | iex

The installer adds the CLI to your PATH, so open a new terminal and check it.

Terminal showing hubspot --version and the top of hubspot --help listing command groups like objects, pipelines and workflows
Terminal output: the version (top) and the command groups (1).
Example from my portal

This machine already had the CLI installed. hubspot --version printed 0.15.1, and the help lists command groups such as objects, pipelines, properties, workflows, reports and segments.

Using Claude Cowork on a Team or Enterprise plan? HubSpot says outbound network access is restricted by default, so install and upgrade can fail with a network error until a Claude organization admin allows api.hubapi.com under Organization settings > Capabilities.

3. Sign in

Most people should use OAuth. Run hubspot auth login. A browser window opens, you sign in, review the permissions and click Connect app. The token matches your user permissions, refreshes itself, and hubspot auth logout clears it. Check the session any time with hubspot whoami.

The first screen lists the accounts your login can reach and asks you to choose one. Pick the account, then click Choose Account.

Connecting HubSpot Agent CLI to HubSpot page with a Choose an account list
Choose the account (1).

The next screen lists what the CLI can access. One permission is required, and the rest are optional. The Select switch offers All, View-only and None.

Permission screen for HubSpot Agent CLI with one required permission, 85 optional permissions, and a View-only select option
View-only (1) and the required permission (2).
Example from my portal

I connected my demo portal and chose View-only, which ticked the read permissions and left the create, delete and change permissions unticked. The page showed 85 optional permissions. For a first run, that is the safest choice.

Bottom of the permission screen showing read permissions ticked, write permissions unticked, and Connect app and Cancel buttons
Connect app (1).

After Connect app, the browser lands on a local page at 127.0.0.1:3000 that says Authentication successful, and the terminal confirms the portal. On my machine the CLI also printed that an update was available and upgraded itself first.

Terminal showing hubspot whoami returning a not authenticated error
Terminal output: whoami before signing in (1).
Example from my portal

Before I signed in, hubspot whoami answered with an error that says to run hubspot auth login or set HUBSPOT_ACCESS_TOKEN. That is the expected state of a fresh install.

Terminal showing hubspot whoami returning authType oauth, a user, a portal ID and a list of read scopes
Terminal output: whoami after signing in (1).
Example from my portal

After signing in, whoami showed authType oauth, my user, the demo portal ID, and a list of scopes that were all read scopes, matching the View-only choice.

Admin mode. During the beta, some account-level operations do not work with OAuth alone, such as schema changes, deleting records, and some association, activity and destructive commands. For those, HubSpot has you set a service key as the HUBSPOT_ACCESS_TOKEN environment variable. When it is set, the CLI uses it before cached OAuth credentials, and unset HUBSPOT_ACCESS_TOKEN returns you to OAuth. HubSpot warns that admin mode has broader permissions and no per-user audit trail, so keep it to trusted environments.

4. Run commands

Commands follow hubspot <noun> <verb>, and --help works at every level.

hubspot --help
hubspot objects --help
hubspot objects types
hubspot objects search --type contacts --filter "email=jane@example.com"
hubspot objects list --type contacts --properties email,firstname,lastname
Terminal showing hubspot objects count for contacts and deals, and the first object types
Terminal output: counts (1, 2) and object types (3).
Example from my portal

Against my demo portal, objects count --type contacts returned a total of 179,942 and deals returned 25. I used counts so no contact names appear. objects types printed 99 object types.

Output is JSONL by default, which agents handle well. Use --format json or --format table when a person is reading. HubSpot's list covers objects, pipelines, properties, associations, owners, workflows, views, schemas, activities, reports, segments, conversations, sequences, imports, analytics and more.

Not every command works with OAuth alone during the beta. On my View-only login, hubspot pipelines list --type deals was refused with a message that the endpoint does not support user-level OAuth tokens and that I should set HUBSPOT_ACCESS_TOKEN to a service key.

Terminal showing hubspot pipelines list failing because the endpoint does not support user-level OAuth tokens
Terminal output: the OAuth limit (1).

5. Always dry-run writes first

Every write command supports --dry-run, which prints what would happen without changing anything. HubSpot says the output has the same shape as the input for the next command, so you can save a plan, read it, then feed it back in.

Terminal showing hubspot objects update --help with the dry-run, digest and confirm options and examples
Terminal output: the dry run option (1), digest and confirm for bulk changes (2), and the examples (3).
hubspot objects search --type contacts --filter "email~example.com" --format jsonl \
  | hubspot objects update --type contacts --property tier=gold --dry-run > plan.jsonl

cat plan.jsonl | hubspot objects update --type contacts
Terminal showing a dry run of an objects update with executed false, records affected 1, and reversible false
Terminal output: a dry run changes nothing (1).
Example from my portal

I ran a dry run that would set a demo contact's lifecycle stage to customer. The result said executed false, 1 record affected, and reversible false. Nothing changed, and the plan warned that the change could not be undone.

Some destructive commands, such as deletes, also need a safety digest from a prior dry run, and the help for objects update lists --digest and --confirm for bulk changes. hubspot history shows a local audit log of destructive operations.

6. Add the skills

In the agent workspace, run npx skills add hubspot/agent-cli-skills. The skills are markdown files that give the agent guidance for HubSpot tasks. HubSpot's repository lists skills such as bulk-operations (the foundation, covering JSONL pipes and dry runs), crm-lookup, crm-data-quality, deal-management, sales-reporting, team-ownership, ticket-resolution and workflow-automation. Read them in the public repository before you let an agent follow them. Run npx skills update to refresh, and hubspot upgrade to update the CLI itself.

7. Control who can connect it

HubSpot recommends admins join the App Governance beta. Super Admins then go to Settings > Integrations > Connected Apps > Approved apps, find HubSpot Agent CLI, and approve it, choose who can install it and set optional data permissions. A user without install access sees a request screen after hubspot auth login and can ask a Super Admin to approve. This controls authorizing the OAuth connector, not downloading the binary, and it does not cover admin mode with a service key.

Connected Apps page on the Approved apps tab with an Approve apps button and a table of approved apps with Manage access buttons
Approve apps (1), the approved list (2) and Manage access (3).
Example from my portal

My Approved apps tab lists 14 apps, each with its access type, how many users installed it, its install permissions and a Manage access button.

8. Habits HubSpot recommends

  • Start with reports, summaries and analysis before anything that modifies data.
  • For scheduled or recurring tasks, start with one narrow use case.
  • Review recommendations and large updates before applying them.
  • Use clear prompts that describe the result you want, and follow your data governance policy.

Sources

New field notes by email

One email when a new article publishes.

Still stuck?

If this did not fix it, the problem is probably specific to your setup. Book a call and we will look at it together.

Book a call with Sam