{
  "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"
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      }
    }
  },
  "paths": {
    "/executions/{executionId}": {
      "get": {
        "operationId": "getExecution",
        "tags": [
          "Executions"
        ],
        "summary": "获取执行记录",
        "description": "获取实例中的某条执行记录。",
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "required": true,
            "description": "执行的 ID。",
            "name": "executionId",
            "in": "path"
          },
          {
            "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"
          }
        ],
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "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"
                      ]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "startedAt": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time",
                      "description": "执行离开队列并开始运行之前为 Null。"
                    },
                    "stoppedAt": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time",
                      "description": "执行停止的时间。状态为 `new`、`running` 或 `unknown` 时为 Null；`waiting` 状态的执行已停止当前这轮运行，因此有此时间值。"
                    },
                    "deletedAt": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time",
                      "description": "始终为 null，不会返回已软删除的执行记录。"
                    },
                    "workflowId": {
                      "type": "string"
                    },
                    "waitTill": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time",
                      "description": "等待中的执行恢复运行的时间。"
                    },
                    "storedAt": {
                      "type": "string",
                      "description": "执行数据的存储位置。",
                      "enum": [
                        "db",
                        "fs",
                        "s3",
                        "az"
                      ]
                    },
                    "tracingContext": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "traceparent": {
                          "type": "string"
                        },
                        "tracestate": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "traceparent"
                      ],
                      "description": "随执行传递的 W3C 跟踪上下文。"
                    },
                    "deduplicationKey": {
                      "type": "string",
                      "nullable": true,
                      "description": "用于防止创建重复执行的键。"
                    },
                    "jsonSizeBytes": {
                      "type": "number",
                      "description": "已存储执行数据的大小，单位为字节；0 表示未知。"
                    },
                    "binaryDataSizeBytes": {
                      "type": "number",
                      "description": "已存储二进制数据的大小，单位为字节；0 表示未知。"
                    },
                    "workflowVersionId": {
                      "type": "string",
                      "nullable": true,
                      "description": "此执行所运行的工作流版本 ID。"
                    },
                    "usedPrivateCredentials": {
                      "type": "boolean",
                      "description": "执行是否使用了未与项目共享的凭据。"
                    },
                    "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": "当前用户是否有权显示被遮蔽的原始数据。"
                            }
                          }
                        }
                      }
                    },
                    "customData": {
                      "type": "object",
                      "description": "由工作流设置的执行元数据，仅当 `includeData` 为 `true` 时包含。",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "workflowData": {
                      "type": "object",
                      "description": "执行运行时保存的工作流。仅当 `includeData` 为 `true` 时包含。较早执行记录携带的字段比新执行记录更多。",
                      "additionalProperties": true
                    },
                    "dataTooLargeToDisplay": {
                      "type": "boolean",
                      "description": "执行数据超过 `EXECUTIONS_DATA_MAX_DISPLAY_SIZE` 时返回，值为 true。此时 `data` 为空，`jsonSizeBytes` 保存实际大小。仍需读取数据时，使用 `ignoreDataSizeLimit`。"
                    }
                  },
                  "required": [
                    "id",
                    "finished",
                    "mode",
                    "retryOf",
                    "retrySuccessId",
                    "status",
                    "createdAt",
                    "startedAt",
                    "stoppedAt",
                    "deletedAt",
                    "workflowId",
                    "waitTill",
                    "storedAt",
                    "tracingContext",
                    "deduplicationKey",
                    "jsonSizeBytes",
                    "binaryDataSizeBytes",
                    "workflowVersionId",
                    "usedPrivateCredentials"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          }
        }
      }
    }
  }
}
