{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "Executions",
      "description": "执行记录相关操作"
    }
  ],
  "servers": [
    {
      "url": "/api/v1",
      "description": "当前 n8n 实例（自托管版本的内置测试台）"
    },
    {
      "url": "{url}/api/v1",
      "description": "自托管 n8n 实例",
      "variables": {
        "url": {
          "default": "https://example.com"
        }
      }
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "BearerAuth": []
    },
    {
      "CookieAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-N8N-API-KEY"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "CookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "n8n-auth"
      }
    },
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "description": "最多返回的数据项数量。",
        "required": false,
        "schema": {
          "type": "number",
          "default": 100,
          "maximum": 250
        }
      },
      "cursor": {
        "name": "cursor",
        "in": "query",
        "description": "将 cursor 参数设为上次请求响应中的 nextCursor 属性，以进行分页。使用默认值时，获取集合的第一页。更多信息，请参阅分页说明。",
        "required": false,
        "style": "form",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      }
    }
  },
  "paths": {
    "/executions": {
      "get": {
        "operationId": "getExecutions",
        "tags": [
          "Executions"
        ],
        "summary": "获取所有执行记录",
        "description": "获取实例中的所有执行记录。",
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false",
              "description": "是否包含执行的详细数据。"
            },
            "required": false,
            "name": "includeData",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "default": "false",
              "description": "即使执行数据超过配置的大小限制（EXECUTIONS_DATA_MAX_DISPLAY_SIZE），是否仍返回完整数据。否则，超出大小限制的执行记录将不包含其数据。"
            },
            "required": false,
            "name": "ignoreDataSizeLimit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ],
              "description": "控制执行数据遮蔽。为 `true` 时，始终遮蔽执行输出数据；为 `false` 时，请求未遮蔽的数据（显示原始数据），需要 `execution:reveal` 作用域。省略时遵循工作流的遮蔽策略。"
            },
            "required": false,
            "name": "redactExecutionData",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "canceled",
                "crashed",
                "error",
                "new",
                "running",
                "success",
                "unknown",
                "waiting"
              ],
              "description": "用于筛选执行记录的状态。"
            },
            "required": false,
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "用于筛选执行记录的工作流。"
            },
            "required": false,
            "name": "workflowId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "name": "projectId",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "仅返回在此时间之后开始的执行。"
            },
            "required": false,
            "name": "startedAfter",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "仅返回在此时间之前开始的执行。"
            },
            "required": false,
            "name": "startedBefore",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "finished": {
                            "type": "boolean",
                            "description": "执行是否已运行完成。请改用 `status`。",
                            "deprecated": true
                          },
                          "mode": {
                            "type": "string",
                            "enum": [
                              "cli",
                              "error",
                              "integrated",
                              "internal",
                              "manual",
                              "retry",
                              "trigger",
                              "webhook",
                              "evaluation",
                              "chat",
                              "agent"
                            ]
                          },
                          "retryOf": {
                            "type": "string",
                            "nullable": true,
                            "description": "此执行所重试的原执行 ID。"
                          },
                          "retrySuccessId": {
                            "type": "string",
                            "nullable": true,
                            "description": "如果此执行失败，但某次重试成功，则为该成功重试的 ID。"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "canceled",
                              "crashed",
                              "error",
                              "new",
                              "running",
                              "success",
                              "unknown",
                              "waiting"
                            ]
                          },
                          "startedAt": {
                            "type": "string",
                            "nullable": true,
                            "format": "date-time",
                            "description": "执行离开队列并开始运行之前为 Null。"
                          },
                          "stoppedAt": {
                            "type": "string",
                            "nullable": true,
                            "format": "date-time",
                            "description": "执行停止的时间。状态为 `new`、`running` 或 `unknown` 时为 Null；`waiting` 状态的执行已停止当前这轮运行，因此有此时间值。"
                          },
                          "workflowId": {
                            "type": "string"
                          },
                          "waitTill": {
                            "type": "string",
                            "nullable": true,
                            "format": "date-time",
                            "description": "等待中的执行恢复运行的时间。"
                          },
                          "storedAt": {
                            "type": "string",
                            "description": "执行数据的存储位置。",
                            "enum": [
                              "db",
                              "fs",
                              "s3",
                              "az"
                            ]
                          },
                          "jsonSizeBytes": {
                            "type": "number",
                            "description": "已存储执行数据的大小，单位为字节；0 表示未知。"
                          },
                          "workflowVersionId": {
                            "type": "string",
                            "nullable": true,
                            "description": "此执行所运行的工作流版本 ID。"
                          },
                          "data": {
                            "type": "object",
                            "description": "详细执行数据，仅当 `includeData` 为 `true` 时包含。",
                            "additionalProperties": true,
                            "properties": {
                              "redactionInfo": {
                                "type": "object",
                                "nullable": true,
                                "description": "执行数据已被遮蔽时返回。",
                                "properties": {
                                  "isRedacted": {
                                    "type": "boolean",
                                    "description": "执行数据是否被遮蔽。"
                                  },
                                  "reason": {
                                    "type": "string",
                                    "description": "遮蔽原因。"
                                  },
                                  "canReveal": {
                                    "type": "boolean",
                                    "description": "当前用户是否有权显示被遮蔽的原始数据。"
                                  }
                                }
                              }
                            }
                          },
                          "workflowData": {
                            "type": "object",
                            "description": "执行运行时保存的工作流。仅当 `includeData` 为 `true` 时包含。较早执行记录携带的字段比新执行记录更多。",
                            "additionalProperties": true
                          },
                          "customData": {
                            "type": "object",
                            "description": "由工作流设置的执行元数据，仅当 `includeData` 为 `true` 时包含。",
                            "additionalProperties": {
                              "type": "string"
                            }
                          },
                          "dataTooLargeToDisplay": {
                            "type": "boolean",
                            "description": "执行数据超过 `EXECUTIONS_DATA_MAX_DISPLAY_SIZE` 时返回，值为 true。此时 `data` 为空，`jsonSizeBytes` 保存实际大小。仍需读取数据时，使用 `ignoreDataSizeLimit`。"
                          }
                        },
                        "required": [
                          "id",
                          "finished",
                          "mode",
                          "retryOf",
                          "retrySuccessId",
                          "status",
                          "startedAt",
                          "stoppedAt",
                          "workflowId",
                          "waitTill"
                        ]
                      }
                    },
                    "nextCursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "将 cursor 参数设为先前请求返回的 nextCursor 属性，以对执行记录进行分页。使用默认值时，获取集合的第一页。"
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          }
        }
      }
    }
  }
}
