{
  "openapi": "3.1.0",
  "info": {
    "title": "Data Access Service",
    "version": "1.0.0",
    "description": "API REST para leitura e escrita controlada sobre o app sem expor o PostgreSQL diretamente."
  },
  "servers": [
    {
      "url": "https://api.growdoc.com.br"
    },
    {
      "url": "https://growdoc-data-access.lucas-f58.workers.dev"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    },
    "schemas": {
      "Client": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "status": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "product": {
            "type": [
              "string",
              "null"
            ]
          },
          "specialty": {
            "type": [
              "string",
              "null"
            ]
          },
          "squad": {
            "type": [
              "integer",
              "null"
            ]
          },
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "projectName": {
            "type": [
              "string",
              "null"
            ]
          },
          "instagram": {
            "type": [
              "string",
              "null"
            ]
          },
          "landingPageUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "healthScore": {
            "type": [
              "integer",
              "null"
            ]
          },
          "healthReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "monthlyBudget": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Contact": {
        "type": "object",
        "required": [
          "id",
          "clientId"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "clientId": {
            "type": "integer"
          },
          "displayName": {
            "type": [
              "string",
              "null"
            ]
          },
          "emailMasked": {
            "type": [
              "string",
              "null"
            ]
          },
          "phoneLast4": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "type": [
              "string",
              "null"
            ]
          },
          "stage": {
            "type": [
              "string",
              "null"
            ]
          },
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "utmSource": {
            "type": [
              "string",
              "null"
            ]
          },
          "utmCampaign": {
            "type": [
              "string",
              "null"
            ]
          },
          "utmMedium": {
            "type": [
              "string",
              "null"
            ]
          },
          "utmContent": {
            "type": [
              "string",
              "null"
            ]
          },
          "utmTerm": {
            "type": [
              "string",
              "null"
            ]
          },
          "assignedUserId": {
            "type": [
              "integer",
              "null"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ContactV2": {
        "type": "object",
        "required": [
          "id",
          "clientId",
          "lifecycle",
          "identity",
          "location",
          "intake",
          "attribution",
          "commercial",
          "activitySummary"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "clientId": {
            "type": "integer"
          },
          "leadDate": {
            "type": [
              "string",
              "null"
            ]
          },
          "lifecycle": {
            "type": "object",
            "additionalProperties": true
          },
          "identity": {
            "type": "object",
            "additionalProperties": true
          },
          "location": {
            "type": "object",
            "additionalProperties": true
          },
          "intake": {
            "type": "object",
            "additionalProperties": true
          },
          "attribution": {
            "type": "object",
            "additionalProperties": true
          },
          "commercial": {
            "type": "object",
            "additionalProperties": true
          },
          "activitySummary": {
            "type": "object",
            "additionalProperties": true
          },
          "raw": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          }
        }
      },
      "ContactV2Detail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ContactV2"
          },
          {
            "type": "object",
            "properties": {
              "recentTasks": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Task"
                }
              },
              "recentConversions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ConversionEvent"
                }
              }
            }
          }
        ]
      },
      "ClientV2": {
        "type": "object",
        "required": [
          "id",
          "identity",
          "location",
          "channels",
          "management",
          "crm",
          "activitySummary"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "status": {
            "type": [
              "string",
              "null"
            ]
          },
          "dates": {
            "type": "object",
            "additionalProperties": true
          },
          "identity": {
            "type": "object",
            "additionalProperties": true
          },
          "location": {
            "type": "object",
            "additionalProperties": true
          },
          "channels": {
            "type": "object",
            "additionalProperties": true
          },
          "management": {
            "type": "object",
            "additionalProperties": true
          },
          "crm": {
            "type": "object",
            "additionalProperties": true
          },
          "activitySummary": {
            "type": "object",
            "additionalProperties": true
          },
          "raw": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          }
        }
      },
      "ClientV2Detail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ClientV2"
          },
          {
            "type": "object",
            "properties": {
              "notes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "integrations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "recentContacts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        ]
      },
      "TaskV2": {
        "type": "object",
        "required": [
          "id",
          "title",
          "status",
          "schedule",
          "ownership",
          "contact",
          "client"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "schedule": {
            "type": "object",
            "additionalProperties": true
          },
          "ownership": {
            "type": "object",
            "additionalProperties": true
          },
          "contact": {
            "type": "object",
            "additionalProperties": true
          },
          "client": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "TaskV2Detail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/TaskV2"
          },
          {
            "type": "object",
            "properties": {
              "recentConversions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        ]
      },
      "ConversionEventV2": {
        "type": "object",
        "required": [
          "id",
          "classification",
          "schedule",
          "contact",
          "client"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "classification": {
            "type": "object",
            "additionalProperties": true
          },
          "schedule": {
            "type": "object",
            "additionalProperties": true
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "contact": {
            "type": "object",
            "additionalProperties": true
          },
          "client": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ConversionEventV2Detail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ConversionEventV2"
          },
          {
            "type": "object",
            "properties": {
              "recentTasks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        ]
      },
      "CampaignPerformanceV2": {
        "type": "object",
        "required": [
          "platform",
          "clientId",
          "date"
        ],
        "properties": {
          "platform": {
            "type": "string"
          },
          "clientId": {
            "type": "integer"
          },
          "date": {
            "type": "string"
          },
          "accountId": {
            "type": [
              "string",
              "null"
            ]
          },
          "accountName": {
            "type": [
              "string",
              "null"
            ]
          },
          "objectiveOrCampaignType": {
            "type": [
              "string",
              "null"
            ]
          },
          "campaignId": {
            "type": [
              "string",
              "null"
            ]
          },
          "campaignName": {
            "type": [
              "string",
              "null"
            ]
          },
          "adsetId": {
            "type": [
              "string",
              "null"
            ]
          },
          "adsetName": {
            "type": [
              "string",
              "null"
            ]
          },
          "adGroupId": {
            "type": [
              "string",
              "null"
            ]
          },
          "adGroupName": {
            "type": [
              "string",
              "null"
            ]
          },
          "adId": {
            "type": [
              "string",
              "null"
            ]
          },
          "adName": {
            "type": [
              "string",
              "null"
            ]
          },
          "spend": {
            "type": [
              "string",
              "null"
            ]
          },
          "impressions": {
            "type": [
              "string",
              "null"
            ]
          },
          "clicks": {
            "type": [
              "string",
              "null"
            ]
          },
          "leads": {
            "type": [
              "string",
              "null"
            ]
          },
          "conversationsStarted": {
            "type": [
              "string",
              "null"
            ]
          },
          "landingPageViews": {
            "type": [
              "string",
              "null"
            ]
          },
          "conversions": {
            "type": [
              "string",
              "null"
            ]
          },
          "reach": {
            "type": [
              "string",
              "null"
            ]
          },
          "linkClicks": {
            "type": [
              "string",
              "null"
            ]
          },
          "cpm": {
            "type": [
              "string",
              "null"
            ]
          },
          "ctr": {
            "type": [
              "string",
              "null"
            ]
          },
          "cpc": {
            "type": [
              "string",
              "null"
            ]
          },
          "frequency": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Task": {
        "type": "object",
        "required": [
          "id",
          "contactId",
          "clientId",
          "title",
          "status"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "contactId": {
            "type": "integer"
          },
          "clientId": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "dueDate": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          },
          "assignedTo": {
            "type": [
              "integer",
              "null"
            ]
          },
          "assignedToName": {
            "type": [
              "string",
              "null"
            ]
          },
          "creatorUserId": {
            "type": [
              "integer",
              "null"
            ]
          },
          "contactDisplayName": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ConversionEvent": {
        "type": "object",
        "required": [
          "id",
          "contactId",
          "clientId",
          "type",
          "status",
          "conversionDate"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "contactId": {
            "type": "integer"
          },
          "clientId": {
            "type": "integer"
          },
          "type": {
            "type": "string"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "value": {
            "type": [
              "string",
              "null"
            ]
          },
          "conversionDate": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "scheduledAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        }
      },
      "ClientMetricDaily": {
        "type": "object",
        "required": [
          "clientId",
          "date"
        ],
        "properties": {
          "clientId": {
            "type": "integer"
          },
          "date": {
            "type": "string"
          },
          "metaSpend": {
            "type": [
              "string",
              "null"
            ]
          },
          "metaImpressions": {
            "type": [
              "integer",
              "null"
            ]
          },
          "metaClicks": {
            "type": [
              "integer",
              "null"
            ]
          },
          "metaLeads": {
            "type": [
              "integer",
              "null"
            ]
          },
          "googleSpend": {
            "type": [
              "string",
              "null"
            ]
          },
          "googleImpressions": {
            "type": [
              "string",
              "null"
            ]
          },
          "googleClicks": {
            "type": [
              "string",
              "null"
            ]
          },
          "googleConversions": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "TrafficManagerFunnelBreakdownRow": {
        "type": "object",
        "required": [
          "leads",
          "agendamentos",
          "sessoes",
          "fechamentos",
          "faturamento",
          "payingLeads"
        ],
        "properties": {
          "dimensionValue": {
            "type": [
              "string",
              "null"
            ]
          },
          "leads": {
            "type": "integer"
          },
          "agendamentos": {
            "type": "integer"
          },
          "sessoes": {
            "type": "integer"
          },
          "fechamentos": {
            "type": "integer"
          },
          "faturamento": {
            "type": [
              "string",
              "null"
            ]
          },
          "payingLeads": {
            "type": "integer"
          },
          "ticketMedio": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "TrafficManagerFunnelSummaryResponse": {
        "type": "object",
        "required": [
          "queryScope",
          "metricDefinitions",
          "summary",
          "breakdown"
        ],
        "properties": {
          "queryScope": {
            "type": "object"
          },
          "metricDefinitions": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "summary": {
            "$ref": "#/components/schemas/TrafficManagerFunnelBreakdownRow"
          },
          "breakdown": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrafficManagerFunnelBreakdownRow"
            }
          }
        }
      },
      "TrafficManagerFunnelQueryRequest": {
        "type": "object",
        "required": [
          "clientId"
        ],
        "properties": {
          "clientId": {
            "type": "integer"
          },
          "leadPeriod": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "startDate": {
                "type": "string"
              },
              "endDate": {
                "type": "string"
              }
            }
          },
          "eventPeriod": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "startDate": {
                "type": "string"
              },
              "endDate": {
                "type": "string"
              }
            }
          },
          "filters": {
            "type": "object",
            "properties": {
              "utmSource": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "utmCampaign": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "utmMedium": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "utmContent": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "utmTerm": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "type": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "stage": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "assignedUserId": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              },
              "city": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "state": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "country": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "tagsAny": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "tagsAll": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "breakdownBy": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "utmSource",
              "utmCampaign",
              "utmMedium",
              "utmContent",
              "utmTerm",
              "stage",
              "assignedUserId",
              "city",
              "state",
              "country",
              "type",
              null
            ]
          },
          "limit": {
            "type": [
              "integer",
              "null"
            ]
          },
          "offset": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "CreateTaskRequest": {
        "type": "object",
        "required": [
          "contactId",
          "title"
        ],
        "properties": {
          "contactId": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "dueDate": {
            "type": [
              "string",
              "null"
            ]
          },
          "assignedTo": {
            "type": [
              "integer",
              "null"
            ]
          },
          "actorUserId": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "UpdateTaskStatusRequest": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string"
          },
          "actorUserId": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "AssignContactRequest": {
        "type": "object",
        "required": [
          "assignedUserId"
        ],
        "properties": {
          "assignedUserId": {
            "type": [
              "integer",
              "null"
            ]
          },
          "actorUserId": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "CreateManagementNoteRequest": {
        "type": "object",
        "required": [
          "noteType",
          "noteContent",
          "createdBy"
        ],
        "properties": {
          "noteType": {
            "type": "string"
          },
          "noteContent": {
            "type": "string"
          },
          "createdBy": {
            "type": "string"
          },
          "healthScoreSnapshot": {
            "type": [
              "integer",
              "null"
            ]
          },
          "actorUserId": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "CreateConversionEventRequest": {
        "type": "object",
        "required": [
          "type",
          "conversionDate"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "value": {
            "type": [
              "number",
              "null"
            ]
          },
          "conversionDate": {
            "type": "string"
          },
          "status": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "scheduledAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "actorUserId": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "AdvancedQueryFilter": {
        "type": "object",
        "required": [
          "field",
          "op"
        ],
        "properties": {
          "field": {
            "type": "string"
          },
          "op": {
            "type": "string",
            "enum": [
              "eq",
              "neq",
              "in",
              "contains",
              "gte",
              "lte",
              "between",
              "isNull",
              "notNull",
              "hasAny",
              "hasAll"
            ]
          },
          "value": {}
        }
      },
      "AdvancedQuerySort": {
        "type": "object",
        "required": [
          "field"
        ],
        "properties": {
          "field": {
            "type": "string"
          },
          "direction": {
            "type": "string",
            "enum": [
              "asc",
              "desc"
            ]
          }
        }
      },
      "AdvancedQueryRequest": {
        "type": "object",
        "properties": {
          "filters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdvancedQueryFilter"
            }
          },
          "sort": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdvancedQuerySort"
            }
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "includeRaw": {
            "type": "boolean"
          },
          "includeHistory": {
            "type": "boolean"
          }
        }
      },
      "AdvancedQueryMeta": {
        "type": "object",
        "required": [
          "limit",
          "offset",
          "returned",
          "filters",
          "sort"
        ],
        "properties": {
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "returned": {
            "type": "integer"
          },
          "filters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdvancedQueryFilter"
            }
          },
          "sort": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdvancedQuerySort"
            }
          }
        }
      },
      "ClientQueryResponse": {
        "type": "object",
        "required": [
          "meta",
          "data"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/AdvancedQueryMeta"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClientV2"
            }
          }
        }
      },
      "ContactQueryResponse": {
        "type": "object",
        "required": [
          "meta",
          "data"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/AdvancedQueryMeta"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactV2"
            }
          }
        }
      },
      "TaskQueryResponse": {
        "type": "object",
        "required": [
          "meta",
          "data"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/AdvancedQueryMeta"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskV2"
            }
          }
        }
      },
      "ConversionQueryResponse": {
        "type": "object",
        "required": [
          "meta",
          "data"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/AdvancedQueryMeta"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversionEventV2"
            }
          }
        }
      },
      "CampaignPerformanceQueryResponse": {
        "type": "object",
        "required": [
          "meta",
          "data"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/AdvancedQueryMeta"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CampaignPerformanceV2"
            }
          }
        }
      },
      "QueryCatalogField": {
        "type": "object",
        "required": [
          "field",
          "type",
          "operators",
          "sortable"
        ],
        "properties": {
          "field": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "operators": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sortable": {
            "type": "boolean"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "QueryCatalogDomain": {
        "type": "object",
        "required": [
          "domain",
          "endpoint",
          "description",
          "fields",
          "example"
        ],
        "properties": {
          "domain": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QueryCatalogField"
            }
          },
          "example": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "security": [],
        "responses": {
          "200": {
            "description": "Health check"
          }
        }
      }
    },
    "/v1/clients": {
      "get": {
        "responses": {
          "200": {
            "description": "Clients list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Client"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/contacts": {
      "get": {
        "responses": {
          "200": {
            "description": "Contacts list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Contact"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2/contacts": {
      "get": {
        "parameters": [
          {
            "name": "clientId",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "stage",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "assignedUserId",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "leadStartDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "leadEndDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "updatedStartDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "updatedEndDate",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "utmSource",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "utmCampaign",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sourceApp",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "hasEmail",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "hasPhone",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "hasMessage",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "withTasks",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "withConversions",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "includeRaw",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "includeHistory",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rich contacts list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ContactV2"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2/contacts/{contactId}": {
      "get": {
        "parameters": [
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "includeRaw",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "includeHistory",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rich contact detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactV2Detail"
                }
              }
            }
          },
          "404": {
            "description": "Contact not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v2/clients": {
      "get": {
        "responses": {
          "200": {
            "description": "Rich clients list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientV2"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2/clients/{clientId}": {
      "get": {
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rich client detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientV2Detail"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks": {
      "get": {
        "responses": {
          "200": {
            "description": "Tasks list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Task"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTaskRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created task",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          }
        }
      }
    },
    "/v2/tasks": {
      "get": {
        "responses": {
          "200": {
            "description": "Rich tasks list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskV2"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2/tasks/{taskId}": {
      "get": {
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rich task detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskV2Detail"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/{taskId}/status": {
      "patch": {
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTaskStatusRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated task status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string"
                    },
                    "completedAt": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2/conversions": {
      "get": {
        "responses": {
          "200": {
            "description": "Rich conversions list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ConversionEventV2"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v2/conversions/{conversionId}": {
      "get": {
        "parameters": [
          {
            "name": "conversionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rich conversion detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversionEventV2Detail"
                }
              }
            }
          }
        }
      }
    },
    "/v1/contacts/{contactId}/assignee": {
      "patch": {
        "parameters": [
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignContactRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated contact assignee"
          }
        }
      }
    },
    "/v2/metrics/campaign-performance": {
      "get": {
        "responses": {
          "200": {
            "description": "Campaign performance rows from Meta and Google",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CampaignPerformanceV2"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/clients/{clientId}/management-notes": {
      "post": {
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateManagementNoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created management note"
          }
        }
      }
    },
    "/v1/contacts/{contactId}/conversion-events": {
      "post": {
        "parameters": [
          {
            "name": "contactId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateConversionEventRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created conversion event"
          }
        }
      }
    },
    "/v1/conversions": {
      "get": {
        "responses": {
          "200": {
            "description": "Conversion events list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ConversionEvent"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/metrics/clients/daily": {
      "get": {
        "responses": {
          "200": {
            "description": "Client metrics daily aggregate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ClientMetricDaily"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/metrics/traffic-manager/funnel-summary": {
      "get": {
        "parameters": [
          {
            "name": "clientId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "utmSource",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "utmCampaign",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "utmMedium",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "utmContent",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "utmTerm",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "stage",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "assignedUserId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "city",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "eventStartDate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "eventEndDate",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "breakdownBy",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Traffic manager funnel summary for a lead cohort",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrafficManagerFunnelSummaryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/query/traffic-manager/funnel-summary": {
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TrafficManagerFunnelQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced traffic manager funnel query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrafficManagerFunnelSummaryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/query/clients": {
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdvancedQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced clients query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientQueryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/query/contacts": {
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdvancedQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced contacts query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactQueryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/query/tasks": {
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdvancedQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced tasks query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskQueryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/query/conversions": {
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdvancedQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced conversions query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversionQueryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/query/metrics/campaign-performance": {
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdvancedQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced campaign performance query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CampaignPerformanceQueryResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/query/catalog": {
      "get": {
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "clients",
                "contacts",
                "tasks",
                "conversions",
                "campaignPerformance",
                "campaign-performance"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog of advanced query fields by domain",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/QueryCatalogDomain"
                    },
                    {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/QueryCatalogDomain"
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}