{
  "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": {
      "idempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "description": "此 POST 请求的安全重试键。使用 1 到 128 个可见 ASCII 字符。相同的键配合相同的请求，会返回首次成功的响应。使用此键发送不同请求时返回 422。首次请求仍在处理时重试，会返回 409。",
        "required": false,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[\\x21-\\x7E]+$"
        }
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      },
      "conflict": {
        "description": "冲突"
      },
      "unsupportedMediaType": {
        "description": "不支持的媒体类型。"
      },
      "unprocessableEntity": {
        "description": "无法处理的实体"
      }
    }
  },
  "paths": {
    "/executions/{executionId}/retry": {
      "post": {
        "operationId": "retryExecution",
        "tags": [
          "Executions"
        ],
        "summary": "重试执行",
        "description": "重试实例中的某次执行。",
        "parameters": [
          {
            "$ref": "#/components/parameters/idempotencyKey"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "required": true,
            "description": "执行的 ID。",
            "name": "executionId",
            "in": "path"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "loadWorkflow": {
                    "type": "boolean",
                    "description": "是否加载当前保存的工作流执行，而非使用原执行运行时保存的工作流。设为 true 时，将使用工作流最新版本进行重试。"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "重试所启动的新执行 ID。"
                    },
                    "mode": {
                      "type": "string",
                      "enum": [
                        "cli",
                        "error",
                        "integrated",
                        "internal",
                        "manual",
                        "retry",
                        "trigger",
                        "webhook",
                        "evaluation",
                        "chat",
                        "agent"
                      ]
                    },
                    "startedAt": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time",
                      "description": "新执行开始的时间。"
                    },
                    "workflowId": {
                      "type": "string"
                    },
                    "finished": {
                      "type": "boolean",
                      "description": "执行是否已运行完成。请改用 `status`。",
                      "deprecated": true
                    },
                    "retryOf": {
                      "type": "string",
                      "nullable": true,
                      "description": "此执行所重试的原执行 ID。"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "canceled",
                        "crashed",
                        "error",
                        "new",
                        "running",
                        "success",
                        "unknown",
                        "waiting"
                      ]
                    },
                    "waitTill": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time",
                      "description": "等待中的执行恢复运行的时间。"
                    },
                    "data": {
                      "type": "object",
                      "description": "新执行的运行数据。API 密钥所属用户无权读取此工作流的执行记录时不返回。",
                      "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": "原执行运行时保存的工作流。`loadWorkflow` 改变重试所运行的工作流，不改变此字段返回的内容。API 密钥所属用户无权读取此工作流的执行记录时不返回。",
                      "additionalProperties": true
                    },
                    "customData": {
                      "type": "object",
                      "description": "从原执行继承的执行元数据。API 密钥所属用户无权读取此工作流的执行记录时不返回。",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "annotation": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "number"
                        },
                        "vote": {
                          "type": "string",
                          "nullable": true,
                          "description": "原执行上的投票。",
                          "enum": [
                            "up",
                            "down"
                          ]
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "name"
                            ]
                          }
                        }
                      },
                      "required": [
                        "id",
                        "vote",
                        "tags"
                      ],
                      "description": "原执行上的注释。原执行没有注释，或 API 密钥所属用户无权读取此工作流的执行记录时不返回。"
                    },
                    "storedAt": {
                      "type": "string",
                      "description": "执行数据的存储位置。",
                      "enum": [
                        "db",
                        "fs",
                        "s3",
                        "az"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "mode",
                    "startedAt",
                    "workflowId",
                    "finished",
                    "retryOf",
                    "status",
                    "storedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          },
          "409": {
            "$ref": "#/components/responses/conflict"
          },
          "415": {
            "$ref": "#/components/responses/unsupportedMediaType"
          },
          "422": {
            "$ref": "#/components/responses/unprocessableEntity"
          }
        }
      }
    }
  }
}
