{
  "openapi": "3.0.3",
  "info": {
    "title": "API Gestão+",
    "version": "2026-10-31",
    "description": "API REST do Gestão+ para integrar o seu negócio com automações e ferramentas de IA. Disponível a partir do plano Start. Autentique com `Authorization: Bearer <chave>`. Chaves `gm_test_` respondem com dados fictícios. Guia completo: https://gestaomais.app/developers",
    "contact": {
      "name": "Suporte Gestão+",
      "url": "https://gestaomais.app/ajuda"
    }
  },
  "servers": [
    {
      "url": "https://gestaomais.app/api/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Geral"
    },
    {
      "name": "Clientes",
      "description": "Cadastro de clientes da empresa."
    },
    {
      "name": "Produtos",
      "description": "Catálogo de produtos com preço e estoque."
    },
    {
      "name": "Serviços",
      "description": "Catálogo de serviços com valor e tempo estimado."
    },
    {
      "name": "Vendas",
      "description": "Vendas do PDV. O detalhe traz itens e pagamentos."
    },
    {
      "name": "Lançamentos financeiros",
      "description": "Contas a pagar e a receber."
    },
    {
      "name": "Contas financeiras",
      "description": "Contas bancárias, caixas e carteiras."
    },
    {
      "name": "Categorias financeiras",
      "description": "Categorias de entradas e saídas."
    },
    {
      "name": "Agenda",
      "description": "Compromissos e atendimentos agendados."
    }
  ],
  "paths": {
    "/ping": {
      "get": {
        "summary": "Testar a chave",
        "description": "Confere se a chave funciona e devolve a empresa, os escopos e o plano. Não exige escopo.",
        "tags": [
          "Geral"
        ],
        "responses": {
          "200": {
            "description": "Chave válida."
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/clientes": {
      "get": {
        "summary": "Listar clientes",
        "description": "Cadastro de clientes da empresa. Escopo: `clientes:ler`. Ordem: mais recentes primeiro.",
        "tags": [
          "Clientes"
        ],
        "x-gm-scope": "clientes:ler",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor da página anterior."
          },
          {
            "name": "status",
            "in": "query",
            "description": "Situação do cadastro.",
            "schema": {
              "type": "string",
              "enum": [
                "ativo",
                "inativo"
              ]
            }
          },
          {
            "name": "atualizado_desde",
            "in": "query",
            "description": "Só registros alterados a partir desta data e hora (ISO 8601). Útil para sincronizar.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de resultados.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Clientes"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "post": {
        "summary": "Criar clientes",
        "description": "Escopo: `clientes:escrever`. Exige Idempotency-Key.",
        "tags": [
          "Clientes"
        ],
        "x-gm-scope": "clientes:escrever",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "nome"
                ],
                "properties": {
                  "nome": {
                    "type": "string",
                    "nullable": false,
                    "description": "Nome ou razão social."
                  },
                  "cpf_cnpj": {
                    "type": "string",
                    "nullable": true,
                    "description": "CPF ou CNPJ. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "email": {
                    "type": "string",
                    "nullable": true,
                    "description": "E-mail. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "telefone": {
                    "type": "string",
                    "nullable": true,
                    "description": "Telefone. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "endereco": {
                    "type": "string",
                    "nullable": true,
                    "description": "Endereço. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "cep": {
                    "type": "string",
                    "nullable": true,
                    "description": "CEP. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "cidade": {
                    "type": "string",
                    "nullable": true,
                    "description": "Cidade."
                  },
                  "estado": {
                    "type": "string",
                    "nullable": true,
                    "description": "UF."
                  },
                  "observacoes": {
                    "type": "string",
                    "nullable": true,
                    "description": "Observações internas. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "ativo ou inativo."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "description": "Etiquetas."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Criado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Clientes"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/clientes/{id}": {
      "patch": {
        "summary": "Atualizar clientes",
        "description": "Escopo: `clientes:escrever`. Envie só os campos que mudam.",
        "tags": [
          "Clientes"
        ],
        "x-gm-scope": "clientes:escrever",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "nome": {
                    "type": "string",
                    "nullable": false,
                    "description": "Nome ou razão social."
                  },
                  "cpf_cnpj": {
                    "type": "string",
                    "nullable": true,
                    "description": "CPF ou CNPJ. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "email": {
                    "type": "string",
                    "nullable": true,
                    "description": "E-mail. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "telefone": {
                    "type": "string",
                    "nullable": true,
                    "description": "Telefone. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "endereco": {
                    "type": "string",
                    "nullable": true,
                    "description": "Endereço. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "cep": {
                    "type": "string",
                    "nullable": true,
                    "description": "CEP. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "cidade": {
                    "type": "string",
                    "nullable": true,
                    "description": "Cidade."
                  },
                  "estado": {
                    "type": "string",
                    "nullable": true,
                    "description": "UF."
                  },
                  "observacoes": {
                    "type": "string",
                    "nullable": true,
                    "description": "Observações internas. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "ativo ou inativo."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "description": "Etiquetas."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Atualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Clientes"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "get": {
        "summary": "Buscar clientes por id",
        "description": "Escopo: `clientes:ler`.",
        "tags": [
          "Clientes"
        ],
        "x-gm-scope": "clientes:ler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Registro.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Clientes"
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/produtos": {
      "get": {
        "summary": "Listar produtos",
        "description": "Catálogo de produtos com preço e estoque. Escopo: `produtos:ler`. Ordem: mais recentes primeiro.",
        "tags": [
          "Produtos"
        ],
        "x-gm-scope": "produtos:ler",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor da página anterior."
          },
          {
            "name": "status",
            "in": "query",
            "description": "Situação do cadastro.",
            "schema": {
              "type": "string",
              "enum": [
                "ativo",
                "inativo"
              ]
            }
          },
          {
            "name": "categoria",
            "in": "query",
            "description": "Categoria exata.",
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "sku",
            "in": "query",
            "description": "SKU exato.",
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "codigo_barras",
            "in": "query",
            "description": "Código de barras exato.",
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "atualizado_desde",
            "in": "query",
            "description": "Só registros alterados a partir desta data e hora (ISO 8601). Útil para sincronizar.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de resultados.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Produtos"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "post": {
        "summary": "Criar produtos",
        "description": "Escopo: `produtos:escrever`. Exige Idempotency-Key.",
        "tags": [
          "Produtos"
        ],
        "x-gm-scope": "produtos:escrever",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "nome"
                ],
                "properties": {
                  "nome": {
                    "type": "string",
                    "nullable": false,
                    "description": "Nome do produto."
                  },
                  "sku": {
                    "type": "string",
                    "nullable": true,
                    "description": "Código interno (SKU)."
                  },
                  "codigo_barras": {
                    "type": "string",
                    "nullable": true,
                    "description": "Código de barras (EAN)."
                  },
                  "categoria": {
                    "type": "string",
                    "nullable": true,
                    "description": "Categoria."
                  },
                  "unidade": {
                    "type": "string",
                    "nullable": true,
                    "description": "Unidade de venda (UN, KG…)."
                  },
                  "preco_venda": {
                    "type": "number",
                    "nullable": true,
                    "description": "Preço de venda (R$)."
                  },
                  "preco_custo": {
                    "type": "number",
                    "nullable": true,
                    "description": "Preço de custo (R$)."
                  },
                  "estoque_minimo": {
                    "type": "number",
                    "nullable": true,
                    "description": "Estoque mínimo."
                  },
                  "fornecedor": {
                    "type": "string",
                    "nullable": true,
                    "description": "Fornecedor principal."
                  },
                  "descricao": {
                    "type": "string",
                    "nullable": true,
                    "description": "Descrição."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "ativo ou inativo."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "description": "Etiquetas."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Criado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Produtos"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/produtos/{id}": {
      "patch": {
        "summary": "Atualizar produtos",
        "description": "Escopo: `produtos:escrever`. Envie só os campos que mudam.",
        "tags": [
          "Produtos"
        ],
        "x-gm-scope": "produtos:escrever",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "nome": {
                    "type": "string",
                    "nullable": false,
                    "description": "Nome do produto."
                  },
                  "sku": {
                    "type": "string",
                    "nullable": true,
                    "description": "Código interno (SKU)."
                  },
                  "codigo_barras": {
                    "type": "string",
                    "nullable": true,
                    "description": "Código de barras (EAN)."
                  },
                  "categoria": {
                    "type": "string",
                    "nullable": true,
                    "description": "Categoria."
                  },
                  "unidade": {
                    "type": "string",
                    "nullable": true,
                    "description": "Unidade de venda (UN, KG…)."
                  },
                  "preco_venda": {
                    "type": "number",
                    "nullable": true,
                    "description": "Preço de venda (R$)."
                  },
                  "preco_custo": {
                    "type": "number",
                    "nullable": true,
                    "description": "Preço de custo (R$)."
                  },
                  "estoque_minimo": {
                    "type": "number",
                    "nullable": true,
                    "description": "Estoque mínimo."
                  },
                  "fornecedor": {
                    "type": "string",
                    "nullable": true,
                    "description": "Fornecedor principal."
                  },
                  "descricao": {
                    "type": "string",
                    "nullable": true,
                    "description": "Descrição."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "ativo ou inativo."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "description": "Etiquetas."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Atualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Produtos"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "get": {
        "summary": "Buscar produtos por id",
        "description": "Escopo: `produtos:ler`.",
        "tags": [
          "Produtos"
        ],
        "x-gm-scope": "produtos:ler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Registro.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Produtos"
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/servicos": {
      "get": {
        "summary": "Listar serviços",
        "description": "Catálogo de serviços com valor e tempo estimado. Escopo: `servicos:ler`. Ordem: mais recentes primeiro.",
        "tags": [
          "Serviços"
        ],
        "x-gm-scope": "servicos:ler",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor da página anterior."
          },
          {
            "name": "status",
            "in": "query",
            "description": "Situação do cadastro.",
            "schema": {
              "type": "string",
              "enum": [
                "ativo",
                "inativo"
              ]
            }
          },
          {
            "name": "categoria",
            "in": "query",
            "description": "Categoria exata.",
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "atualizado_desde",
            "in": "query",
            "description": "Só registros alterados a partir desta data e hora (ISO 8601). Útil para sincronizar.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de resultados.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Servicos"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "post": {
        "summary": "Criar serviços",
        "description": "Escopo: `servicos:escrever`. Exige Idempotency-Key.",
        "tags": [
          "Serviços"
        ],
        "x-gm-scope": "servicos:escrever",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "nome"
                ],
                "properties": {
                  "nome": {
                    "type": "string",
                    "nullable": false,
                    "description": "Nome do serviço."
                  },
                  "categoria": {
                    "type": "string",
                    "nullable": true,
                    "description": "Categoria."
                  },
                  "descricao": {
                    "type": "string",
                    "nullable": true,
                    "description": "Descrição."
                  },
                  "valor": {
                    "type": "number",
                    "nullable": true,
                    "description": "Valor (R$)."
                  },
                  "tempo_estimado_min": {
                    "type": "integer",
                    "nullable": true,
                    "description": "Tempo estimado em minutos."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "ativo ou inativo."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "description": "Etiquetas."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Criado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Servicos"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/servicos/{id}": {
      "patch": {
        "summary": "Atualizar serviços",
        "description": "Escopo: `servicos:escrever`. Envie só os campos que mudam.",
        "tags": [
          "Serviços"
        ],
        "x-gm-scope": "servicos:escrever",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "nome": {
                    "type": "string",
                    "nullable": false,
                    "description": "Nome do serviço."
                  },
                  "categoria": {
                    "type": "string",
                    "nullable": true,
                    "description": "Categoria."
                  },
                  "descricao": {
                    "type": "string",
                    "nullable": true,
                    "description": "Descrição."
                  },
                  "valor": {
                    "type": "number",
                    "nullable": true,
                    "description": "Valor (R$)."
                  },
                  "tempo_estimado_min": {
                    "type": "integer",
                    "nullable": true,
                    "description": "Tempo estimado em minutos."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "ativo ou inativo."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "description": "Etiquetas."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Atualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Servicos"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "get": {
        "summary": "Buscar serviços por id",
        "description": "Escopo: `servicos:ler`.",
        "tags": [
          "Serviços"
        ],
        "x-gm-scope": "servicos:ler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Registro.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Servicos"
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/vendas": {
      "get": {
        "summary": "Listar vendas",
        "description": "Vendas do PDV. O detalhe traz itens e pagamentos. Escopo: `vendas:ler`. Ordem: mais recentes primeiro.",
        "tags": [
          "Vendas"
        ],
        "x-gm-scope": "vendas:ler",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor da página anterior."
          },
          {
            "name": "status",
            "in": "query",
            "description": "Situação exata.",
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "cliente_id",
            "in": "query",
            "description": "Vendas de um cliente.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "desde",
            "in": "query",
            "description": "Feitas a partir de (ISO 8601).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "ate",
            "in": "query",
            "description": "Feitas até (ISO 8601).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de resultados.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Vendas"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/vendas/{id}": {
      "get": {
        "summary": "Buscar vendas por id",
        "description": "Escopo: `vendas:ler`. Inclui itens e pagamentos.",
        "tags": [
          "Vendas"
        ],
        "x-gm-scope": "vendas:ler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Registro.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/VendasDetalhe"
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/lancamentos": {
      "get": {
        "summary": "Listar lançamentos financeiros",
        "description": "Contas a pagar e a receber. Escopo: `financeiro:ler`. Ordem: mais recentes primeiro.",
        "tags": [
          "Lançamentos financeiros"
        ],
        "x-gm-scope": "financeiro:ler",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor da página anterior."
          },
          {
            "name": "tipo",
            "in": "query",
            "description": "Tipo do lançamento.",
            "schema": {
              "type": "string",
              "enum": [
                "entrada",
                "saida"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Situação.",
            "schema": {
              "type": "string",
              "enum": [
                "previsto",
                "pago",
                "atrasado",
                "cancelado"
              ]
            }
          },
          {
            "name": "vencimento_de",
            "in": "query",
            "description": "Vencimento a partir de (AAAA-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "vencimento_ate",
            "in": "query",
            "description": "Vencimento até (AAAA-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "cliente_id",
            "in": "query",
            "description": "Lançamentos de um cliente.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "atualizado_desde",
            "in": "query",
            "description": "Só registros alterados a partir desta data e hora (ISO 8601). Útil para sincronizar.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de resultados.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Lancamentos"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "post": {
        "summary": "Criar lançamentos financeiros",
        "description": "Escopo: `financeiro:escrever`. Exige Idempotency-Key.",
        "tags": [
          "Lançamentos financeiros"
        ],
        "x-gm-scope": "financeiro:escrever",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "tipo",
                  "descricao",
                  "valor"
                ],
                "properties": {
                  "tipo": {
                    "type": "string",
                    "nullable": false,
                    "description": "entrada ou saida."
                  },
                  "descricao": {
                    "type": "string",
                    "nullable": false,
                    "description": "Descrição."
                  },
                  "valor": {
                    "type": "number",
                    "nullable": false,
                    "description": "Valor (R$)."
                  },
                  "data_vencimento": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Vencimento (AAAA-MM-DD)."
                  },
                  "data_pagamento": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Pagamento (AAAA-MM-DD)."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "previsto, pago, atrasado ou cancelado."
                  },
                  "conta_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true,
                    "description": "Conta bancária ou caixa."
                  },
                  "categoria_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true,
                    "description": "Categoria financeira."
                  },
                  "cliente_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true,
                    "description": "Cliente relacionado."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "description": "Etiquetas."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Criado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lancamentos"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/lancamentos/{id}": {
      "patch": {
        "summary": "Atualizar lançamentos financeiros",
        "description": "Escopo: `financeiro:escrever`. Envie só os campos que mudam.",
        "tags": [
          "Lançamentos financeiros"
        ],
        "x-gm-scope": "financeiro:escrever",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "tipo": {
                    "type": "string",
                    "nullable": false,
                    "description": "entrada ou saida."
                  },
                  "descricao": {
                    "type": "string",
                    "nullable": false,
                    "description": "Descrição."
                  },
                  "valor": {
                    "type": "number",
                    "nullable": false,
                    "description": "Valor (R$)."
                  },
                  "data_vencimento": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Vencimento (AAAA-MM-DD)."
                  },
                  "data_pagamento": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "Pagamento (AAAA-MM-DD)."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "previsto, pago, atrasado ou cancelado."
                  },
                  "conta_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true,
                    "description": "Conta bancária ou caixa."
                  },
                  "categoria_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true,
                    "description": "Categoria financeira."
                  },
                  "cliente_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true,
                    "description": "Cliente relacionado."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "description": "Etiquetas."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Atualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lancamentos"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "get": {
        "summary": "Buscar lançamentos financeiros por id",
        "description": "Escopo: `financeiro:ler`.",
        "tags": [
          "Lançamentos financeiros"
        ],
        "x-gm-scope": "financeiro:ler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Registro.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Lancamentos"
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/contas": {
      "get": {
        "summary": "Listar contas financeiras",
        "description": "Contas bancárias, caixas e carteiras. Escopo: `financeiro:ler`. Ordem: mais recentes primeiro.",
        "tags": [
          "Contas financeiras"
        ],
        "x-gm-scope": "financeiro:ler",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor da página anterior."
          }
        ],
        "responses": {
          "200": {
            "description": "Página de resultados.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contas"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/contas/{id}": {
      "get": {
        "summary": "Buscar contas financeiras por id",
        "description": "Escopo: `financeiro:ler`.",
        "tags": [
          "Contas financeiras"
        ],
        "x-gm-scope": "financeiro:ler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Registro.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contas"
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/categorias": {
      "get": {
        "summary": "Listar categorias financeiras",
        "description": "Categorias de entradas e saídas. Escopo: `financeiro:ler`. Ordem: mais recentes primeiro.",
        "tags": [
          "Categorias financeiras"
        ],
        "x-gm-scope": "financeiro:ler",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor da página anterior."
          },
          {
            "name": "tipo",
            "in": "query",
            "description": "Tipo da categoria.",
            "schema": {
              "type": "string",
              "enum": [
                "entrada",
                "saida"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de resultados.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Categorias"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/categorias/{id}": {
      "get": {
        "summary": "Buscar categorias financeiras por id",
        "description": "Escopo: `financeiro:ler`.",
        "tags": [
          "Categorias financeiras"
        ],
        "x-gm-scope": "financeiro:ler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Registro.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Categorias"
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/agenda": {
      "get": {
        "summary": "Listar agenda",
        "description": "Compromissos e atendimentos agendados. Escopo: `agenda:ler`. Ordem: mais recentes primeiro.",
        "tags": [
          "Agenda"
        ],
        "x-gm-scope": "agenda:ler",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor da página anterior."
          },
          {
            "name": "inicio_de",
            "in": "query",
            "description": "Começa a partir de (ISO 8601).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "inicio_ate",
            "in": "query",
            "description": "Começa até (ISO 8601).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Situação exata.",
            "schema": {
              "type": "string",
              "maxLength": 60
            }
          },
          {
            "name": "cliente_id",
            "in": "query",
            "description": "Compromissos de um cliente.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "atualizado_desde",
            "in": "query",
            "description": "Só registros alterados a partir desta data e hora (ISO 8601). Útil para sincronizar.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Página de resultados.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Agenda"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "post": {
        "summary": "Criar agenda",
        "description": "Escopo: `agenda:escrever`. Exige Idempotency-Key.",
        "tags": [
          "Agenda"
        ],
        "x-gm-scope": "agenda:escrever",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "titulo",
                  "inicio",
                  "fim"
                ],
                "properties": {
                  "titulo": {
                    "type": "string",
                    "nullable": false,
                    "description": "Título."
                  },
                  "descricao": {
                    "type": "string",
                    "nullable": true,
                    "description": "Descrição."
                  },
                  "inicio": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": false,
                    "description": "Início (ISO 8601)."
                  },
                  "fim": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": false,
                    "description": "Fim (ISO 8601)."
                  },
                  "dia_inteiro": {
                    "type": "boolean",
                    "nullable": true,
                    "description": "Ocupa o dia inteiro."
                  },
                  "local": {
                    "type": "string",
                    "nullable": true,
                    "description": "Local."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "Situação do compromisso."
                  },
                  "tipo": {
                    "type": "string",
                    "nullable": true,
                    "description": "Tipo do compromisso."
                  },
                  "cliente_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true,
                    "description": "Cliente relacionado."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Criado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Agenda"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    },
    "/agenda/{id}": {
      "patch": {
        "summary": "Atualizar agenda",
        "description": "Escopo: `agenda:escrever`. Envie só os campos que mudam.",
        "tags": [
          "Agenda"
        ],
        "x-gm-scope": "agenda:escrever",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            },
            "description": "Identificador único da operação (ex.: um UUID). Repetir a chamada com a mesma chave devolve a resposta original em até 24 h.",
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "titulo": {
                    "type": "string",
                    "nullable": false,
                    "description": "Título."
                  },
                  "descricao": {
                    "type": "string",
                    "nullable": true,
                    "description": "Descrição."
                  },
                  "inicio": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": false,
                    "description": "Início (ISO 8601)."
                  },
                  "fim": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": false,
                    "description": "Fim (ISO 8601)."
                  },
                  "dia_inteiro": {
                    "type": "boolean",
                    "nullable": true,
                    "description": "Ocupa o dia inteiro."
                  },
                  "local": {
                    "type": "string",
                    "nullable": true,
                    "description": "Local."
                  },
                  "status": {
                    "type": "string",
                    "nullable": true,
                    "description": "Situação do compromisso."
                  },
                  "tipo": {
                    "type": "string",
                    "nullable": true,
                    "description": "Tipo do compromisso."
                  },
                  "cliente_id": {
                    "type": "string",
                    "format": "uuid",
                    "nullable": true,
                    "description": "Cliente relacionado."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Atualizado.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Agenda"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Erro"
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "409": {
            "$ref": "#/components/responses/Erro"
          },
          "422": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      },
      "get": {
        "summary": "Buscar agenda por id",
        "description": "Escopo: `agenda:ler`.",
        "tags": [
          "Agenda"
        ],
        "x-gm-scope": "agenda:ler",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Registro.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Agenda"
                    },
                    "ambiente": {
                      "type": "string",
                      "enum": [
                        "live",
                        "test"
                      ]
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Erro"
          },
          "403": {
            "$ref": "#/components/responses/Erro"
          },
          "404": {
            "$ref": "#/components/responses/Erro"
          },
          "429": {
            "$ref": "#/components/responses/Erro"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Chave criada em Configurações → Integrações."
      }
    },
    "responses": {
      "Erro": {
        "description": "Erro (veja error.code).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Erro"
            }
          }
        }
      }
    },
    "schemas": {
      "Erro": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "Clientes": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "nome": {
            "type": "string",
            "nullable": true,
            "description": "Nome ou razão social."
          },
          "cpf_cnpj": {
            "type": "string",
            "nullable": true,
            "description": "CPF ou CNPJ. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "E-mail. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
          },
          "telefone": {
            "type": "string",
            "nullable": true,
            "description": "Telefone. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
          },
          "endereco": {
            "type": "string",
            "nullable": true,
            "description": "Endereço. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
          },
          "cep": {
            "type": "string",
            "nullable": true,
            "description": "CEP. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
          },
          "cidade": {
            "type": "string",
            "nullable": true,
            "description": "Cidade."
          },
          "estado": {
            "type": "string",
            "nullable": true,
            "description": "UF."
          },
          "observacoes": {
            "type": "string",
            "nullable": true,
            "description": "Observações internas. Dado pessoal: exige o escopo dados_pessoais:ler (senão vem null)."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "ativo ou inativo."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "Etiquetas."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          }
        }
      },
      "Produtos": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "nome": {
            "type": "string",
            "nullable": true,
            "description": "Nome do produto."
          },
          "sku": {
            "type": "string",
            "nullable": true,
            "description": "Código interno (SKU)."
          },
          "codigo_barras": {
            "type": "string",
            "nullable": true,
            "description": "Código de barras (EAN)."
          },
          "categoria": {
            "type": "string",
            "nullable": true,
            "description": "Categoria."
          },
          "unidade": {
            "type": "string",
            "nullable": true,
            "description": "Unidade de venda (UN, KG…)."
          },
          "preco_venda": {
            "type": "number",
            "nullable": true,
            "description": "Preço de venda (R$)."
          },
          "preco_custo": {
            "type": "number",
            "nullable": true,
            "description": "Preço de custo (R$)."
          },
          "estoque": {
            "type": "number",
            "nullable": true,
            "description": "Quantidade em estoque."
          },
          "estoque_minimo": {
            "type": "number",
            "nullable": true,
            "description": "Estoque mínimo."
          },
          "fornecedor": {
            "type": "string",
            "nullable": true,
            "description": "Fornecedor principal."
          },
          "descricao": {
            "type": "string",
            "nullable": true,
            "description": "Descrição."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "ativo ou inativo."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "Etiquetas."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          }
        }
      },
      "Servicos": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "nome": {
            "type": "string",
            "nullable": true,
            "description": "Nome do serviço."
          },
          "categoria": {
            "type": "string",
            "nullable": true,
            "description": "Categoria."
          },
          "descricao": {
            "type": "string",
            "nullable": true,
            "description": "Descrição."
          },
          "valor": {
            "type": "number",
            "nullable": true,
            "description": "Valor (R$)."
          },
          "tempo_estimado_min": {
            "type": "integer",
            "nullable": true,
            "description": "Tempo estimado em minutos."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "ativo ou inativo."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "Etiquetas."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          }
        }
      },
      "Vendas": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "numero": {
            "type": "integer",
            "nullable": true,
            "description": "Número sequencial da venda."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "Situação (concluida, cancelada…)."
          },
          "cliente_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Cliente, quando identificado."
          },
          "subtotal": {
            "type": "number",
            "nullable": true,
            "description": "Soma dos itens (R$)."
          },
          "desconto": {
            "type": "number",
            "nullable": true,
            "description": "Desconto (R$)."
          },
          "acrescimo": {
            "type": "number",
            "nullable": true,
            "description": "Acréscimo (R$)."
          },
          "total": {
            "type": "number",
            "nullable": true,
            "description": "Total da venda (R$)."
          },
          "origem": {
            "type": "string",
            "nullable": true,
            "description": "Origem (pdv, app…)."
          },
          "cancelada_em": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Quando foi cancelada."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          }
        }
      },
      "VendasDetalhe": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "numero": {
            "type": "integer",
            "nullable": true,
            "description": "Número sequencial da venda."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "Situação (concluida, cancelada…)."
          },
          "cliente_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Cliente, quando identificado."
          },
          "subtotal": {
            "type": "number",
            "nullable": true,
            "description": "Soma dos itens (R$)."
          },
          "desconto": {
            "type": "number",
            "nullable": true,
            "description": "Desconto (R$)."
          },
          "acrescimo": {
            "type": "number",
            "nullable": true,
            "description": "Acréscimo (R$)."
          },
          "total": {
            "type": "number",
            "nullable": true,
            "description": "Total da venda (R$)."
          },
          "origem": {
            "type": "string",
            "nullable": true,
            "description": "Origem (pdv, app…)."
          },
          "cancelada_em": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Quando foi cancelada."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          },
          "itens": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": false,
                  "description": "Identificador."
                },
                "produto_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true,
                  "description": "Produto vendido."
                },
                "servico_id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": true,
                  "description": "Serviço vendido."
                },
                "descricao": {
                  "type": "string",
                  "nullable": true,
                  "description": "Descrição no momento da venda."
                },
                "quantidade": {
                  "type": "number",
                  "nullable": true,
                  "description": "Quantidade."
                },
                "preco_unitario": {
                  "type": "number",
                  "nullable": true,
                  "description": "Preço unitário (R$)."
                },
                "desconto": {
                  "type": "number",
                  "nullable": true,
                  "description": "Desconto (R$)."
                },
                "acrescimo": {
                  "type": "number",
                  "nullable": true,
                  "description": "Acréscimo (R$)."
                },
                "total": {
                  "type": "number",
                  "nullable": true,
                  "description": "Total do item (R$)."
                }
              }
            }
          },
          "pagamentos": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "nullable": false,
                  "description": "Identificador."
                },
                "forma": {
                  "type": "string",
                  "nullable": true,
                  "description": "Forma (dinheiro, pix, credito…)."
                },
                "valor": {
                  "type": "number",
                  "nullable": true,
                  "description": "Valor (R$)."
                },
                "parcelas": {
                  "type": "integer",
                  "nullable": true,
                  "description": "Parcelas."
                },
                "troco": {
                  "type": "number",
                  "nullable": true,
                  "description": "Troco (R$)."
                }
              }
            }
          }
        }
      },
      "Lancamentos": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "tipo": {
            "type": "string",
            "nullable": true,
            "description": "entrada ou saida."
          },
          "descricao": {
            "type": "string",
            "nullable": true,
            "description": "Descrição."
          },
          "valor": {
            "type": "number",
            "nullable": true,
            "description": "Valor (R$)."
          },
          "data_vencimento": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Vencimento (AAAA-MM-DD)."
          },
          "data_pagamento": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "Pagamento (AAAA-MM-DD)."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "previsto, pago, atrasado ou cancelado."
          },
          "conta_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Conta bancária ou caixa."
          },
          "categoria_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Categoria financeira."
          },
          "cliente_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Cliente relacionado."
          },
          "centro_custo_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Centro de custo."
          },
          "parcela_num": {
            "type": "integer",
            "nullable": true,
            "description": "Número da parcela."
          },
          "parcela_total": {
            "type": "integer",
            "nullable": true,
            "description": "Total de parcelas."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "Etiquetas."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          }
        }
      },
      "Contas": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "nome": {
            "type": "string",
            "nullable": true,
            "description": "Nome da conta."
          },
          "tipo": {
            "type": "string",
            "nullable": true,
            "description": "caixa, banco, cartao ou outro."
          },
          "saldo_inicial": {
            "type": "number",
            "nullable": true,
            "description": "Saldo inicial (R$)."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "ativo ou inativo."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          }
        }
      },
      "Categorias": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "nome": {
            "type": "string",
            "nullable": true,
            "description": "Nome da categoria."
          },
          "tipo": {
            "type": "string",
            "nullable": true,
            "description": "entrada ou saida."
          },
          "cor": {
            "type": "string",
            "nullable": true,
            "description": "Cor no painel."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          }
        }
      },
      "Agenda": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": false,
            "description": "Identificador."
          },
          "titulo": {
            "type": "string",
            "nullable": true,
            "description": "Título."
          },
          "descricao": {
            "type": "string",
            "nullable": true,
            "description": "Descrição."
          },
          "inicio": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Início (ISO 8601)."
          },
          "fim": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Fim (ISO 8601)."
          },
          "dia_inteiro": {
            "type": "boolean",
            "nullable": true,
            "description": "Ocupa o dia inteiro."
          },
          "local": {
            "type": "string",
            "nullable": true,
            "description": "Local."
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "Situação do compromisso."
          },
          "tipo": {
            "type": "string",
            "nullable": true,
            "description": "Tipo do compromisso."
          },
          "cliente_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "Cliente relacionado."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Criado em (ISO 8601)."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Atualizado em (ISO 8601)."
          }
        }
      }
    }
  }
}