HubSpot by @altf1be
Full HubSpot platform CLI covering CRM, CMS, Marketing, Conversations, and Automation.
Setup
- 1. Create a Private App in HubSpot: Settings > Integrations > Private Apps
- Set environment variables (or create
.env in {baseDir}):
CODEBLOCK0
- 3. Configure the required Private App scopes in HubSpot (Settings > Integrations > Private Apps > your app > Scopes):
| Scope | Description |
|---|
| INLINECODE2 | View properties and other details about contacts |
| INLINECODE3 |
Create, delete, or make changes to contacts |
|
crm.objects.companies.read | View properties and other details about companies |
|
crm.objects.companies.write | Create, delete, or make changes to companies |
|
crm.objects.deals.read | View properties and other details about deals |
|
crm.objects.deals.write | Create, delete, or make changes to deals |
|
crm.objects.owners.read | View details about users assigned to a CRM record |
|
crm.schemas.contacts.read | View details about property settings for contacts |
|
crm.schemas.companies.read | View details about property settings for companies |
|
crm.schemas.deals.read | View details about property settings for deals |
|
tickets | View, create, delete, or make changes to tickets |
|
automation | Workflows |
|
content | Sites, landing pages, CTA, email, blog, campaigns |
|
conversations.read | View messages, comments, threads, recipient/user/assignment details |
|
forms | Access to the Forms API |
- 4. Install dependencies: INLINECODE17
Commands
CRM — Contacts
CODEBLOCK1
CRM — Companies
CODEBLOCK2
CRM — Deals
CODEBLOCK3
CRM — Tickets
CODEBLOCK4
CRM — Owners
CODEBLOCK5
CRM — Pipelines
CODEBLOCK6
CRM — Associations (v4)
CODEBLOCK7
CRM — Properties
CODEBLOCK8
CRM — Engagements
CODEBLOCK9
CMS — Blog Posts
CODEBLOCK10
CMS — Pages
CODEBLOCK11
CMS — Domains
CODEBLOCK12
Marketing — Email Campaigns
CODEBLOCK13
Marketing — Forms
CODEBLOCK14
Marketing — Marketing Emails
CODEBLOCK15
Marketing — Contact Lists
CODEBLOCK16
Conversations
CODEBLOCK17
Automation — Workflows
CODEBLOCK18
Security
- - Auth method: Bearer token (Private App) or OAuth 2.0 with auto-refresh
- No secrets or tokens printed to stdout
- All delete operations require explicit
--confirm flag - Built-in rate limiting with exponential backoff retry (3 attempts)
- OAuth tokens cached in INLINECODE19
- Lazy config validation (only checked when a command runs)
Dependencies
- -
commander — CLI framework - INLINECODE21 — environment variable loading
- Node.js built-in
fetch (requires Node >= 18)
Author
Abdelkrim BOUJRAF — ALT-F1 SRL, Brussels 🇧🇪 🇲🇦
X: @altf1be
HubSpot by @altf1be
覆盖CRM、CMS、营销、对话和自动化的完整HubSpot平台CLI。
设置
- 1. 在HubSpot中创建私有应用:设置 > 集成 > 私有应用
- 设置环境变量(或在{baseDir}中创建.env文件):
必需(私有应用模式)
HUBSPOT
ACCESSTOKEN=pat-na1-xxxxxxxx
或使用OAuth 2.0模式(设置以下三项):
HUBSPOTCLIENTID=your-client-id
HUBSPOTCLIENTSECRET=your-client-secret
HUBSPOTREFRESHTOKEN=your-refresh-token
可选
HUBSPOTMAXRESULTS=100
- 3. 在HubSpot中配置所需的私有应用作用域(设置 > 集成 > 私有应用 > 你的应用 > 作用域):
| 作用域 | 描述 |
|---|
| crm.objects.contacts.read | 查看联系人的属性及其他详细信息 |
| crm.objects.contacts.write |
创建、删除或修改联系人 |
| crm.objects.companies.read | 查看公司的属性及其他详细信息 |
| crm.objects.companies.write | 创建、删除或修改公司 |
| crm.objects.deals.read | 查看交易的属性及其他详细信息 |
| crm.objects.deals.write | 创建、删除或修改交易 |
| crm.objects.owners.read | 查看分配给CRM记录的用户详细信息 |
| crm.schemas.contacts.read | 查看联系人的属性设置详细信息 |
| crm.schemas.companies.read | 查看公司的属性设置详细信息 |
| crm.schemas.deals.read | 查看交易的属性设置详细信息 |
| tickets | 查看、创建、删除或修改工单 |
| automation | 工作流 |
| content | 网站、落地页、CTA、邮件、博客、营销活动 |
| conversations.read | 查看消息、评论、线程、收件人/用户/分配详细信息 |
| forms | 访问表单API |
- 4. 安装依赖:cd {baseDir} && npm install
命令
CRM — 联系人
bash
列出联系人
node {baseDir}/scripts/hubspot.mjs contacts list
按邮箱搜索联系人
node {baseDir}/scripts/hubspot.mjs contacts search --query john@example.com
读取联系人详情
node {baseDir}/scripts/hubspot.mjs contacts read --id 123
创建联系人
node {baseDir}/scripts/hubspot.mjs contacts create --email jane@example.com --firstname Jane --lastname Doe
更新联系人
node {baseDir}/scripts/hubspot.mjs contacts update --id 123 --phone +1234567890
删除联系人(需要--confirm)
node {baseDir}/scripts/hubspot.mjs contacts delete --id 123 --confirm
CRM — 公司
bash
node {baseDir}/scripts/hubspot.mjs companies list
node {baseDir}/scripts/hubspot.mjs companies search --query Acme
node {baseDir}/scripts/hubspot.mjs companies read --id 456
node {baseDir}/scripts/hubspot.mjs companies create --name Acme Corp --domain acme.com
node {baseDir}/scripts/hubspot.mjs companies update --id 456 --industry Technology
node {baseDir}/scripts/hubspot.mjs companies delete --id 456 --confirm
CRM — 交易
bash
node {baseDir}/scripts/hubspot.mjs deals list
node {baseDir}/scripts/hubspot.mjs deals search --query Enterprise
node {baseDir}/scripts/hubspot.mjs deals read --id 789
node {baseDir}/scripts/hubspot.mjs deals create --name Big Deal --amount 50000 --stage appointmentscheduled
node {baseDir}/scripts/hubspot.mjs deals update --id 789 --stage closedwon
node {baseDir}/scripts/hubspot.mjs deals delete --id 789 --confirm
CRM — 工单
bash
node {baseDir}/scripts/hubspot.mjs tickets list
node {baseDir}/scripts/hubspot.mjs tickets search --query Bug
node {baseDir}/scripts/hubspot.mjs tickets read --id 101
node {baseDir}/scripts/hubspot.mjs tickets create --subject Login broken --priority HIGH
node {baseDir}/scripts/hubspot.mjs tickets update --id 101 --stage 2
node {baseDir}/scripts/hubspot.mjs tickets delete --id 101 --confirm
CRM — 所有者
bash
node {baseDir}/scripts/hubspot.mjs owners list
node {baseDir}/scripts/hubspot.mjs owners list --email john@company.com
node {baseDir}/scripts/hubspot.mjs owners read --id 55
CRM — 管道
bash
列出交易管道(默认)
node {baseDir}/scripts/hubspot.mjs pipelines list
列出工单管道
node {baseDir}/scripts/hubspot.mjs pipelines list --object-type tickets
CRM — 关联(v4)
bash
列出从联系人到公司的关联
node {baseDir}/scripts/hubspot.mjs associations list --from-type contacts --from-id 123 --to-type companies
创建关联
node {baseDir}/scripts/hubspot.mjs associations create --from-type contacts --from-id 123 --to-type companies --to-id 456 --type-id 1
删除关联(需要--confirm)
node {baseDir}/scripts/hubspot.mjs associations delete --from-type contacts --from-id 123 --to-type companies --to-id 456 --confirm
CRM — 属性
bash
列出联系人属性(默认)
node {baseDir}/scripts/hubspot.mjs properties list
列出交易属性
node {baseDir}/scripts/hubspot.mjs properties list --object-type deals
CRM — 互动记录
bash
node {baseDir}/scripts/hubspot.mjs engagements notes
node {baseDir}/scripts/hubspot.mjs engagements emails
node {baseDir}/scripts/hubspot.mjs engagements calls
node {baseDir}/scripts/hubspot.mjs engagements tasks
node {baseDir}/scripts/hubspot.mjs engagements meetings
CMS — 博客文章
bash
node {baseDir}/scripts/hubspot.mjs blog-posts list
node {baseDir}/scripts/hubspot.mjs blog-posts list --state PUBLISHED
node {baseDir}/scripts/hubspot.mjs blog-posts read --id 1001
node {baseDir}/scripts/hubspot.mjs blog-posts create --name My Post
node {baseDir}/scripts/hubspot.mjs blog-posts update --id 1001 --name Updated Title
CMS — 页面
bash
node {baseDir}/scripts/hubspot.mjs pages list
node {baseDir}/scripts/hubspot.mjs pages read --id 2001
CMS — 域名
bash
node {baseDir}/scripts/hubspot.mjs domains list
营销 — 邮件营销活动
bash
node {baseDir}/scripts/hubspot.mjs email-campaigns list
node {baseDir}/scripts/hubspot.mjs email-campaigns read --id 3001
营销 — 表单
bash
node {baseDir}/scripts/hubspot.mjs forms list
node {baseDir}/scripts/hubspot.mjs forms read --id 4001
营销 — 营销邮件
bash
node {baseDir}/scripts/hubspot.mjs marketing-emails list
node {baseDir}/scripts/hubspot.mjs marketing-emails read --id 5001
node {baseDir}/scripts/hubspot.mjs marketing-emails stats --id 5001
营销 — 联系人列表
bash
node {baseDir}/scripts/hubspot.mjs lists list
node {baseDir}/scripts/hubspot.mjs lists read --id 6001
对话
bash
node {baseDir}/scripts/hubspot.mjs conversations list
node {baseDir}/scripts/hubspot.mjs conversations read --id 7001
node {baseDir}/scripts/hubspot.mjs messages list --thread-id 7001
自动化 — 工作流
bash
node {baseDir}/scripts/hubspot.mjs workflows list
node {baseDir}/scripts/hubspot.mjs workflows read --id 8001
安全性
- - 认证方式:Bearer令牌(私有应用)或带自动刷新的OAuth 2.0
- 不会将密钥或令牌输出到stdout
- 所有删除操作需要显式