{
  "openapi": "3.1.0",
  "info": {
    "title": "Dezz Developer API",
    "version": "2026.11",
    "description": "Endpoints públicos e autenticados pelo usuário do Dezz. Todas as chamadas autenticadas usam o token OAuth do próprio usuário; RLS e controle parental continuam aplicados."
  },
  "servers": [
    {
      "url": "https://mxdobpemzwlsqlesyhvh.supabase.co"
    }
  ],
  "components": {
    "securitySchemes": {
      "apikey": {
        "type": "apiKey",
        "in": "header",
        "name": "apikey"
      },
      "userToken": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "FeatureRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "platform": {
            "type": "string"
          },
          "audience": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "under_review",
              "planned",
              "in_progress",
              "shipped",
              "declined",
              "duplicate"
            ]
          },
          "team_note": {
            "type": [
              "string",
              "null"
            ]
          },
          "vote_count": {
            "type": "integer"
          },
          "has_voted": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "relevance": {
            "type": "number"
          }
        }
      }
    }
  },
  "security": [
    {
      "apikey": []
    }
  ],
  "paths": {
    "/rest/v1/rpc/search_feature_requests": {
      "post": {
        "summary": "Buscar pedidos de recurso por palavras-chave",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "p_query": {
                    "type": "string"
                  },
                  "p_limit": {
                    "type": "integer",
                    "maximum": 50
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lista",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FeatureRequest"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rest/v1/rpc/submit_feature_request": {
      "post": {
        "summary": "Criar pedido de recurso (5/24h)",
        "security": [
          {
            "apikey": [],
            "userToken": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "p_title"
                ],
                "properties": {
                  "p_title": {
                    "type": "string",
                    "minLength": 4,
                    "maxLength": 120
                  },
                  "p_description": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "p_platform": {
                    "type": "string",
                    "enum": [
                      "all",
                      "iphone",
                      "ipad",
                      "mac",
                      "watch",
                      "web",
                      "android",
                      "developers"
                    ]
                  },
                  "p_audience": {
                    "type": "string",
                    "enum": [
                      "all",
                      "student",
                      "teacher",
                      "parent",
                      "developer"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "UUID do pedido"
          },
          "401": {
            "description": "Login necessário"
          }
        }
      }
    },
    "/rest/v1/rpc/toggle_feature_request_vote": {
      "post": {
        "summary": "Votar ou remover voto",
        "security": [
          {
            "apikey": [],
            "userToken": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "p_request_id"
                ],
                "properties": {
                  "p_request_id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "[{has_voted, vote_count}]"
          }
        }
      }
    },
    "/functions/v1/dezz-plugin-submissions": {
      "post": {
        "summary": "Enviar ou listar propostas de plugin",
        "security": [
          {
            "apikey": [],
            "userToken": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "submit",
                      "list"
                    ]
                  },
                  "slug": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9-]{1,62}$"
                  },
                  "name": {
                    "type": "string"
                  },
                  "summary": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 240
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "study",
                      "creation",
                      "organization",
                      "accessibility",
                      "ai"
                    ]
                  },
                  "sourceURL": {
                    "type": "string",
                    "format": "uri"
                  },
                  "capabilities": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "design.create.blank",
                        "documents.import.selected",
                        "study.generate.flashcards",
                        "study.generate.quiz",
                        "study.explain.topic",
                        "accessibility.read.aloud"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Proposta criada"
          },
          "200": {
            "description": "Lista de propostas"
          },
          "409": {
            "description": "Duplicada"
          },
          "429": {
            "description": "Limite"
          }
        }
      }
    },
    "/functions/v1/public-app-config": {
      "get": {
        "summary": "Configuração pública do app",
        "responses": {
          "200": {
            "description": "JSON"
          }
        }
      }
    }
  }
}