Productivity and CRM

HubSpot API tokens: find, store, rotate, and use them safely with AI agents

HubSpot private app access tokens come from a legacy app: a super admin goes to Development, then Legacy apps, creates an app, picks scopes, and copies the token from the Auth tab. The token can be rotated from the same tab, and deleting the app revokes it.

HubSpot key types

TypePrefixSecret?ScopeExpiry
Private (legacy) app access token
Sent as Bearer [YOUR_TOKEN] in the Authorization header. HubSpot says legacy apps are still supported but lack the latest app features.
—YesThe scopes selected on the app's Scopes tabDoes not expire on its own; HubSpot recommends rotating every six months

How to create a HubSpot key

  1. Sign in to HubSpot as a super admin.
  2. In the left sidebar choose Development, then Legacy apps.
  3. Click Create legacy app and complete the setup.
  4. On the Scopes tab select only the scopes you need.
  5. Open the Auth tab and copy the access token.

Limiting what the key can do

Scopes are chosen on the Scopes tab and can be added or removed later. An app loses scopes if the account is downgraded and loses access to that functionality.

How to rotate a HubSpot key

  1. Open the app and go to the Auth tab.
  2. Click Rotate.
  3. Choose Rotate and expire now for a compromised token, or Rotate and expire later to keep the old token working for 7 days.

You can also expire the old token immediately or cancel a pending rotation. HubSpot recommends rotating every six months.

How to revoke a HubSpot key

  1. Open the app's Auth tab.
  2. Click Delete [app name] and type the app name to confirm. The token is permanently revoked.

If your HubSpot key leaked

  1. Rotate the token on the Auth tab with Rotate and expire now.
  2. Update every service that used the old token.
  3. Review the scopes and remove any the app does not need.

Things that catch people out

  • Only a super admin can create a legacy app.
  • Rotating with an expiry window leaves the old token valid for 7 days, so use "expire now" after a leak.
  • Removing the user who created the app can break calls until you rotate the token.

Common HubSpot authentication errors

USER_DOES_NOT_HAVE_PERMISSIONS

The user who created the app was removed, so some calls fail.

Using your HubSpot key with AI agents

A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.

BotPassword works this way. For a HubSpot key, these intents fit:

IntentWhat BotPassword does
run_withRuns a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
http_requestMakes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
rotatePartly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.

HubSpot also publishes its own MCP server. Whatever server the agent uses, keep the credential it authenticates with out of the agent's context.

Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents

Frequently asked questions

Where do I find my HubSpot private app token?

Open the app under Development, Legacy apps, and look at the Auth tab.

How do I rotate a HubSpot private app token?

On the Auth tab click Rotate, then choose to expire the old token now or after 7 days.

How do I revoke a HubSpot private app token?

Delete the app from its Auth tab. That permanently revokes the token.

Can an AI agent use my HubSpot key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with run_with, http_request, so the agent gets the result and never the value.

Stop pasting HubSpot keys into agents

BotPassword is in early access. Request an invite and we'll email you when your spot opens.