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

Source: https://botpassword.com/keys/hubspot
Last checked: 2026-10-25

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.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Private (legacy) app access token | — | Yes | The scopes selected on the app's Scopes tab | Does 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.

## 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 the 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.

## Gotchas

- 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.

## Using this key with AI agents (BotPassword)

- `run_with`: Runs 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_request`: Makes 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.
- `rotate`: Partly 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.

## FAQ

### 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.

## Sources

- https://developers.hubspot.com/docs/api/private-apps
- https://developers.hubspot.com/mcp
