{
  "openapi": "3.0.0",
  "paths": {
    "/wascer-api/{api_key}/v1/store/collections": {
      "post": {
        "description": "Cria uma nova collection vazia no tenant. Idempotente em relação ao nome.",
        "operationId": "WascerApiController_createCollection",
        "parameters": [
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCollectionDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateCollectionResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida (corpo, filtro, cursor ou nome)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_INVALID_REQUEST",
                  "message": "collection_name must match ^[a-zA-Z0-9_-]{1,64}$"
                }
              }
            }
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Criar collection",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      },
      "get": {
        "description": "Retorna todas as collections do tenant.",
        "operationId": "WascerApiController_listCollections",
        "parameters": [
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListCollectionsResponseDto"
                }
              }
            }
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Listar collections",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      }
    },
    "/wascer-api/{api_key}/v1/store/collections/{collection_name}/documents": {
      "post": {
        "description": "Cria um documento na collection. Falha com 409 se `document_key` já existir.",
        "operationId": "WascerApiController_createDocument",
        "parameters": [
          {
            "name": "collection_name",
            "required": true,
            "in": "path",
            "schema": {
              "example": "users",
              "type": "string"
            }
          },
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerDocumentDto"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida (corpo, filtro, cursor ou nome)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_INVALID_REQUEST",
                  "message": "collection_name must match ^[a-zA-Z0-9_-]{1,64}$"
                }
              }
            }
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "409": {
            "description": "document_key já existe nesta collection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_CONFLICT",
                  "message": "document already exists"
                }
              }
            }
          },
          "413": {
            "description": "data acima de 500 KB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_PAYLOAD_TOO_LARGE",
                  "message": "payload exceeds size limit"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Criar documento",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      },
      "get": {
        "description": "Lista documentos da collection com paginação por cursor. Use `next_cursor` para a próxima página.",
        "operationId": "WascerApiController_listDocuments",
        "parameters": [
          {
            "name": "collection_name",
            "required": true,
            "in": "path",
            "schema": {
              "example": "users",
              "type": "string"
            }
          },
          {
            "name": "order",
            "required": false,
            "in": "query",
            "description": "Ordem da listagem por document_key",
            "schema": {
              "default": "ASC",
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Quantidade máxima de documentos retornados",
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "default": 50,
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "description": "Cursor opaco (base64) retornado em `next_cursor` para paginação subsequente",
            "schema": {
              "example": "dXNlci00Mg==",
              "type": "string"
            }
          },
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListDocumentsResponseDto"
                }
              }
            }
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Listar documentos",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      }
    },
    "/wascer-api/{api_key}/v1/store/collections/{collection_name}/documents/query": {
      "post": {
        "description": "Filtra a collection por campos do `data`, do mais recente para o mais antigo. Cada chamada lê no máximo 1000 documentos; enquanto `next_cursor` não for nulo, chame de novo com ele para continuar. Use `created_after`/`created_before` para limitar a janela.",
        "operationId": "WascerApiController_queryDocuments",
        "parameters": [
          {
            "name": "collection_name",
            "required": true,
            "in": "path",
            "schema": {
              "example": "purchases",
              "type": "string"
            }
          },
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueryDocumentsDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryDocumentsResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida (corpo, filtro, cursor ou nome)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_INVALID_REQUEST",
                  "message": "collection_name must match ^[a-zA-Z0-9_-]{1,64}$"
                }
              }
            }
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Buscar documentos por campo",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      }
    },
    "/wascer-api/{api_key}/v1/store/collections/{collection_name}/documents/{document_key}": {
      "get": {
        "description": "Retorna um documento pelo `document_key`.",
        "operationId": "WascerApiController_getDocument",
        "parameters": [
          {
            "name": "collection_name",
            "required": true,
            "in": "path",
            "schema": {
              "example": "users",
              "type": "string"
            }
          },
          {
            "name": "document_key",
            "required": true,
            "in": "path",
            "schema": {
              "example": "user-42",
              "type": "string"
            }
          },
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerDocumentDto"
                }
              }
            }
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "404": {
            "description": "Documento não encontrado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_NOT_FOUND",
                  "message": "document not found"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Buscar documento",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      },
      "put": {
        "description": "Substitui o `data` do documento. Cria se não existir (upsert).",
        "operationId": "WascerApiController_putDocument",
        "parameters": [
          {
            "name": "collection_name",
            "required": true,
            "in": "path",
            "schema": {
              "example": "users",
              "type": "string"
            }
          },
          {
            "name": "document_key",
            "required": true,
            "in": "path",
            "schema": {
              "example": "user-42",
              "type": "string"
            }
          },
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerDocumentDto"
                }
              }
            }
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "413": {
            "description": "data acima de 500 KB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_PAYLOAD_TOO_LARGE",
                  "message": "payload exceeds size limit"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Substituir documento (PUT)",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      },
      "patch": {
        "description": "Faz merge superficial dos campos enviados sobre o `data` existente.",
        "operationId": "WascerApiController_patchDocument",
        "parameters": [
          {
            "name": "collection_name",
            "required": true,
            "in": "path",
            "schema": {
              "example": "users",
              "type": "string"
            }
          },
          {
            "name": "document_key",
            "required": true,
            "in": "path",
            "schema": {
              "example": "user-42",
              "type": "string"
            }
          },
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchDocumentDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerDocumentDto"
                }
              }
            }
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "404": {
            "description": "Documento não encontrado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_NOT_FOUND",
                  "message": "document not found"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Atualizar documento parcialmente (PATCH)",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      },
      "delete": {
        "description": "Remove o documento. Idempotente — sempre retorna 204.",
        "operationId": "WascerApiController_deleteDocument",
        "parameters": [
          {
            "name": "collection_name",
            "required": true,
            "in": "path",
            "schema": {
              "example": "users",
              "type": "string"
            }
          },
          {
            "name": "document_key",
            "required": true,
            "in": "path",
            "schema": {
              "example": "user-42",
              "type": "string"
            }
          },
          {
            "name": "api_key",
            "required": true,
            "in": "path",
            "description": "Chave pública (`pk_…`) de uma API key com escopo `database:access`, criada no painel em Configurações → API keys. Vale para os containers do dono da chave.",
            "schema": {
              "example": "pk_0123456789abcdef"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Documento removido"
          },
          "403": {
            "description": "Chave errada, revogada ou sem o escopo database:access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FORBIDDEN",
                  "message": "invalid api key"
                }
              }
            }
          },
          "503": {
            "description": "API ainda não ativa no container (crie a chave e aguarde até 2 min)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WascerErrorResponseDto"
                },
                "example": {
                  "code": "WASCER_FEATURE_DISABLED",
                  "message": "Feature enable_wascer_api is disabled"
                }
              }
            }
          }
        },
        "summary": "Deletar documento",
        "tags": [
          "Wascer API — Collections & Documents"
        ]
      }
    }
  },
  "info": {
    "title": "Wascer Database API",
    "description": "API REST do Database (store) do container sGTM da Wascer. Como começar e guia completo: https://docs.wascer.com/ e https://docs.wascer.com/guia.html",
    "version": "1.0",
    "contact": {}
  },
  "tags": [],
  "servers": [
    {
      "url": "https://{host}",
      "variables": {
        "host": {
          "default": "seu-container.soureicdn.com",
          "description": "Host do container sGTM"
        }
      }
    }
  ],
  "components": {
    "schemas": {
      "WascerErrorResponseDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Código machine-readable do erro",
            "enum": [
              "WASCER_INVALID_REQUEST",
              "WASCER_FORBIDDEN",
              "WASCER_NOT_FOUND",
              "WASCER_CONFLICT",
              "WASCER_PAYLOAD_TOO_LARGE",
              "WASCER_FEATURE_DISABLED",
              "WASCER_FEATURE_PENDING_SCHEMA",
              "WASCER_INTERNAL_ERROR"
            ],
            "example": "WASCER_NOT_FOUND"
          },
          "message": {
            "type": "string",
            "description": "Mensagem legível para humanos",
            "example": "document not found"
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "CreateCollectionDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Nome da collection (letras, números, underscore, hífen)",
            "example": "users",
            "pattern": "^[a-zA-Z0-9_-]{1,64}$",
            "minLength": 1,
            "maxLength": 64
          }
        },
        "required": [
          "name"
        ]
      },
      "CreateCollectionResponseDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "users"
          }
        },
        "required": [
          "name"
        ]
      },
      "ListCollectionsResponseDto": {
        "type": "object",
        "properties": {
          "collections": {
            "example": [
              "users",
              "orders"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "collections"
        ]
      },
      "CreateDocumentDto": {
        "type": "object",
        "properties": {
          "document_key": {
            "type": "string",
            "description": "Chave única do documento dentro da collection",
            "example": "user-42",
            "minLength": 1,
            "maxLength": 2054
          },
          "data": {
            "type": "object",
            "description": "Payload arbitrário do documento (objeto JSON). Limite total serializado: 500 KB.",
            "additionalProperties": true,
            "example": {
              "name": "Adam",
              "plan": "pro"
            }
          },
          "ttl": {
            "type": "number",
            "description": "TTL custom em segundos. Sobrescreve o default de 90 dias. Omitido ou 0 = default. Máximo 7776000 (90 dias) — o default já é o teto da base. Só na criação.",
            "minimum": 0,
            "maximum": 7776000,
            "example": 1209600
          }
        },
        "required": [
          "document_key",
          "data"
        ]
      },
      "WascerDocumentDto": {
        "type": "object",
        "properties": {
          "document_key": {
            "type": "string",
            "example": "user-42"
          },
          "collection": {
            "type": "string",
            "example": "users"
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "example": {
              "name": "Adam",
              "plan": "pro"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-05-09T12:34:56.789Z"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-05-09T12:34:56.789Z"
          }
        },
        "required": [
          "document_key",
          "collection",
          "data",
          "created_at",
          "updated_at"
        ]
      },
      "ListDocumentsResponseDto": {
        "type": "object",
        "properties": {
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WascerDocumentDto"
            }
          },
          "next_cursor": {
            "type": "object",
            "description": "Cursor para a próxima página (null quando não houver mais)",
            "nullable": true,
            "example": "dXNlci0xMDA="
          },
          "order": {
            "type": "string",
            "enum": [
              "ASC",
              "DESC"
            ],
            "example": "ASC"
          },
          "limit": {
            "type": "number",
            "example": 50
          }
        },
        "required": [
          "documents",
          "next_cursor",
          "order",
          "limit"
        ]
      },
      "UpdateDocumentDto": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "description": "Novo payload completo do documento (substitui o anterior). Objeto JSON, limite 500 KB.",
            "additionalProperties": true,
            "example": {
              "name": "Adam",
              "plan": "enterprise"
            }
          }
        },
        "required": [
          "data"
        ]
      },
      "PatchDocumentDto": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "description": "Atualização parcial — campos enviados sobrescrevem os existentes (merge superficial).",
            "additionalProperties": true,
            "example": {
              "plan": "enterprise"
            }
          }
        },
        "required": [
          "data"
        ]
      },
      "QueryDocumentsDto": {
        "type": "object",
        "properties": {
          "filter": {
            "type": "object",
            "description": "Condições sobre campos do `data` (caminho com ponto, ex.: `user_data.email`). Até 10 condições, combinadas por `and` (padrão) ou `or`. Operadores: equal, not-equal, exists, not-exists, contains, not-contains, gt, gte, lt, lte. `exists`/`not-exists` não usam `value`. Sem filtro, retorna todos os documentos da janela.",
            "additionalProperties": true,
            "example": {
              "operator": "and",
              "conditions": [
                {
                  "field": "event_name",
                  "operator": "equal",
                  "value": "purchase"
                },
                {
                  "field": "gclid",
                  "operator": "exists"
                }
              ]
            }
          },
          "created_after": {
            "type": "string",
            "description": "Só documentos criados a partir desta data (ISO 8601).",
            "example": "2026-10-27T00:00:00Z"
          },
          "created_before": {
            "type": "string",
            "description": "Só documentos criados até esta data (ISO 8601).",
            "example": "2026-11-03T23:59:59Z"
          },
          "order": {
            "type": "string",
            "description": "Ordem por data de criação. Padrão: mais recentes primeiro.",
            "enum": [
              "ASC",
              "DESC"
            ],
            "default": "DESC"
          },
          "limit": {
            "type": "number",
            "description": "Máximo de documentos encontrados por resposta.",
            "minimum": 1,
            "maximum": 500,
            "default": 50
          },
          "cursor": {
            "type": "string",
            "description": "`next_cursor` da resposta anterior, para continuar a busca."
          }
        }
      },
      "QueryDocumentsResponseDto": {
        "type": "object",
        "properties": {
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WascerDocumentDto"
            }
          },
          "next_cursor": {
            "type": "object",
            "description": "Cursor para a próxima página (null quando não houver mais)",
            "nullable": true,
            "example": "dXNlci0xMDA="
          },
          "order": {
            "type": "string",
            "enum": [
              "ASC",
              "DESC"
            ],
            "example": "ASC"
          },
          "limit": {
            "type": "number",
            "example": 50
          },
          "scanned": {
            "type": "number",
            "description": "Documentos lidos nesta chamada (no máximo 1000). Com `next_cursor` não nulo há mais a percorrer, mesmo que `documents` venha vazio.",
            "example": 1000
          }
        },
        "required": [
          "documents",
          "next_cursor",
          "order",
          "limit",
          "scanned"
        ]
      }
    }
  }
}