# 設置調用API接口

<figure><img src="/files/tm0iE1FUflgiqUyaMjOG" 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` 格式。

例子：如果您想存儲shipping\_status，則必須在上面的“整個回應正文”中使用 `[0].order_tracking.shipment_track[0].shipping_status`

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

```

### 回應路由

您可以根據回應狀態碼，然後使用回應路由來拆分流程。默認情況下，每個 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-hk/crm-quickstarts/customized-flow/setting-up-call-api-block-in-flow.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.
