{
  "openapi": "3.1.0",
  "info": {
    "title": "IKAI Enterprise API",
    "version": "1.0.0",
    "description": "API-key REST access to IKAI Actions. Use MCP for agent tool orchestration and this REST API for enterprise automation. Money-moving workflows stay inside IKAI/MCP with explicit human confirmation.",
    "termsOfService": "https://ikai.world/terms",
    "contact": {
      "name": "IKAI",
      "email": "hello@ikai.world",
      "url": "https://ikai.world/developers"
    }
  },
  "servers": [
    {
      "url": "https://hnyxyistlgtyxzaqoyvc.supabase.co/functions/v1/enterprise-api",
      "description": "IKAI Supabase Edge Function REST endpoint"
    }
  ],
  "security": [
    {
      "BearerApiKey": []
    }
  ],
  "tags": [
    {
      "name": "Actions",
      "description": "Create and inspect IKAI Actions for enterprise workflows."
    }
  ],
  "paths": {
    "/actions": {
      "get": {
        "tags": [
          "Actions"
        ],
        "summary": "List Actions visible to the API key owner",
        "operationId": "listActions",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "open",
                "in_progress",
                "submitted",
                "completed",
                "cancelled"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Action list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "actions"
                  ],
                  "properties": {
                    "actions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Action"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/actions/{action_id}": {
      "get": {
        "tags": [
          "Actions"
        ],
        "summary": "Get one Action",
        "operationId": "getAction",
        "parameters": [
          {
            "name": "action_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Action detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "action"
                  ],
                  "properties": {
                    "action": {
                      "$ref": "#/components/schemas/Action"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/actions/bulk": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "Bulk-create draft Actions",
        "operationId": "bulkCreateDraftActions",
        "description": "Creates draft Actions only. Funding, launch, booking, approvals, refunds, and payouts remain separate IKAI flows with human confirmation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "actions"
                ],
                "properties": {
                  "actions": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "$ref": "#/components/schemas/DraftActionInput"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Draft Actions created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "created"
                  ],
                  "properties": {
                    "created": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Action"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "API key lacks write permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "IKAI API key",
        "description": "Use Authorization: Bearer ik_..."
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid API key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found or not visible to the API key owner",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Action": {
        "type": "object",
        "required": [
          "id",
          "title",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "reward_cents": {
            "type": "integer",
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "default": "USD"
          },
          "spots": {
            "type": "integer",
            "minimum": 1
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DraftActionInput": {
        "type": "object",
        "required": [
          "title",
          "description"
        ],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 160
          },
          "description": {
            "type": "string",
            "minLength": 10
          },
          "category": {
            "type": "string"
          },
          "reward_cents": {
            "type": "integer",
            "minimum": 0
          },
          "spots": {
            "type": "integer",
            "minimum": 1,
            "default": 1
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    }
  },
  "x-ikai": {
    "mcp_discovery": "https://ikai.world/.well-known/mcp.json",
    "agent_manifest": "https://ikai.world/.well-known/ikai-agent.json",
    "human_confirmation_required_for": [
      "funding",
      "booking",
      "approving",
      "rejecting",
      "cancelling",
      "refunds",
      "payouts"
    ]
  }
}
