{
  "openapi": "3.0.3",
  "info": {
    "title": "IOBend Web API",
    "description": "Developer platform API for project config synchronizations, secrets envelope storage, organization memberships, webhooks dispatch, and tool diagnostics.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/api/v1",
      "description": "Production V1 REST API Gateway"
    }
  ],
  "paths": {
    "/projects": {
      "get": {
        "summary": "List Cloud Workspace Projects",
        "description": "Returns a list of all active projects in the current workspace authenticated by the caller.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved projects list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "projects": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Project"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "post": {
        "summary": "Create Project",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name", "projectType"],
                "properties": {
                  "name": { "type": "string" },
                  "projectType": { "type": "string", "enum": ["node", "python", "go", "rust", "generic"] },
                  "environment": { "type": "string" },
                  "description": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Project created successfully"
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/cli/secrets": {
      "get": {
        "summary": "Retrieve Project Secrets",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "projectId",
            "in": "query",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Secrets list returned"
          }
        }
      },
      "post": {
        "summary": "Upsert Secret",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["projectId", "key"],
                "properties": {
                  "projectId": { "type": "string" },
                  "key": { "type": "string" },
                  "value": { "type": "string" },
                  "ciphertext": { "type": "string" },
                  "iv": { "type": "string" },
                  "tag": { "type": "string" },
                  "environment": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Secret saved" }
        }
      }
    },
    "/cli/secrets/rotate": {
      "post": {
        "summary": "Rotate Secret Value",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["projectId", "key"],
                "properties": {
                  "projectId": { "type": "string" },
                  "key": { "type": "string" },
                  "environment": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Secret rotated successfully"
          }
        }
      }
    },
    "/cli/sync": {
      "post": {
        "summary": "Sync Project Workspace Configuration",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["projectId", "name"],
                "properties": {
                  "projectId": { "type": "string" },
                  "name": { "type": "string" },
                  "secrets": { "type": "array", "items": { "type": "object" } },
                  "assets": { "type": "array", "items": { "type": "object" } },
                  "dependencies": { "type": "array", "items": { "type": "object" } }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Synchronization complete, webhooks dispatched"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Enter your IOBend developer API key"
      }
    },
    "schemas": {
      "Project": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "projectType": { "type": "string" },
          "environment": { "type": "string" },
          "description": { "type": "string" }
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid Bearer API Key",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": { "type": "string" }
              }
            }
          }
        }
      }
    }
  }
}
