# 调用API接口

<figure><img src="/files/7SErHqfsIY9kMFEOPi6e" alt=""><figcaption></figcaption></figure>

### 网址（URL）及方法&#x20;

选择请求方法并输入外部 API 的 URL 端点。 您可以通过将变量插入路径来使 URL 动态化。对于您在流程中设置的用户输入变量，例如，它名为“order\_num”，您可以使用 {{order\_num}} 来调用它。对于自定义字段，对于名为“membership”的字段，您可以将其命名为 {{customFields.membership}}。

### 自定义标题&#x20;

HTTP API 请求中的标题用于指定 API 的用途或其内容类型。是否使用标题是可选项目, 它位于“附加设置”下，默认情况下处于关闭状态。标题设置为一对：键+值。 例如 键=内容类型 值=应用程序

### 定制正文&#x20;

调用 API 请求的正文添加到此处。这也是可选的，默认设置为关闭。正文必须始终采用 JSON 格式。 格式提示：&#x20;

• 字符串和变量必须用引号括起来 > {{name}}&#x20;

• 2个键值对之间需要逗号 > "Email": "{{email}}", "Name": "{{name}}"&#x20;

• 变量是自定义字段而不是默认字段（即姓名、电子邮件、电话），例如字段名称是membership，则格式应为>“{{customFields.membership}}”

### 设置你的测试变量&#x20;

通过单击“添加变量”手动设置测试变量。

### 测试请求&#x20;

您可以通过单击“测试请求”按钮来测试 API 请求。

### 将回应保存为变量&#x20;

还可以将请求的回应保存到变量或自定义属性中。如果您的 API 回应是带有键值对的 JSON，您可以通过传递键名称来存储每个值。

#### 存储对象内部的回应值

如果要存储对象内的回应值，则需要使用 `objectkey.keyname` 格式。 例子：如果要存储 `userId`，则必须在上面的“整个回应正文”中使用 `Result.userId`

```
{ 
    "Result": { 
        "userId": "xxxxx", 
        "PhoneNumber": "xxxxxx", 
        "PurchaseHistory": null, 
    }
}

```

#### 存储对像数组内的回应值

如果要存储对像数组内的回应值，则需要使用 `[0].objectkey.keyname[0].value` 格式。&#x20;

例子：如果您想存储shipping\_status，则必须在上面的“整个回应正文”中使用 `[0].order_tracking.shipment_track[0].shipping_status`

```
[
    {
        "order_tracking": {
            "track_status":0,
            "shipment_track" : [
                {
                    "id":123342515,
                    "shipping_status":"On the way"
                }
            ]
        }
    }
]
```

### 回应路由&#x20;

您可以根据回应状态码，然后使用回应路由来拆分流程。默认情况下，每个 Webhook 块都有“成功”和“失败”节点。您可以根据需要选择添加自定义状态代码。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chatalog.ai/zh-cn/crm-quickstarts/customized-flow/diao-yong-api-jie-kou.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
