workflow-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Resources

资源

FileWhen to use
resources/workflow-json-reference.md
Body shape for create/update — top-level fields,
enrollmentCriteria
, common action types, full-PUT pitfall
resources/example-contact-flow.json
Minimal valid
CONTACT_FLOW
body for
hubspot workflows create --file
文件使用场景
resources/workflow-json-reference.md
创建/更新请求的主体结构——顶级字段、
enrollmentCriteria
、常见操作类型、全量PUT的陷阱
resources/example-contact-flow.json
用于
hubspot workflows create --file
的最小有效
CONTACT_FLOW
主体

Source of truth

权威参考来源

hubspot workflows --help
lists five subcommands:
list
,
get
,
create
,
update
,
delete
. There is no
search
— finding by name is
list | jq
. For JSONL piping, pagination, and destructive dry-run/digest/confirm patterns, this skill builds on
bulk-operations/SKILL.md
— re-read that first.
hubspot workflows --help
列出了五个子命令:
list
get
create
update
delete
没有
search
命令
——按名称查找需要使用
list | jq
。关于JSONL管道、分页以及破坏性操作的预演(dry-run)/摘要(digest)/确认(confirm)模式,本技能基于
bulk-operations/SKILL.md
构建,请先重新阅读该文档。

1. List + find by name

1. 列出工作流并按名称查找

bash
hubspot workflows list                       # JSONL: id, name, isEnabled, type, objectTypeId, revisionId
hubspot workflows list --format table        # for human scanning
bash
hubspot workflows list                       # JSONL格式:id, name, isEnabled, type, objectTypeId, revisionId
hubspot workflows list --format table        # 适合人工查看的表格格式

Find by name — case-insensitive substring

按名称查找——不区分大小写的子串匹配

hubspot workflows list | jq -c 'select(.name | test("Welcome"; "i"))'
hubspot workflows list | jq -c 'select(.name | test("Welcome"; "i"))'

Exact match

精确匹配

hubspot workflows list | jq -c 'select(.name == "MQL Nurture")'

List is paginated at 100 per call. Loop with `--after` until `meta.next` is empty — see `bulk-operations/SKILL.md` "Pagination". See `resources/json-patterns.md` in `bulk-operations` for more `jq` filters.
hubspot workflows list | jq -c 'select(.name == "MQL Nurture")'

列出操作默认每页返回100条结果。使用`--after`参数循环调用,直到`meta.next`为空——详见`bulk-operations/SKILL.md`中的“分页”章节。更多`jq`过滤器可查看`bulk-operations`中的`resources/json-patterns.md`。

2. Get + read shape

2. 获取工作流并查看结构

bash
hubspot workflows get 12345678                            # one
hubspot workflows get 12345678 87654321                   # batch positional
printf '%s\n' 12345678 87654321 | hubspot workflows get   # batch stdin
hubspot workflows get 12345678 > workflow.json            # save for editing
Get returns the full body (
actions
,
enrollmentCriteria
,
revisionId
, …) — the shape required by create/update. See
resources/workflow-json-reference.md
.
bash
hubspot workflows get 12345678                            # 获取单个工作流
hubspot workflows get 12345678 87654321                   # 批量获取(位置参数)
printf '%s\n' 12345678 87654321 | hubspot workflows get   # 批量获取(标准输入)
hubspot workflows get 12345678 > workflow.json            # 保存结果用于编辑
获取操作会返回完整的工作流主体(包含
actions
enrollmentCriteria
revisionId
等)——这正是创建/更新操作所需的结构。详见
resources/workflow-json-reference.md

3. Create from JSON

3. 通过JSON创建工作流

bash
hubspot workflows create --file workflow.json --dry-run
hubspot workflows create --file workflow.json
cat workflow.json | hubspot workflows create         # stdin also works
Set
type
to
CONTACT_FLOW
or
PLATFORM_FLOW
; for
PLATFORM_FLOW
include
objectTypeId
. See
resources/workflow-json-reference.md
for the body shape, and
resources/example-contact-flow.json
for a minimal template. Easiest path:
get
an existing similar workflow as a starting template
rather than hand-writing the JSON.
bash
hubspot workflows create --file workflow.json --dry-run
hubspot workflows create --file workflow.json
cat workflow.json | hubspot workflows create         # 标准输入方式同样生效
需将
type
设置为
CONTACT_FLOW
PLATFORM_FLOW
;若为
PLATFORM_FLOW
需包含
objectTypeId
。请求主体结构详见
resources/workflow-json-reference.md
,最小模板可参考
resources/example-contact-flow.json
最简路径:获取一个现有同类工作流作为起始模板,而非手动编写JSON

