# V2 # Queries ## Get queries `client.BrandProtection.V2.Queries.Get(ctx, params) (*[]V2QueryGetResponse, error)` **get** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/queries` Get all saved brand protection queries for an account ### Parameters - `params V2QueryGetParams` - `AccountID param.Field[string]` Path param - `ID param.Field[string]` Query param ### Returns - `type V2QueryGetResponse []V2QueryGetResponse` - `Created string` - `Parameters V2QueryGetResponseParameters` - `StringMatches []V2QueryGetResponseParametersStringMatch` - `MaxEditDistance float64` - `Pattern string` - `MaxTime string` - `MinTime string` - `QueryID int64` - `QueryTag string` - `Scan bool` - `Updated string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/brand_protection" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) queries, err := client.BrandProtection.V2.Queries.Get(context.TODO(), brand_protection.V2QueryGetParams{ AccountID: cloudflare.F("x"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", 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" } ] ``` # Matches ## List saved query matches `client.BrandProtection.V2.Matches.Get(ctx, params) (*V2MatchGetResponse, error)` **get** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/domain/matches` Get paginated list of domain matches for a specific brand protection query ### Parameters - `params V2MatchGetParams` - `AccountID param.Field[string]` Path param - `QueryID param.Field[string]` Query param - `IncludeDismissed param.Field[string]` Query param - `IncludeDomainID param.Field[string]` Query param - `Limit param.Field[string]` Query param - `Offset param.Field[string]` Query param - `Order param.Field[V2MatchGetParamsOrder]` Query param: Sort order. Options: 'asc' (ascending) or 'desc' (descending) - `const V2MatchGetParamsOrderAsc V2MatchGetParamsOrder = "asc"` - `const V2MatchGetParamsOrderDesc V2MatchGetParamsOrder = "desc"` - `OrderBy param.Field[V2MatchGetParamsOrderBy]` Query param: Column to sort by. Options: 'domain' or 'first_seen' - `const V2MatchGetParamsOrderByDomain V2MatchGetParamsOrderBy = "domain"` - `const V2MatchGetParamsOrderByFirstSeen V2MatchGetParamsOrderBy = "first_seen"` ### Returns - `type V2MatchGetResponse struct{…}` - `Matches []V2MatchGetResponseMatch` - `Dismissed bool` - `Domain string` - `FirstSeen string` - `PublicScans V2MatchGetResponseMatchesPublicScans` - `SubmissionID string` - `ScanStatus string` - `ScanSubmissionID int64` - `Source string` - `Total int64` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/brand_protection" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) match, err := client.BrandProtection.V2.Matches.Get(context.TODO(), brand_protection.V2MatchGetParams{ AccountID: cloudflare.F("x"), QueryID: cloudflare.F("x"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", 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 } ``` # Logos ## Insert logo query `client.BrandProtection.V2.Logos.New(ctx, params) (*V2LogoNewResponse, error)` **post** `/accounts/{account_id}/cloudforce-one/v2/brand-protection/logo/queries` Create a new saved brand protection logo query for visual similarity matching ### Parameters - `params V2LogoNewParams` - `AccountID param.Field[string]` Path param - `ImageData param.Field[string]` Body param: Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string. - `SimilarityThreshold param.Field[float64]` Body param: Minimum similarity score (0-1) required for visual matches - `Tag param.Field[string]` Body param: Unique identifier for the logo query - `SearchLookback param.Field[bool]` Body param: If true, search historic scanned images for matches above the similarity threshold ### Returns - `type V2LogoNewResponse struct{…}` - `Message string` - `Success bool` - `QueryID int64` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/brand_protection" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) logo, err := client.BrandProtection.V2.Logos.New(context.TODO(), brand_protection.V2LogoNewParams{ AccountID: cloudflare.F("x"), ImageData: cloudflare.F("x"), SimilarityThreshold: cloudflare.F(0.000000), Tag: cloudflare.F("x"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", logo.QueryID) } ``` #### Response ```json { "message": "message", "success": true, "query_id": 0 } ``` ## Delete logo query `client.BrandProtection.V2.Logos.Delete(ctx, queryID, body) (*V2LogoDeleteResponse, error)` **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 - `queryID string` - `body V2LogoDeleteParams` - `AccountID param.Field[string]` ### Returns - `type V2LogoDeleteResponse struct{…}` - `Message string` - `Success bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/brand_protection" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) logo, err := client.BrandProtection.V2.Logos.Delete( context.TODO(), "x", brand_protection.V2LogoDeleteParams{ AccountID: cloudflare.F("x"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", logo.Message) } ``` #### Response ```json { "message": "message", "success": true } ``` ## Get logo queries `client.BrandProtection.V2.Logos.Get(ctx, params) (*[]V2LogoGetResponse, error)` **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 - `params V2LogoGetParams` - `AccountID param.Field[string]` Path param - `ID param.Field[string]` Query param: Optional query ID to retrieve a specific logo query - `Download param.Field[string]` Query param: If true, include base64-encoded image data in the response ### Returns - `type V2LogoGetResponse []V2LogoGetResponse` - `ID int64` - `R2Path string` - `SimilarityThreshold float64` - `Tag string` - `UploadedAt string` - `ContentType string` MIME type of the image (only present when download=true) - `ImageData string` Base64-encoded image data (only present when download=true) ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/brand_protection" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) logos, err := client.BrandProtection.V2.Logos.Get(context.TODO(), brand_protection.V2LogoGetParams{ AccountID: cloudflare.F("x"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", 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" } ] ``` # Logo Matches ## List logo matches `client.BrandProtection.V2.LogoMatches.Get(ctx, params) (*V2LogoMatchGetResponse, error)` **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 - `params V2LogoMatchGetParams` - `AccountID param.Field[string]` Path param - `QueryID param.Field[string]` Query param - `Download param.Field[string]` Query param - `Limit param.Field[string]` Query param - `Offset param.Field[string]` Query param - `Order param.Field[V2LogoMatchGetParamsOrder]` Query param: Sort order. Options: 'asc' (ascending) or 'desc' (descending) - `const V2LogoMatchGetParamsOrderAsc V2LogoMatchGetParamsOrder = "asc"` - `const V2LogoMatchGetParamsOrderDesc V2LogoMatchGetParamsOrder = "desc"` - `OrderBy param.Field[V2LogoMatchGetParamsOrderBy]` Query param: Column to sort by. Options: 'matchedAt', 'domain', or 'similarityScore' - `const V2LogoMatchGetParamsOrderByMatchedAt V2LogoMatchGetParamsOrderBy = "matchedAt"` - `const V2LogoMatchGetParamsOrderByDomain V2LogoMatchGetParamsOrderBy = "domain"` - `const V2LogoMatchGetParamsOrderBySimilarityScore V2LogoMatchGetParamsOrderBy = "similarityScore"` ### Returns - `type V2LogoMatchGetResponse struct{…}` - `Matches []V2LogoMatchGetResponseMatch` - `ID int64` - `MatchedAt string` - `QueryID int64` - `SimilarityScore float64` - `URLScanID string` - `ContentType string` - `Domain string` - `ImageData string` - `Total int64` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/brand_protection" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) logoMatch, err := client.BrandProtection.V2.LogoMatches.Get(context.TODO(), brand_protection.V2LogoMatchGetParams{ AccountID: cloudflare.F("x"), QueryID: cloudflare.F("x"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", logoMatch.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 } ```