> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hitheo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建 Hook

> 安装一个自主 Hook，当匹配的事件发生时触发技能执行。

## 请求

<ParamField body="hook_preset_id" type="string" optional>
  内置 Hook 预设的 ID（例如 `share.accepted.welcome`、`task.overdue.summary`）。与 `event_pattern` 互斥。
</ParamField>

<ParamField body="event_pattern" type="string" optional>
  要匹配的自定义事件模式。支持精确匹配（`share.accepted`）、通配符（`order.*.completed`）、前缀匹配（`share`）或全匹配（`*`）。与 `hook_preset_id` 互斥。
</ParamField>

<ParamField body="skill_slug" type="string" required>
  Hook 触发时要执行的技能 slug。
</ParamField>

<ParamField body="cooldown_minutes" type="number" optional>
  两次触发之间的最短间隔时间（分钟，1–1440）。省略时将应用服务端默认值。
</ParamField>

## 响应

<ResponseField name="id" type="string">
  该 Hook 的唯一 UUID。
</ResponseField>

<ResponseField name="event_pattern" type="string">
  解析后的事件模式（来自预设或自定义）。
</ResponseField>

<ResponseField name="skill_slug" type="string">
  目标技能 slug。
</ResponseField>

<ResponseField name="enabled" type="boolean">
  创建时始终为 `true`。
</ResponseField>

<ResponseField name="cooldown_minutes" type="number">
  两次触发之间的冷却周期。
</ResponseField>

## 身份验证

需要具有 `completions` 权限范围的 API 密钥。

## 示例

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://www.hitheo.ai/api/v1/hooks \
    -H "Authorization: Bearer $THEO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "event_pattern": "order.*.completed",
      "skill_slug": "order-processor",
      "cooldown_minutes": 5
    }'
  ```

  ```typescript SDK theme={null}
  const hook = await theo.createHook({
    event_pattern: "order.*.completed",
    skill_slug: "order-processor",
    cooldown_minutes: 5,
  });
  ```
</CodeGroup>

## 护栏

* 每次自主执行前进行预检信用额度检查
* 自主操作单独设有每日上限
* 对工具调用次数和总支出设有单次运行上限
* Hook 在连续失败后会自动暂停
* 强制执行两次触发之间的冷却时间


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.