4. Update — full PUT, get-modify-put round-trip

4. 更新工作流——全量PUT,获取-修改-提交流程

Update is a full replace. The body must include
revisionId
(from
get
) and
type
. Read-only fields (
createdAt
,
updatedAt
,
dataSources
) are stripped automatically. Update is gated: dry-run first, then re-run with
--digest <hash> --confirm <flowId>
.
bash
undefined
更新操作是全量替换。请求主体必须包含
revisionId
(来自获取操作)和
type
。只读字段(
createdAt
updatedAt
dataSources
)会被自动忽略。更新操作受安全机制限制:先执行预演,再使用
--digest <hash> --confirm <flowId>
重新执行。
bash
undefined

1. Fetch current state

1. 获取当前状态

hubspot workflows get 12345678 > workflow.json
hubspot workflows get 12345678 > workflow.json

2. Edit workflow.json (preserve revisionId, type, and any field you want to keep)

2. 编辑workflow.json(保留revisionId、type以及所有需要保留的字段)

3. Dry-run — emits a digest

3. 预演——生成摘要

hubspot workflows update 12345678 --file workflow.json --dry-run
hubspot workflows update 12345678 --file workflow.json --dry-run

4. Apply — confirm value is the flow id

4. 应用更新——确认值为工作流ID

hubspot workflows update 12345678 --file workflow.json
--digest blast-xxxxxxxx --confirm 12345678

**Pitfall:** partial bodies silently clear fields. Sending only `actions` will wipe `enrollmentCriteria`. Always start from the full `get` response.
hubspot workflows update 12345678 --file workflow.json
--digest blast-xxxxxxxx --confirm 12345678

**陷阱:** 部分主体会静默清空未指定的字段。仅发送`actions`会清除`enrollmentCriteria`。始终从完整的获取响应开始编辑。

5. Delete — destructive, link to bulk safety flow

5. 删除工作流——破坏性操作,关联批量安全流程

bash
undefined
bash
undefined

1. Dry-run — emits a digest + the confirm hint

1. 预演——生成摘要和确认提示

hubspot workflows delete 12345678 --dry-run
hubspot workflows delete 12345678 --dry-run

2. Re-run with digest + confirm. Confirm value is the workflow's NAME, not its id.

2. 使用摘要和确认信息重新执行。确认值为工作流的名称,而非ID。

hubspot workflows delete 12345678 --digest blast-xxxxxxxx --confirm "New lead routing"

The dry-run output includes an `apply_command_hint` — copy the exact confirm string from there to avoid quoting surprises. Workflows cannot be restored through the automation API after deletion; check `hubspot history --since 1h` for an audit record. The full safety pattern (digest, 5-minute expiry, history recovery) is documented in `bulk-operations/SKILL.md` "Safe destructive workflow".
hubspot workflows delete 12345678 --digest blast-xxxxxxxx --confirm "New lead routing"

预演输出包含`apply_command_hint`——从其中复制准确的确认字符串以避免引号问题。工作流删除后无法通过自动化API恢复;可查看`hubspot history --since 1h`获取审计记录。完整的安全模式(摘要、5分钟有效期、历史恢复)详见`bulk-operations/SKILL.md`中的“安全破坏性工作流”章节。

Known limitations

已知限制

  • No
    hubspot workflows search
    list | jq
    is the workaround.
  • No Lists API in the CLI — list-membership enrollment triggers must be wired up in the UI.
  • No sequences/cadences API.
    dataSources
    is read-only — cannot be rewired via update.
  • hubspot workflows search
    命令——替代方案是
    list | jq
  • CLI中无列表API——列表成员资格注册触发器需在UI中配置。
  • 无序列/节奏API。
    dataSources
    为只读字段——无法通过更新操作重新配置。