> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/chinese/guan-li-yu-she-zhi/workflow/cards-overview/then/action/call-api.md).

# 调用 API

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-4cc081844222e8928c69949b999b8c8eba0fad5c%2FThen_Call_API.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## 用途：

**“Call API”** 工作流卡片允许用户直接在工作流中向指定的 API 端点发送 HTTP 请求。此卡片支持多种 HTTP 方法，并可通过发送参数和数据与外部系统动态交互。它简化了与第三方服务和自定义 API 的集成，确保通信顺畅。

## 卡片组件：

1. **API 端点**
   * **说明：** 此卡片将与之交互的 **DocBits API** 目标端点。
   * **详情：** 一个文本字段，用户可在其中指定 API 请求的端点。
2. **HTTP 方法**
   * **说明：** 要发送的 HTTP 请求类型。
   * **选项：**
     1. **GET：** 从指定端点获取数据。
     2. **POST：** 向端点发送数据。
     3. **PUT：** 更新端点上的现有数据。
     4. **DELETE：** 删除端点上的数据。
3. **参数**
   * **说明：** 要包含在 API 请求中的查询参数。
   * **详情：** 一个文本字段或列表，用于输入请求 URL 的键值对。
4. **数据**
   1. **说明：** 要在 API 请求正文中发送的负载（适用于 POST 和 PUT 方法）。
   2. **详情：** 一个用于输入 JSON 格式数据的字段。

## 功能：

**条件评估：** 系统会评估“Where”和“And Sections”中定义的条件：

* 如果两个条件都为 **true**，则按配置执行 API 请求。
* 如果任一条件为 **false**，则不会执行此卡片，也不会发出 API 调用。

**API 请求执行：**

* 卡片使用所选方法向指定端点发送 HTTP 请求。
* 所提供的参数会附加到 URL 中，数据会包含在请求正文中（如适用）。

## 设置和配置：

1. **定义 API 端点：**\
   输入要调用的 API 的 URL。
2. **选择 HTTP 方法：**\
   根据 API 的要求，选择一种受支持的方法（GET、POST、PUT、DELETE）。
3. **提供参数：**\
   以键值对形式添加所需的查询参数。
4. **包含数据（如适用）：**\
   对于 POST 或 PUT 方法，指定要在请求正文中发送的数据。
5. **配置条件：**\
   配置“Where”和“And Sections”，以定义何时应发出 API 调用。

## 结论：

**“Call API”** 工作流卡片通过支持与外部系统直接交互，增强了工作流自动化。借助灵活的端点、方法和数据配置，工作流可以顺畅地集成第三方 API 或自定义后端。按条件执行 API 调用的能力可确保外部通信自动化的精准性和效率。

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.docbits.com/chinese/guan-li-yu-she-zhi/workflow/cards-overview/then/action/call-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
