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

# 示例：追踪职位发布

> 使用 company_first 和 signal_first 检测模式监控职位发布的完整演练——附可复制代码。

本指南演示两个实际场景。每个代码块都可以直接复制、粘贴和运行——只需将 `YOUR_API_KEY` 替换为你的实际密钥。

<Tabs>
  <Tab title="公司优先：追踪 OpenAI">
    ## 场景：监控 OpenAI 何时发布新职位

    你希望在 OpenAI 发布职位空缺时立即收到通知——并自动获取其工程领导层的联系方式。

    ### 创建 monitor

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.pubrio.com/monitors/create \
        -H "Content-Type: application/json" \
        -H "pubrio-api-key: YOUR_API_KEY" \
        -d '{
          "name": "OpenAI Job Tracker",
          "detection_mode": "company_first",
          "signal_types": ["jobs"],
          "signal_filters": [
            {
              "signal_type": "jobs",
              "filters": {
                "locations": ["US"]
              }
            }
          ],
          "companies": [
            "67c4696b-b7b0-46b5-b2af-9f434543661e"
          ],
          "is_company_enrichment": true,
          "is_people_enrichment": true,
          "people_enrichment_configs": [
            {
              "max_people_to_return": 5,
              "people_contact_types": ["email-work"],
              "filters": {
                "management_levels": ["director", "vp"],
                "departments": ["master_engineering"]
              }
            }
          ],
          "destination_type": "webhook",
          "destination_config": {
            "webhook_url": "https://usewebhook.com/YOUR_WEBHOOK_ID",
            "headers": {
              "Authorization": "Bearer your-secret-token"
            }
          },
          "max_records_per_trigger": 5,
          "profile_id": 1
        }'
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "https://api.pubrio.com/monitors/create",
          headers={
              "Content-Type": "application/json",
              "pubrio-api-key": "YOUR_API_KEY"
          },
          json={
              "name": "OpenAI Job Tracker",
              "detection_mode": "company_first",
              "signal_types": ["jobs"],
              "signal_filters": [
                  {
                      "signal_type": "jobs",
                      "filters": {
                          "locations": ["US"]
                      }
                  }
              ],
              "companies": [
                  "67c4696b-b7b0-46b5-b2af-9f434543661e"
              ],
              "is_company_enrichment": True,
              "is_people_enrichment": True,
              "people_enrichment_configs": [
                  {
                      "max_people_to_return": 5,
                      "people_contact_types": ["email-work"],
                      "filters": {
                          "management_levels": ["director", "vp"],
                          "departments": ["master_engineering"]
                      }
                  }
              ],
              "destination_type": "webhook",
              "destination_config": {
                  "webhook_url": "https://usewebhook.com/YOUR_WEBHOOK_ID",
                  "headers": {
                      "Authorization": "Bearer your-secret-token"
                  }
              },
              "max_records_per_trigger": 5,
              "profile_id": 1
          }
      )

      data = response.json()
      print(f"Monitor created: {data['data']['monitor_id']}")
      print(f"Signature: {data['data']['signature']}")
      ```

      ```javascript Node.js theme={null}
      const response = await fetch("https://api.pubrio.com/monitors/create", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "pubrio-api-key": "YOUR_API_KEY"
        },
        body: JSON.stringify({
          name: "OpenAI Job Tracker",
          detection_mode: "company_first",
          signal_types: ["jobs"],
          signal_filters: [
            {
              signal_type: "jobs",
              filters: {
                locations: ["US"]
              }
            }
          ],
          companies: [
            "67c4696b-b7b0-46b5-b2af-9f434543661e"
          ],
          is_company_enrichment: true,
          is_people_enrichment: true,
          people_enrichment_configs: [
            {
              max_people_to_return: 5,
              people_contact_types: ["email-work"],
              filters: {
                management_levels: ["director", "vp"],
                departments: ["master_engineering"]
              }
            }
          ],
          destination_type: "webhook",
          destination_config: {
            webhook_url: "https://usewebhook.com/YOUR_WEBHOOK_ID",
            headers: {
              Authorization: "Bearer your-secret-token"
            }
          },
          max_records_per_trigger: 5,
          profile_id: 1
        })
      });

      const data = await response.json();
      console.log("Monitor created:", data.data.monitor_id);
      console.log("Signature:", data.data.signature);
      ```
    </CodeGroup>

    **功能说明：**

    * 监控 OpenAI（`domain_search_id: 67c4696b-...`）的美国新职位发布
    * 补充公司数据并查找最多5位总监/副总裁级别的工程联系人
    * 每次触发最多投递5条记录到你的 webhook
    * 所有其他设置使用合理的默认值（实时频率、每日500次上限等）

    <Note>
      在 `company_first` 模式中，你通常只需要 `companies`、`domains` 或 `linkedin_urls` 和信号筛选。`company_filters` 是可选的——当你希望将关注列表与更广泛的公司条件结合时，它会添加第二层筛选。
    </Note>

    ### 立即测试

    不要等待计划扫描——触发一次手动运行以验证一切正常。使用 `tried_at` 设置一个过去的时间戳以确保有可用数据（使用当前时间可能因尚未出现新信号而返回0条结果）：

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.pubrio.com/monitors/process/try \
        -H "Content-Type: application/json" \
        -H "pubrio-api-key: YOUR_API_KEY" \
        -d '{
          "monitor_id": "YOUR_MONITOR_ID",
          "tried_at": "2026-01-01T00:00:00.000Z",
          "profile_id": 1
        }'
      ```
    </CodeGroup>

    <Info>
      手动触发与计划触发一样消耗积分。使用 `tried_at` 设置近期的过去日期以获取具有代表性的测试结果。
    </Info>

    ### 检查结果

    几秒钟后，在 [usewebhook.com](https://usewebhook.com) 检查你的 webhook URL 以查看负载。你也可以通过日志验证：

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.pubrio.com/monitors/statistics/logs \
        -H "Content-Type: application/json" \
        -H "pubrio-api-key: YOUR_API_KEY" \
        -d '{
          "profile_id": 1,
          "monitor_id": "YOUR_MONITOR_ID",
          "page": 1,
          "per_page": 5
        }'
      ```
    </CodeGroup>

    每个日志条目显示状态、信号/公司/人员数量、积分用量和处理时间。
  </Tab>

  <Tab title="信号优先：发现 AI 招聘">
    ## 场景：发现正在招聘 AI/ML 岗位的公司

    你想找到正在积极组建 AI 团队的公司——无论你之前是否追踪过它们。这是一个潜客挖掘的使用场景。

    ### 创建 monitor

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.pubrio.com/monitors/create \
        -H "Content-Type: application/json" \
        -H "pubrio-api-key: YOUR_API_KEY" \
        -d '{
          "name": "AI Hiring Discovery",
          "detection_mode": "signal_first",
          "signal_types": ["jobs"],
          "signal_filters": [
            {
              "signal_type": "jobs",
              "filters": {
                "titles": ["Machine Learning", "AI Engineer", "Data Scientist"],
                "locations": ["US"]
              }
            }
          ],
          "company_filters": {
            "employees": [[201, 500], [501, 1000], [1001, 5000]]
          },
          "is_company_enrichment": true,
          "is_people_enrichment": true,
          "people_enrichment_configs": [
            {
              "max_people_to_return": 3,
              "people_contact_types": ["email-work"],
              "filters": {
                "management_levels": ["founder", "c_suite", "vp"]
              }
            }
          ],
          "destination_type": "webhook",
          "destination_config": {
            "webhook_url": "https://usewebhook.com/YOUR_WEBHOOK_ID",
            "body": {
              "pipeline": "ai-prospecting"
            }
          },
          "max_records_per_trigger": 10,
          "profile_id": 1
        }'
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "https://api.pubrio.com/monitors/create",
          headers={
              "Content-Type": "application/json",
              "pubrio-api-key": "YOUR_API_KEY"
          },
          json={
              "name": "AI Hiring Discovery",
              "detection_mode": "signal_first",
              "signal_types": ["jobs"],
              "signal_filters": [
                  {
                      "signal_type": "jobs",
                      "filters": {
                          "titles": ["Machine Learning", "AI Engineer", "Data Scientist"],
                          "locations": ["US"]
                      }
                  }
              ],
              "company_filters": {
                  "employees": [[201, 500], [501, 1000], [1001, 5000]]
              },
              "is_company_enrichment": True,
              "is_people_enrichment": True,
              "people_enrichment_configs": [
                  {
                      "max_people_to_return": 3,
                      "people_contact_types": ["email-work"],
                      "filters": {
                          "management_levels": ["founder", "c_suite", "vp"]
                      }
                  }
              ],
              "destination_type": "webhook",
              "destination_config": {
                  "webhook_url": "https://usewebhook.com/YOUR_WEBHOOK_ID",
                  "body": {
                      "pipeline": "ai-prospecting"
                  }
              },
              "max_records_per_trigger": 10,
              "profile_id": 1
          }
      )

      data = response.json()
      print(f"Monitor created: {data['data']['monitor_id']}")
      ```
    </CodeGroup>

    **功能说明：**

    * 扫描美国的 AI/ML 职位发布
    * **全局公司筛选**将结果缩小到中型公司（201-5,000名员工）——这就是将信号与公司条件结合的强大之处
    * 补充公司信息并查找最多3位创始人/C 级高管/副总裁联系人
    * 在负载中添加自定义 `pipeline` 字段用于在 webhook 处理程序中路由
    * 默认实时频率

    ### 立即测试

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.pubrio.com/monitors/process/try \
        -H "Content-Type: application/json" \
        -H "pubrio-api-key: YOUR_API_KEY" \
        -d '{
          "monitor_id": "YOUR_MONITOR_ID",
          "tried_at": "2026-01-01T00:00:00.000Z",
          "profile_id": 1
        }'
      ```
    </CodeGroup>

    <Info>
      手动触发消耗积分。使用 `tried_at` 设置近期的过去日期以获取具有代表性的测试数据——使用当前时间可能因该时刻未出现新信号而返回0条结果。
    </Info>

    ### 你将收到的内容

    检查 [usewebhook.com](https://usewebhook.com) — 你将看到以信号为主要结构的 `signal_first` 负载。注意根级别来自 `destination_config.body` 的自定义 `pipeline` 字段：

    ```json theme={null}
    {
      "monitor": { ... },
      "metadata": {
        "total_signals": 5,
        "total_companies": 4,
        "total_people": 10
      },
      "triggered_at": "2026-04-06T14:30:00.000Z",
      "signals": [
        {
          "signal_type": "jobs",
          "signal": { ... },
          "companies": [
            {
              "company_name": "...",
              "domain": "...",
              "company_size": 800,
              "people": [...],
              ...
            }
          ]
        },
        ...
      ],
      "pipeline": "ai-prospecting"
    }
    ```
  </Tab>
</Tabs>

***

## 重试失败的投递

如果某次触发失败了（例如你的 webhook 临时不可用），可以重试它而无需重新运行整个扫描：

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.pubrio.com/monitors/process/retry \
    -H "Content-Type: application/json" \
    -H "pubrio-api-key: YOUR_API_KEY" \
    -d '{
      "monitor_id": "YOUR_MONITOR_ID",
      "monitor_log_id": "THE_FAILED_LOG_ID",
      "profile_id": 1
    }'
  ```
</CodeGroup>

通过查询[统计日志](/cn/api-reference/endpoint/monitors/statistics_logs)并筛选 `"status": "failed"` 的条目来找到 `monitor_log_id`。

***

## 后续步骤

<CardGroup cols={2}>
  <Card title="最佳实践" icon="star" href="/cn/developer-guides/best-practices">
    频率、积分、重试和扩展。
  </Card>

  <Card title="Webhook 设置" icon="plug" href="/cn/developer-guides/setting-up-webhooks">
    详细的 webhook 配置和签名验证。
  </Card>
</CardGroup>
