{
  "openapi": "3.1.0",
  "info": {
    "title": "Nexora Signal API",
    "version": "1.0.0",
    "description": "Private beta IT incident analysis. Default live access requires a workspace key. Optional Monetization Gateway access uses an eligible account and an x402-compatible client; PAYMENT-CONTEXT is supplied by the Gateway, not created by clients."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "summary": "Check application health",
        "responses": {
          "200": {
            "description": "Health and configuration status"
          }
        }
      }
    },
    "/api/status": {
      "get": {
        "summary": "Read workspace configuration status",
        "responses": {
          "200": {
            "description": "Mode, input limits and available sample IDs"
          }
        }
      }
    },
    "/api/examples": {
      "get": {
        "summary": "Read a prepared example; does not invoke AI",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "dns",
                "service",
                "web"
              ],
              "default": "dns"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Prepared incident and report, with mode=example"
          },
          "404": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/usage": {
      "get": {
        "summary": "Read the workspace daily attempt count",
        "security": [
          {
            "WorkspaceKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "UTC day, used attempts and limit"
          },
          "401": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/analyze-incident": {
      "post": {
        "summary": "Analyze one incident",
        "description": "Private mode requires WorkspaceKey. In Gateway mode, call the protected public endpoint with an x402 client. The edge may respond 402 before forwarding a verified request to the origin. Input text is treated as untrusted data; no diagnostic commands are executed.",
        "security": [
          {
            "WorkspaceKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Incident"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A validated analysis, labelled as live output.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "mode",
                    "incident",
                    "analysis",
                    "meta"
                  ],
                  "properties": {
                    "mode": {
                      "type": "string",
                      "enum": [
                        "live"
                      ]
                    },
                    "incident": {
                      "type": "object"
                    },
                    "analysis": {
                      "$ref": "#/components/schemas/Analysis"
                    },
                    "meta": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Payment requirements returned by an enabled Monetization Gateway rule."
          },
          "403": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "WorkspaceKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Private workspace access key; the app and the Gateway mode are configured separately."
      }
    },
    "schemas": {
      "Incident": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "system",
          "log"
        ],
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 120,
            "default": "Untitled incident"
          },
          "system": {
            "type": "string",
            "enum": [
              "Windows",
              "Linux",
              "Network / DNS",
              "Web application",
              "Database",
              "Other"
            ]
          },
          "impact": {
            "type": "string",
            "enum": [
              "Unknown",
              "One user",
              "Several users",
              "Service unavailable"
            ],
            "default": "Unknown"
          },
          "log": {
            "type": "string",
            "minLength": 15,
            "maxLength": 8000
          },
          "context": {
            "type": "string",
            "maxLength": 2000
          }
        }
      },
      "Analysis": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "summary": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1200
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "unknown"
            ]
          },
          "possible_causes": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "title": {
                  "type": "string",
                  "maxLength": 120
                },
                "reasoning": {
                  "type": "string",
                  "maxLength": 600
                }
              },
              "required": [
                "title",
                "reasoning"
              ]
            }
          },
          "diagnostic_checks": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "action": {
                  "type": "string",
                  "maxLength": 500
                },
                "look_for": {
                  "type": "string",
                  "maxLength": 500
                }
              },
              "required": [
                "action",
                "look_for"
              ]
            }
          },
          "missing_information": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "type": "string",
              "maxLength": 300
            }
          },
          "escalation": {
            "type": "string",
            "maxLength": 600
          }
        },
        "required": [
          "summary",
          "priority",
          "possible_causes",
          "diagnostic_checks",
          "missing_information",
          "escalation"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
