# V2 # Queries ## Get queries `brand_protection.v2.queries.get(QueryGetParams**kwargs) -> QueryGetResponse` **get** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/queries` Get all saved brand protection queries for an account ### Parameters - `account_id: str` - `id: Optional[str]` ### Returns - `List[QueryGetResponseItem]` - `created: str` - `parameters: Optional[QueryGetResponseItemParameters]` - `string_matches: List[QueryGetResponseItemParametersStringMatch]` - `max_edit_distance: float` - `pattern: str` - `max_time: Optional[str]` - `min_time: Optional[str]` - `query_id: int` - `query_tag: str` - `scan: bool` - `updated: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) queries = client.brand_protection.v2.queries.get( account_id="x", ) print(queries) ``` #### Response ```json [ { "created": "created", "parameters": { "string_matches": [ { "max_edit_distance": 0, "pattern": "x" } ], "max_time": "max_time", "min_time": "min_time" }, "query_id": 0, "query_tag": "query_tag", "scan": true, "updated": "updated" } ] ``` ## Domain Types ### Query Get Response - `List[QueryGetResponseItem]` - `created: str` - `parameters: Optional[QueryGetResponseItemParameters]` - `string_matches: List[QueryGetResponseItemParametersStringMatch]` - `max_edit_distance: float` - `pattern: str` - `max_time: Optional[str]` - `min_time: Optional[str]` - `query_id: int` - `query_tag: str` - `scan: bool` - `updated: str` # Matches ## List saved query matches `brand_protection.v2.matches.get(MatchGetParams**kwargs) -> MatchGetResponse` **get** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/matches` Get paginated list of domain matches for a specific brand protection query ### Parameters - `account_id: str` - `query_id: str` - `include_dismissed: Optional[str]` - `include_domain_id: Optional[str]` - `limit: Optional[str]` - `offset: Optional[str]` - `order: Optional[Literal["asc", "desc"]]` Sort order. Options: 'asc' (ascending) or 'desc' (descending) - `"asc"` - `"desc"` - `order_by: Optional[Literal["domain", "first_seen"]]` Column to sort by. Options: 'domain' or 'first_seen' - `"domain"` - `"first_seen"` ### Returns - `class MatchGetResponse: …` - `matches: List[Match]` - `dismissed: bool` - `domain: str` - `first_seen: str` - `public_scans: Optional[MatchPublicScans]` - `submission_id: str` - `scan_status: str` - `scan_submission_id: Optional[int]` - `source: Optional[str]` - `total: int` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) match = client.brand_protection.v2.matches.get( account_id="x", query_id="x", ) print(match.matches) ``` #### Response ```json { "matches": [ { "dismissed": true, "domain": "domain", "first_seen": "first_seen", "public_scans": { "submission_id": "submission_id" }, "scan_status": "scan_status", "scan_submission_id": 0, "source": "source" } ], "total": 0 } ``` ## Domain Types ### Match Get Response - `class MatchGetResponse: …` - `matches: List[Match]` - `dismissed: bool` - `domain: str` - `first_seen: str` - `public_scans: Optional[MatchPublicScans]` - `submission_id: str` - `scan_status: str` - `scan_submission_id: Optional[int]` - `source: Optional[str]` - `total: int` # Logos ## Insert logo query `brand_protection.v2.logos.create(LogoCreateParams**kwargs) -> LogoCreateResponse` **post** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries` Create a new saved brand protection logo query for visual similarity matching ### Parameters - `account_id: str` - `image_data: str` Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string. - `similarity_threshold: float` Minimum similarity score (0-1) required for visual matches - `tag: str` Unique identifier for the logo query - `search_lookback: Optional[bool]` If true, search historic scanned images for matches above the similarity threshold ### Returns - `class LogoCreateResponse: …` - `message: str` - `success: bool` - `query_id: Optional[int]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) logo = client.brand_protection.v2.logos.create( account_id="x", image_data="x", similarity_threshold=0, tag="x", ) print(logo.query_id) ``` #### Response ```json { "message": "message", "success": true, "query_id": 0 } ``` ## Delete logo query `brand_protection.v2.logos.delete(strquery_id, LogoDeleteParams**kwargs) -> LogoDeleteResponse` **delete** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries/{query_id}` Delete a saved brand protection logo query. Returns 404 if the query ID doesn't exist. ### Parameters - `account_id: str` - `query_id: str` ### Returns - `class LogoDeleteResponse: …` - `message: str` - `success: bool` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) logo = client.brand_protection.v2.logos.delete( query_id="x", account_id="x", ) print(logo.message) ``` #### Response ```json { "message": "message", "success": true } ``` ## Get logo queries `brand_protection.v2.logos.get(LogoGetParams**kwargs) -> LogoGetResponse` **get** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries` Get all saved brand protection logo queries for an account. Optionally specify id to get a single query. Set download=true to include base64-encoded image data. ### Parameters - `account_id: str` - `id: Optional[str]` Optional query ID to retrieve a specific logo query - `download: Optional[str]` If true, include base64-encoded image data in the response ### Returns - `List[LogoGetResponseItem]` - `id: int` - `r2_path: str` - `similarity_threshold: float` - `tag: str` - `uploaded_at: Optional[str]` - `content_type: Optional[str]` MIME type of the image (only present when download=true) - `image_data: Optional[str]` Base64-encoded image data (only present when download=true) ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) logos = client.brand_protection.v2.logos.get( account_id="x", ) print(logos) ``` #### Response ```json [ { "id": 0, "r2_path": "r2_path", "similarity_threshold": 0, "tag": "tag", "uploaded_at": "uploaded_at", "content_type": "content_type", "image_data": "image_data" } ] ``` ## Domain Types ### Logo Create Response - `class LogoCreateResponse: …` - `message: str` - `success: bool` - `query_id: Optional[int]` ### Logo Delete Response - `class LogoDeleteResponse: …` - `message: str` - `success: bool` ### Logo Get Response - `List[LogoGetResponseItem]` - `id: int` - `r2_path: str` - `similarity_threshold: float` - `tag: str` - `uploaded_at: Optional[str]` - `content_type: Optional[str]` MIME type of the image (only present when download=true) - `image_data: Optional[str]` Base64-encoded image data (only present when download=true) # Logo Matches ## List logo matches `brand_protection.v2.logo_matches.get(LogoMatchGetParams**kwargs) -> LogoMatchGetResponse` **get** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/matches` Get paginated list of logo matches for a specific brand protection logo query ### Parameters - `account_id: str` - `query_id: str` - `download: Optional[str]` - `limit: Optional[str]` - `offset: Optional[str]` - `order: Optional[Literal["asc", "desc"]]` Sort order. Options: 'asc' (ascending) or 'desc' (descending) - `"asc"` - `"desc"` - `order_by: Optional[Literal["matchedAt", "domain", "similarityScore"]]` Column to sort by. Options: 'matchedAt', 'domain', or 'similarityScore' - `"matchedAt"` - `"domain"` - `"similarityScore"` ### Returns - `class LogoMatchGetResponse: …` - `matches: List[Match]` - `id: int` - `matched_at: Optional[str]` - `query_id: int` - `similarity_score: float` - `url_scan_id: Optional[str]` - `content_type: Optional[str]` - `domain: Optional[str]` - `image_data: Optional[str]` - `total: int` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) logo_match = client.brand_protection.v2.logo_matches.get( account_id="x", query_id="x", ) print(logo_match.matches) ``` #### Response ```json { "matches": [ { "id": 0, "matched_at": "matched_at", "query_id": 0, "similarity_score": 0, "url_scan_id": "url_scan_id", "content_type": "content_type", "domain": "domain", "image_data": "image_data" } ], "total": 0 } ``` ## Domain Types ### Logo Match Get Response - `class LogoMatchGetResponse: …` - `matches: List[Match]` - `id: int` - `matched_at: Optional[str]` - `query_id: int` - `similarity_score: float` - `url_scan_id: Optional[str]` - `content_type: Optional[str]` - `domain: Optional[str]` - `image_data: Optional[str]` - `total: int`