{
  "openapi": "3.1.0",
  "info": {
    "title": "UXTap API de leitura",
    "version": "1.0.0",
    "description": "Chaves criadas em Configurações → API para integrações. Não envie a chave em URLs nem em código executado no navegador. Resultados agregados não incluem textos de respostas; sessões exigem read:sessions. APIs de escrita não fazem parte da v1. Organizações com SSO obrigatório recusam autenticação por chave de API."
  },
  "servers": [
    {
      "url": "https://uxtap.app/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/studies": {
      "get": {
        "operationId": "studies",
        "summary": "Listar estudos",
        "description": "Exige o escopo read:studies. A chave respeita a participação e permissões atuais de quem a criou. ",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Cursor opaco e assinado da resposta anterior; vinculado à chave."
          }
        ],
        "responses": {
          "200": {
            "description": "Leitura autorizada. Cada requisição autenticada consome o limite diário da chave.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "itens": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Study"
                      }
                    },
                    "proximoCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "itens",
                    "proximoCursor"
                  ]
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "400": {
            "description": "Parâmetros ou cursor inválidos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "401": {
            "description": "Chave ausente, inválida, expirada ou revogada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo insuficiente ou operação não autorizada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "404": {
            "description": "Estudo inexistente ou inacessível.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "429": {
            "description": "Limite diário ou de rajada atingido; respeite Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              },
              "retry-after": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos para aguardar antes da próxima tentativa."
              }
            }
          }
        }
      }
    },
    "/studies/{id}": {
      "get": {
        "operationId": "studies_studyId",
        "summary": "Detalhar estudo",
        "description": "Exige o escopo read:studies. A chave respeita a participação e permissões atuais de quem a criou. ",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID do estudo acessível ao emissor da chave."
          }
        ],
        "responses": {
          "200": {
            "description": "Leitura autorizada. Cada requisição autenticada consome o limite diário da chave.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Study"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "versoes": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Version"
                          }
                        }
                      }
                    }
                  ]
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "400": {
            "description": "Parâmetros ou cursor inválidos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "401": {
            "description": "Chave ausente, inválida, expirada ou revogada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo insuficiente ou operação não autorizada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "404": {
            "description": "Estudo inexistente ou inacessível.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "429": {
            "description": "Limite diário ou de rajada atingido; respeite Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              },
              "retry-after": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos para aguardar antes da próxima tentativa."
              }
            }
          }
        }
      }
    },
    "/studies/{id}/results": {
      "get": {
        "operationId": "studies_studyId_results",
        "summary": "Ler resultados agregados",
        "description": "Exige o escopo read:results. A chave respeita a participação e permissões atuais de quem a criou. Filtros adicionais de painel: painel.<variável>=valor. ",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID do estudo acessível ao emissor da chave."
          },
          {
            "name": "versao",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "dispositivo",
            "in": "query",
            "schema": {
              "enum": [
                "todos",
                "desktop",
                "celular",
                "tablet"
              ]
            }
          },
          {
            "name": "desfecho",
            "in": "query",
            "schema": {
              "enum": [
                "todas",
                "concluidas",
                "abandonadas",
                "desqualificadas"
              ]
            }
          },
          {
            "name": "parciais",
            "in": "query",
            "schema": {
              "enum": [
                "1",
                "0"
              ]
            },
            "description": "1 inclui respostas parciais."
          }
        ],
        "responses": {
          "200": {
            "description": "Leitura autorizada. Cada requisição autenticada consome o limite diário da chave.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Results"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "400": {
            "description": "Parâmetros ou cursor inválidos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "401": {
            "description": "Chave ausente, inválida, expirada ou revogada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo insuficiente ou operação não autorizada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "404": {
            "description": "Estudo inexistente ou inacessível.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "429": {
            "description": "Limite diário ou de rajada atingido; respeite Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              },
              "retry-after": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos para aguardar antes da próxima tentativa."
              }
            }
          }
        }
      }
    },
    "/studies/{id}/sessions": {
      "get": {
        "operationId": "studies_studyId_sessions",
        "summary": "Ler respostas por sessão",
        "description": "Exige o escopo read:sessions. A chave respeita a participação e permissões atuais de quem a criou. Filtros adicionais de painel: painel.<variável>=valor. ",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID do estudo acessível ao emissor da chave."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Cursor opaco e assinado da resposta anterior; vinculado à chave."
          },
          {
            "name": "versao",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "dispositivo",
            "in": "query",
            "schema": {
              "enum": [
                "todos",
                "desktop",
                "celular",
                "tablet"
              ]
            }
          },
          {
            "name": "desfecho",
            "in": "query",
            "schema": {
              "enum": [
                "todas",
                "concluidas",
                "abandonadas",
                "desqualificadas"
              ]
            }
          },
          {
            "name": "parciais",
            "in": "query",
            "schema": {
              "enum": [
                "1",
                "0"
              ]
            },
            "description": "1 inclui respostas parciais."
          }
        ],
        "responses": {
          "200": {
            "description": "Leitura autorizada. Cada requisição autenticada consome o limite diário da chave.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "itens": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Session"
                          }
                        },
                        "proximoCursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "itens",
                        "proximoCursor"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "estudoId": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "400": {
            "description": "Parâmetros ou cursor inválidos.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "401": {
            "description": "Chave ausente, inválida, expirada ou revogada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Escopo insuficiente ou operação não autorizada.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "404": {
            "description": "Estudo inexistente ou inacessível.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              }
            }
          },
          "429": {
            "description": "Limite diário ou de rajada atingido; respeite Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "x-ratelimit-limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Teto diário por chave."
              },
              "x-ratelimit-remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requisições restantes hoje."
              },
              "x-ratelimit-reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos até meia-noite UTC."
              },
              "retry-after": {
                "schema": {
                  "type": "integer"
                },
                "description": "Segundos para aguardar antes da próxima tentativa."
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Chave uxtap_…; exibida uma única vez ao criar."
      }
    },
    "schemas": {
      "Version": {
        "type": "object",
        "properties": {
          "numero": {
            "type": "integer"
          },
          "publicadaEm": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "numero",
          "publicadaEm"
        ]
      },
      "Study": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "nome": {
            "type": "string"
          },
          "status": {
            "enum": [
              "draft",
              "live",
              "closed"
            ]
          },
          "tipo": {
            "type": "string"
          },
          "idioma": {
            "type": "string"
          },
          "pastaId": {
            "type": [
              "string",
              "null"
            ]
          },
          "versaoPublicada": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Version"
              },
              {
                "type": "null"
              }
            ]
          },
          "respostas": {
            "type": "integer"
          },
          "criadoEm": {
            "type": "string",
            "format": "date-time"
          },
          "atualizadoEm": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "nome",
          "status",
          "tipo",
          "idioma",
          "respostas",
          "criadoEm",
          "atualizadoEm"
        ]
      },
      "Session": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "cotaCheia": {
            "type": "boolean"
          },
          "veladaPorCota": {
            "type": "boolean"
          },
          "naDistribuicao": {
            "type": "boolean"
          },
          "iniciadaEm": {
            "type": "string",
            "format": "date-time"
          },
          "terminadaEm": {
            "type": [
              "string",
              "null"
            ]
          },
          "dispositivo": {
            "type": [
              "string",
              "null"
            ]
          },
          "idioma": {
            "type": [
              "string",
              "null"
            ]
          },
          "variaveisPainel": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "origem": {
            "type": "object",
            "properties": {
              "tipo": {
                "type": "string"
              },
              "canalId": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "canalNome": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "respostas": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "localId": {
                  "type": "string"
                },
                "pergunta": {
                  "type": "string"
                },
                "tipo": {
                  "type": "string"
                },
                "texto": {
                  "type": "string"
                },
                "recusou": {
                  "type": "boolean"
                },
                "followUp": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "pergunta": {
                          "type": "string"
                        },
                        "resposta": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          }
        },
        "required": [
          "id",
          "status",
          "veladaPorCota",
          "respostas"
        ]
      },
      "Results": {
        "type": "object",
        "properties": {
          "estudoId": {
            "type": "string"
          },
          "filtros": {
            "type": "object",
            "properties": {
              "versao": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "dispositivo": {
                "type": "string"
              },
              "desfecho": {
                "type": "string"
              },
              "parciais": {
                "type": "boolean"
              }
            }
          },
          "kpis": {
            "type": "object",
            "properties": {
              "respostas": {
                "type": "integer"
              },
              "concluidas": {
                "type": "integer"
              },
              "desqualificadas": {
                "type": "integer"
              },
              "abandonadas": {
                "type": "integer"
              },
              "taxaConclusao": {
                "type": "number"
              }
            }
          },
          "cotaPlano": {
            "type": "object",
            "properties": {
              "limite": {
                "type": "integer"
              },
              "usado": {
                "type": "integer"
              },
              "excedente": {
                "type": "integer"
              }
            }
          },
          "cotasEstudo": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "metricas": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "blocos": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "localId": {
                  "type": "string"
                },
                "tipo": {
                  "type": "string"
                },
                "pergunta": {
                  "type": "string"
                },
                "total": {
                  "type": "integer"
                }
              },
              "required": [
                "localId",
                "tipo",
                "pergunta",
                "total"
              ]
            }
          }
        },
        "required": [
          "estudoId",
          "kpis",
          "blocos"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "erro": {
            "type": "string"
          },
          "codigo": {
            "type": "string"
          }
        },
        "required": [
          "erro",
          "codigo"
        ]
      }
    }
  }
}
