/*
* Zernio API
*
* API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
*
* The version of the OpenAPI document: 1.522.0
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`add_ad_keywords`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddAdKeywordsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`apply_google_recommendations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApplyGoogleRecommendationsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`attach_ad_group_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AttachAdGroupAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`attach_campaign_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AttachCampaignAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`boost_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BoostPostError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(),
Status422(),
Status429(models::ErrorResponse),
Status503(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`bulk_update_ad_campaign_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BulkUpdateAdCampaignStatusError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_ad_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAdCampaignError {
Status400(),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_ad_set`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAdSetError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_bid_strategy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBidStrategyError {
Status400(),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_google_asset_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateGoogleAssetGroupError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_shared_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateSharedBudgetError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_standalone_ad`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateStandaloneAdError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
Status429(models::ErrorResponse),
Status501(),
Status502(),
Status503(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_ad`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAdError {
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_ad_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAdCampaignError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_ad_set`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAdSetError {
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dismiss_ads_alert`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DismissAdsAlertError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status503(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`dismiss_google_recommendations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DismissGoogleRecommendationsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`duplicate_ad`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DuplicateAdError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status409(),
Status429(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`duplicate_ad_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DuplicateAdCampaignError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`duplicate_ad_set`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DuplicateAdSetError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`edit_google_asset_group_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EditGoogleAssetGroupAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad_campaign_details`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdCampaignDetailsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad_review`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdReviewError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(),
Status429(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad_set_details`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdSetDetailsError {
Status400(),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad_set_targeting`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdSetTargetingError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad_tree`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdTreeError {
Status401(models::ErrorResponse),
Status403(),
Status429(models::InlineObject3),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ads_timeline`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdsTimelineError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status429(models::InlineObject3),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_ad_schedule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignAdScheduleError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_bidding`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignBiddingError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_conversion_goals`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignConversionGoalsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(),
Status409(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_targeting`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignTargetingError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_google_asset_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetGoogleAssetGroupError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_tik_tok_smart_plus_ad_review`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTikTokSmartPlusAdReviewError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(),
Status422(),
Status429(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_campaigns`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdCampaignsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(models::InlineObject3),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_group_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdGroupAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_keywords`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdKeywordsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_sets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdSetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ads`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status429(models::InlineObject3),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ads_alerts`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdsAlertsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status429(models::InlineObject3),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ads_by_performance`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdsByPerformanceError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status429(models::InlineObject3),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_bid_strategies`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListBidStrategiesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_negative_keyword_lists`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignNegativeKeywordListsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_negative_keywords`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignNegativeKeywordsError {
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_google_asset_groups`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListGoogleAssetGroupsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_google_recommendations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListGoogleRecommendationsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_shared_budgets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSharedBudgetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_tik_tok_smart_plus_reviews`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTikTokSmartPlusReviewsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
Status429(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_ad_group_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveAdGroupAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_ad_keyword`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveAdKeywordError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_campaign_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveCampaignAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_google_asset_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveGoogleAssetGroupError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`replace_campaign_negative_keyword_lists`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReplaceCampaignNegativeKeywordListsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`replace_campaign_negative_keywords`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReplaceCampaignNegativeKeywordsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`replace_google_listing_group_filters`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReplaceGoogleListingGroupFiltersError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status422(),
Status429(),
Status501(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdCampaignError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_campaign_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdCampaignStatusError {
Status400(),
Status401(),
Status403(),
Status404(),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_group_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdGroupAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_keyword`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdKeywordError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_set`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdSetError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status409(),
Status422(),
Status501(),
Status502(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_set_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdSetStatusError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdStatusError {
Status400(),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_bid_strategy`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateBidStrategyError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_campaign_ad_schedule`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCampaignAdScheduleError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status422(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_campaign_assets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCampaignAssetsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_campaign_conversion_goals`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCampaignConversionGoalsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(),
Status409(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_campaign_targeting`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCampaignTargetingError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status501(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_google_asset_group`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateGoogleAssetGroupError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::InlineObject1),
Status422(),
Status429(),
Status501(),
UnknownValue(serde_json::Value),
}
/// Adds keywords, or negative keywords, to a Google Search ad group without replacing the ones already there. Adds one or more keyword criteria to an existing Google Search ad group, without touching the keywords already there (unlike the whole-set diff on `PUT /v1/ads/{adId}`, `keywords`/`negativeKeywords` in `platformSpecificData`, which replaces the set). Set `negative: true` to add ad-group-level negatives instead of positive keywords.
pub async fn add_ad_keywords(
configuration: &configuration::Configuration,
add_ad_keywords_request: models::AddAdKeywordsRequest,
) -> Result<models::AddAdKeywords201Response, Error<AddAdKeywordsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_add_ad_keywords_request = add_ad_keywords_request;
let uri_str = format!("{}/v1/ads/keywords", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_add_ad_keywords_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddAdKeywords201Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AddAdKeywords201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddAdKeywordsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Applies Google's optimization suggestions to an ad account, using Google's values or your own; the changes cannot be undone. Apply up to 100 recommendations. This changes the account (budgets, bidding, keywords, assets) and is not reversible or idempotent. Google offers no validate-only mode for it. Items run in partial-failure mode, so one stale recommendation does not block the rest. ### `parameters` Optional. It takes exactly one key named for the recommendation type, in Google's ApplyRecommendationOperation shape. For example: - `campaignBudget: { newBudgetAmountMicros }` - `keyword: { matchType, cpcBidMicros }` Omit it to apply Google's suggested values.
pub async fn apply_google_recommendations(
configuration: &configuration::Configuration,
apply_google_recommendations_request: models::ApplyGoogleRecommendationsRequest,
) -> Result<models::ApplyGoogleRecommendations200Response, Error<ApplyGoogleRecommendationsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_apply_google_recommendations_request = apply_google_recommendations_request;
let uri_str = format!("{}/v1/ads/recommendations/apply", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_apply_google_recommendations_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApplyGoogleRecommendations200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApplyGoogleRecommendations200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ApplyGoogleRecommendationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates sitelinks, callouts, structured snippets or image assets and attaches them to a Google ad group in one step. Creates and attaches sitelinks, callouts, structured snippets and image assets in one Google mutation. Google shows images only on accounts it deems eligible (account age, policy history, vertical).
pub async fn attach_ad_group_assets(
configuration: &configuration::Configuration,
ad_set_id: &str,
attach_campaign_assets_request: models::AttachCampaignAssetsRequest,
) -> Result<models::AttachAdGroupAssets201Response, Error<AttachAdGroupAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_body_attach_campaign_assets_request = attach_campaign_assets_request;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}/assets",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_attach_campaign_assets_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachAdGroupAssets201Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AttachAdGroupAssets201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AttachAdGroupAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Adds sitelinks, callouts, structured snippets and images to a Google campaign in one step. Creates and attaches sitelinks, callouts, structured snippets and image assets in one Google mutation. Google shows images only on accounts it deems eligible (account age, policy history, vertical).
pub async fn attach_campaign_assets(
configuration: &configuration::Configuration,
campaign_id: &str,
attach_campaign_assets_request: models::AttachCampaignAssetsRequest,
) -> Result<models::AttachCampaignAssets201Response, Error<AttachCampaignAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_attach_campaign_assets_request = attach_campaign_assets_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/assets",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_attach_campaign_assets_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AttachCampaignAssets201Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AttachCampaignAssets201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AttachCampaignAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Turns an already published post into a paid ad that keeps the post's likes and comments, creating the campaign around it. By default it provisions the whole hierarchy (campaign, ad set, ad). ### Attach shape (Meta) Send `adSetId` to put the ad under an EXISTING ad set instead, so that ad set keeps its learning phase. That ad set then owns `budget`, `schedule` and `targeting`. Sending any of those alongside `adSetId` is a 400 rather than a silent drop. `budget` is required only without `adSetId`. `instagramAccountId`, `destinationType`, `whatsappPhoneNumber` and `adSetId` are Meta-only and return 400 on other platforms. ### Meta accounts `accountId` may be a Facebook, Instagram or Meta ads (business login) connection. A business-login connection has no posting account, so pass the post as `platformPostId` (Facebook `pageId_postId` or an Instagram media id). A Zernio `postId` is a 400 there. ### X `accountId` may be the posting X account or its X Ads connection: either resolves the other on the same profile. A Zernio `postId` on an X Ads connection resolves through its X account, and is a 400 when the profile has none (pass `platformPostId` instead). ### Reddit `accountId` is the Reddit Ads connection (platform `redditads`). Pass the Reddit post as either: - `platformPostId` (`t3_abc123` or the bare id) - a Zernio `postId`, which resolves through the Reddit account connected on the same profile (400 when there is none) Reddit promotes only posts made by a profile of the ad account: a post by any other author returns 422. Goals: - traffic - awareness - conversions - video_views (the post must be a video, 422 otherwise) - lead_generation conversions and lead_generation need a pixel that already received the event (see `promotedObject`). `leadGenFormId` returns 400: Reddit retired its native lead forms, so `lead_generation` sends people to `linkUrl` and optimizes toward the pixel's Lead event. Each boost creates a campaign, an ad group carrying the budget, the targeting and the bid, and the ad. `bidStrategy` sets the ad group's bid: - LOWEST_COST_WITHOUT_CAP (or omitted): automatic bidding (BIDLESS) - LOWEST_COST_WITH_BID_CAP: MANUAL_BIDDING with `bidAmount` as the bid - COST_CAP: MAXIMIZE_VOLUME with `bidAmount` as the cap - Any other strategy returns 422 before anything is created. ### Messaging boosts (Meta) Use `goal: engagement` with one of these CTAs: - `callToAction: WHATSAPP_MESSAGE`: implies WHATSAPP - `MESSAGE_PAGE`: implies MESSENGER - `INSTAGRAM_MESSAGE`: implies INSTAGRAM_DIRECT `destinationType` alone does not select a messaging CTA. Omit `linkUrl` only for messaging CTAs. Plain link CTAs keep their goal and link behavior when combined with an independent `destinationType`. The campaign uses OUTCOME_ENGAGEMENT and the ad set uses CONVERSATIONS with the promoted Page. Optional `whatsappPhoneNumber` selects a number already paired with that Page. Conflicting CTA/destination, instant form, goal, or optimizationGoal inputs return 400. Attach requires the target ad set destination to match. Existing post references preserve social proof. An Instagram reel rejected by Meta is not re-uploaded as a new post for a messaging boost. ### Retries Boosts are NOT idempotent and can take minutes when Meta requires re-hosting an Instagram video, so do not retry on client timeout. Send an Idempotency-Key header to make retries safe: same key and body replays the original 201, and distinct keys always create distinct ads. Without the header, an identical request is treated as a retry: - While one is in flight it returns 409. - Within 10 minutes of a completed boost it returns the already-created ad instead of creating another. To intentionally duplicate an ad, send distinct Idempotency-Keys (or vary the body, e.g. the name).
pub async fn boost_post(
configuration: &configuration::Configuration,
boost_post_request: models::BoostPostRequest,
idempotency_key: Option<&str>,
) -> Result<models::BoostPost200Response, Error<BoostPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_boost_post_request = boost_post_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!("{}/v1/ads/boost", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_boost_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BoostPost200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BoostPost200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BoostPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Pauses or resumes up to 50 campaigns in one call, with a separate result per campaign so one failure does not block the rest. Each campaign is updated concurrently, and the response contains a per-campaign result so a single bad row does not fail the whole batch. Each campaign is read, written and re-read exactly as PUT /v1/ads/campaigns/{campaignId}/status describes: only the campaign's own switch is written, never its ad sets' or ads'. `updated` / `skipped` count campaigns.
pub async fn bulk_update_ad_campaign_status(
configuration: &configuration::Configuration,
bulk_update_ad_campaign_status_request: models::BulkUpdateAdCampaignStatusRequest,
) -> Result<models::BulkUpdateAdCampaignStatus200Response, Error<BulkUpdateAdCampaignStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_bulk_update_ad_campaign_status_request = bulk_update_ad_campaign_status_request;
let uri_str = format!("{}/v1/ads/campaigns/bulk-status", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_bulk_update_ad_campaign_status_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkUpdateAdCampaignStatus200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::BulkUpdateAdCampaignStatus200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BulkUpdateAdCampaignStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates an empty campaign, paused, so you can add ad sets and ads to it afterwards. Creates a campaign WITHOUT its first ad set / ad, on the platform of the given `accountId`. Ad sets join it later via `existingCampaignId` on the create endpoints. Created `PAUSED` (TikTok `DISABLE`) unless `status: ACTIVE` where the platform supports it. **Idempotency:** send an `Idempotency-Key` header to make retries safe. ### Field support - `specialAdCategories`: Meta-only (400 elsewhere). - `bidStrategy`: Meta and Google (400 elsewhere). Google also accepts `portfolioBidStrategyId` instead. - Budget: Google, X and OpenAI require one (422 without one). OpenAI accepts daily or lifetime, Google only `budgetType: daily`. ### Platform notes - Meta: a budget here is campaign-level (CBO) by definition. Omit it for ABO (each ad set carries its own budget). - OpenAI: `goal` sets the campaign objective, and `conversions` needs an active standard conversion event on the account. - Reddit: see below. - LinkedIn: creates the campaign GROUP (our campaign level) and rejects a budget, which lives on the campaign (ad set) level there. It comes back `status: DRAFT`. ### Reddit `goal` is one of traffic, awareness, conversions, video_views or lead_generation (422 otherwise). The budget is optional. - With a budget, the campaign uses Reddit's campaign budget optimization and carries the pixel (see `promotedObject`, which then needs `customEventType` for `conversions`). The budget is daily or lifetime; a lifetime budget needs `endDate` (400 otherwise). - `startDate` / `endDate` set the campaign's schedule and need that campaign budget (400 without one). - Without a budget, each ad set carries its own budget and dates.
pub async fn create_ad_campaign(
configuration: &configuration::Configuration,
create_ad_campaign_request: models::CreateAdCampaignRequest,
idempotency_key: Option<&str>,
) -> Result<models::CreateAdCampaign200Response, Error<CreateAdCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_ad_campaign_request = create_ad_campaign_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!("{}/v1/ads/campaigns", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_ad_campaign_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCampaign200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateAdCampaign200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAdCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates an empty ad group under an existing campaign, ready for ads to be added later. The ad group is created WITHOUT an ad (Google Ads compliance row C.190). Ads join it later via `adSetId` on POST /v1/ads/create. Supports Google Ads and Reddit Ads; every other platform returns 501. **Google Ads** (`platform: google`) - The ad group type follows the campaign: a standard ad group under a Search or Display campaign, a Demand Gen ad group under a Demand Gen campaign. - On a Demand Gen campaign the ad group is always created PAUSED, and `maxCpc` or `status: ACTIVE` returns 400 (Demand Gen bids at the campaign). - `targeting` sets a Demand Gen ad group's locations and languages (`countries`, `regions`, `cities`, `zips`, `metros`, `languages`), created atomically with the ad group. Without it the ad group serves worldwide. - `targeting` returns 400 for any other targeting field, and on campaigns that keep geo on the campaign: Search, Display, and Demand Gen campaigns migrated from Discovery. Edit those with PUT /v1/ads/campaigns/{campaignId}/targeting. - Any other campaign type returns 400 (Performance Max has asset groups instead of ad groups). - A campaign that is not in the ad account, or was removed, returns 404. **Reddit Ads** (`platform: reddit`) - `adAccountId` (the Reddit ad account id) is required and must be a selected ad account of the connection (403 otherwise). - When the campaign has no campaign budget, send `budgetAmount` + `budgetType` (a lifetime budget needs `endDate`). - The ad group is optimized for the campaign's objective. `promotedObject.customEventType` is required on a conversions campaign, and the pixel must have received that event, else 422. - It bids with `bidStrategy`/`bidAmount` like POST /v1/ads/create. - Under campaign budget optimization the ad group takes the campaign's bid, goal type, optimization event and pixel, and bid fields return 400. - The ad group must start no earlier than a future campaign start and end no later than the campaign end (400 otherwise). - `targeting` takes the same targeting object as the other ad endpoints (no geo defaults to the US). - A campaign of another ad account returns 404, a Reddit Max campaign 422. - `maxCpc` and `customerId` are Google only (400 on Reddit), and the other Reddit fields return 400 on Google. ### After creation Created `PAUSED` unless `status: ACTIVE`. The new ad group has no ad yet, so it will not appear in GET /v1/ads/tree (built purely from `ads` rows) until one is added. Use GET /v1/ads/ad-sets to see it in the meantime. It can be read, edited and deleted through `/v1/ads/ad-sets/{adSetId}` right away (targeting, schedule, name, `status`, `budget` and bid fields). A budget on an ad group that spends its campaign budget returns 422. **Idempotency:** send an `Idempotency-Key` header to make retries safe.
pub async fn create_ad_set(
configuration: &configuration::Configuration,
create_ad_set_request: models::CreateAdSetRequest,
idempotency_key: Option<&str>,
) -> Result<models::CreateAdSet201Response, Error<CreateAdSetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_ad_set_request = create_ad_set_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!("{}/v1/ads/ad-sets", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_ad_set_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdSet201Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateAdSet201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAdSetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a Google Ads bid strategy that several campaigns can share, such as one target CPA or ROAS. Attach it to a campaign with `portfolioBidStrategyId` on POST /v1/ads/create, PUT /v1/ads/campaigns/{campaignId}, or PUT /v1/ads/ad-sets/{adSetId}. Attaching a strategy aligned to a shared budget fails there with a 400 (Google's `BIDDING_STRATEGY_AND_BUDGET_MUST_BE_ALIGNED`); this is not retryable.
pub async fn create_bid_strategy(
configuration: &configuration::Configuration,
create_bid_strategy_request: models::CreateBidStrategyRequest,
) -> Result<models::CreateBidStrategy201Response, Error<CreateBidStrategyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_bid_strategy_request = create_bid_strategy_request;
let uri_str = format!("{}/v1/ads/bid-strategies", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_bid_strategy_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateBidStrategy201Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateBidStrategy201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBidStrategyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Adds an asset group with its assets and optional product targeting to a Performance Max campaign, or just validates it without creating anything. The group, any new assets, their links and an optional listing-group tree are created in one atomic request, so Google checks the asset minimums (for non-retail campaigns) against the whole set. Created PAUSED unless status is ENABLED. validateOnly: true runs Google's validation without creating anything. A campaign that is not Performance Max returns 400 on campaignId (add an ad group with POST /v1/ads/ad-sets instead). A missing or removed campaign returns 404.
pub async fn create_google_asset_group(
configuration: &configuration::Configuration,
campaign_id: &str,
create_google_asset_group_request: models::CreateGoogleAssetGroupRequest,
) -> Result<models::CreateGoogleAssetGroup200Response, Error<CreateGoogleAssetGroupError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_create_google_asset_group_request = create_google_asset_group_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/asset-groups",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_google_asset_group_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateGoogleAssetGroup200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateGoogleAssetGroup200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateGoogleAssetGroupError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a daily Google Ads budget that several campaigns can share. Creates a daily shared campaign budget (`explicitly_shared: true`, standard delivery) that several campaigns can draw from. A lifetime budget returns 422, like every Google budget. Google refuses some bidding strategies on a shared budget; that error surfaces when a campaign is moved onto it.
pub async fn create_shared_budget(
configuration: &configuration::Configuration,
create_shared_budget_request: models::CreateSharedBudgetRequest,
) -> Result<models::CreateSharedBudget201Response, Error<CreateSharedBudgetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_shared_budget_request = create_shared_budget_request;
let uri_str = format!("{}/v1/ads/shared-budgets", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_shared_budget_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateSharedBudget201Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateSharedBudget201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateSharedBudgetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a paid ad with your own creative, building the campaign and ad set it needs or adding it to existing ones. Works across Meta, Google Ads, Pinterest, TikTok, X, LinkedIn, OpenAI Ads (ChatGPT Ads), Reddit Ads and Microsoft Ads. Per-platform required fields, budget minimums, and video-ad rules are documented on each property below. ### Request shapes The body selects one of these mutually exclusive shapes: - Legacy single-creative shape (all platforms, the default). - Meta-only multi-creative shape via the creatives array: one ad set with N ads sharing budget and targeting. - Attach shape via adSetId: adds one new ad to an existing ad set, inheriting its budget, targeting, and schedule (Meta, Google Ads, TikTok, and LinkedIn). On LinkedIn, adSetId in the attach shape is the existing Campaign id, and the budget, schedule, targeting and bidding fields must be omitted. `goal` may be omitted too (taken from the Campaign's objective), and the created ad's `targeting` echoes the Campaign's audience. ### Google Performance Max Set `campaignType: \"pmax\"` and supply `assetGroup` with text, images by role, business name and finalUrl. This creates a daily budget, PAUSED campaign and asset group atomically. - `validateOnly: true` validates the complete request with Google without creating or persisting resources. - Read assets with `GET /v1/ads/campaigns/{campaignId}/asset-groups`. - The logo is required; video is optional via `assetGroup.youtubeVideoId`. - Brand guidelines are disabled at creation. - All supplied asset links are validated together against Google's minimum asset requirements. - PMax rejects ACTIVE creation, portfolio bidding, bid caps, legacy creative fields and attach shapes. - Geo and language targeting are supported; omitted geo targets all locations. - PMax does not require top-level goal, headline, body or linkUrl. Supported bidding: - Omitted or LOWEST_COST_WITHOUT_CAP: Maximize Conversions. - COST_CAP plus bidAmount: target CPA. - LOWEST_COST_WITH_MIN_ROAS plus roasAverageFloor: Maximize Conversion Value with target ROAS. ### Google Demand Gen Set `campaignType: \"demand_gen\"` and supply `demandGen`. One atomic request creates a daily budget, PAUSED campaign, one ad group and one ad. The ad is: - a multi-asset image ad by default; - a video responsive ad when `demandGen.youtubeVideoIds` is sent; - a carousel ad (2 to 10 cards) when `demandGen.carouselCards` is sent. Targeting and validation: - Geo (countries, regions, cities, zips, metros) and languages go on the ad group, as Demand Gen requires. - `demandGen.channels` sets the ad group's channel controls. - `demandGen.audience` builds a Google Audience (user lists, interests, custom audiences, age ranges, genders) attached to the ad group, or `demandGen.audienceId` attaches an existing one. - `validateOnly: true` validates everything with Google without creating resources. Supported bidding: - Omitted or LOWEST_COST_WITHOUT_CAP: Maximize Conversions. - COST_CAP plus bidAmount: target CPA. - LOWEST_COST_WITH_MIN_ROAS plus roasAverageFloor: target ROAS. - LOWEST_COST_WITH_BID_CAP plus bidAmount: target CPC. The created ad carries the native `platformCampaignId`, `platformAdSetId` (ad group) and `platformAdId`. After creation: - Activate with PUT /v1/ads/campaigns/{campaignId}/status. - Edit budget, bidding and name with the regular campaign endpoints. - Edit creative, channels, audience and ad group targeting with PUT /v1/ads/{adId} (`demandGen`, `targeting`). To grow an existing Demand Gen campaign, send one of these (neither takes budget, bidding or schedule fields; both support `validateOnly`): - `existingCampaignId`: adds a PAUSED ad group, with its own geo, languages, channels and audience, plus its ad. - `adSetId`: adds a PAUSED ad to that ad group. ### Meta creative options Meta accepts `creativeFeatures` on the single and attach shapes and as defaults for `creatives[]`; an item replaces the whole feature map. `promotion` is not supported on any shape, and any object is rejected with 400. Reusing `existingCreativeId` uses the existing creative settings instead of new settings. Requested settings are persisted for lists, exports, and default ad-detail reads. ### Meta required fields per shape A missing field is a 400 naming it in `param`. - Every shape that builds a new ad set (no `adSetId`, `existingCampaignId` or `buyingType: \"RESERVED\"`): `budgetAmount`. `budgetType` defaults to daily, and a lifetime budget without `endDate` ends 7 days after it starts (see `appliedDefaults`). - Single image or video (the default), also with `adSetId`: `headline` (max 255), `body`, `callToAction`, and exactly one of `imageUrl` / `video`. A catalog template creative takes none, and ignores and does not upload any sent. - Single image or video also needs `linkUrl`, unless the goal is `lead_generation` or `page_visits` or `leadGenFormId` is set. - `bodies[]` / `headlines[]` text variations: `body`, one list with 2+ items, `callToAction`, `imageUrl` or `video`, and `linkUrl` unless the goal is `lead_generation` or `leadGenFormId` is set. `headline` is not required. - `placementAssets`: `headline`, `body`, `callToAction`, and `linkUrl` with the same exemptions as the single shape; the media comes from `placementAssets`. - `carouselCards`: `body`, `callToAction`, and `linkUrl` unless the goal is `lead_generation` or `leadGenFormId` is set. `headline` is not required. - `creatives[]`: per entry `headline`, `body`, `callToAction`, `imageUrl` or `video`, and `linkUrl` unless the goal is `lead_generation`. Top-level `body` is not required. - `dynamicCreative`: `imageUrls` or `videoUrls`, `callToActionTypes`, and `linkUrls` unless the goal is `lead_generation`. Top-level `body` is not required. - `existingCreativeId`: no creative fields. - Goal `page_likes`: `body` only. - Goal `lead_generation` always needs `leadGenFormId`, except with `existingCreativeId`. ### Meta activation Meta builds the campaign, ad set and ads PAUSED and switches the requested levels to ACTIVE as the last step. When Meta refuses that switch, or the connection drops, after Zernio's retries, the request still answers 201 and nothing is deleted: - The refused level and every level below it stay PAUSED. - Levels above it that already went ACTIVE stay ACTIVE. - The ad comes back with `status: paused` and its `configuredStatus` as read back from Meta. - A switch Meta applied although its answer was lost counts as ACTIVE, since Zernio reads the status back first. `message` says not everything is ACTIVE. `warnings` carries one entry starting with `activation_failed:` that quotes Meta's code, subcode and message, and names what was kept PAUSED and what was switched ACTIVE. That warning also lists the calls that switch the PAUSED ones on later, in this order, with status `active`: 1. PUT /v1/ads/campaigns/{campaignId}/status 2. PUT /v1/ads/ad-sets/{adSetId}/status 3. PUT /v1/ads/{adId}/status On the `creatives[]` shape, only the ads Meta refused stay PAUSED when the campaign and ad set went through. A Reach and Frequency ad is created ACTIVE and is never listed as kept PAUSED. With an `Idempotency-Key`, a retry replays this 201. ### LinkedIn LinkedIn creates a Single Image or Single Video Ad backed by a Direct Sponsored Content \"dark post\" authored by a Company Page (see `organizationId`). - Supported goals: engagement, traffic, awareness, and video_views. - Video ads use the `video` field; video_views requires a video. - Traffic ads require `linkUrl`. ### Reddit Ads Use the `accountId` of a `redditads` connection and an `adAccountId` like `a2_abc123`. Zernio creates a campaign, an ad group carrying the budget, schedule, targeting and pixel, and an ad running a new promoted post. The post is authored by the ad account's first profile (422 when it has none). The creative format follows the body: - `carouselCards`: a carousel. - `video`: a video ad. - `imageUrl`: an image ad. - None of them: a text ad, which cannot link out (`linkUrl` is a 400 there; `body` is required). Only the legacy single-creative shape is available: `creatives[]`, `adSetId`, `existingCampaignId` and `validateOnly` are refused. Reddit throttling surfaces as 429 `rate_limited` with `platform: reddit`; retry after a delay. To promote an existing Reddit post, use POST /v1/ads/boost. ### Microsoft Ads Use the `accountId` of a `microsoftads` connection and its numeric `adAccountId`. Zernio creates a Search campaign carrying the daily budget and the countries, an ad group carrying the schedule, a responsive search ad and the `keywords`. - `goal` is `traffic`; `budgetType` must be `daily`. - `headline`, `body` and `linkUrl` are required. `additionalHeadlines` and `additionalDescriptions` complete the ad to 3 to 15 headlines (30 characters) and 2 to 4 descriptions (90 characters); missing ones are filled from `name` and the link's host. - `countries` (or `targeting.countries`) is required; no other targeting field applies. - Bid fields, `negativeKeywords`, `campaignNegativeKeywords`, sitelinks, callouts, structured snippets, `businessName`, `longHeadline` and a `campaignType` other than `search` return 422. Without `status`, every level is switched on and the campaign spends once Microsoft approves the ad: send `status: PAUSED` to create it paused. A failed step deletes the campaign the call created. ### Idempotency This endpoint is not idempotent at the platform level: a blind retry creates a second campaign/ad set/ad. Send an `Idempotency-Key` header to make retries safe. - The first request with a given key creates the ad and we store the response. - A retry with the same key replays that exact response (with `Idempotent-Replayed: true`) instead of creating duplicates. - Reusing a key with a different body returns 422. - A key whose first request is still in flight returns 409 (retry after a short backoff). - If the first request is cut off mid-create (for example by a function timeout), its key can stay in progress and keep returning 409 until it expires. Use a new key to retry sooner, after checking whether the ad was created. - Keys are scoped to your credential and expire after 24h.
pub async fn create_standalone_ad(
configuration: &configuration::Configuration,
create_standalone_ad_request: models::CreateStandaloneAdRequest,
idempotency_key: Option<&str>,
) -> Result<models::CreateStandaloneAd200Response, Error<CreateStandaloneAdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_standalone_ad_request = create_standalone_ad_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!("{}/v1/ads/create", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_standalone_ad_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateStandaloneAd200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateStandaloneAd200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateStandaloneAdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes an ad on the platform while keeping its history, and removes empty parents only when they were created through this API. The ad is deleted on the platform and marked as cancelled in the database. It is preserved for history. - OpenAI Ads has no delete API: the ad is archived instead (a terminal state, the closest equivalent). - Reddit Ads has no delete either: the ad is archived (`configured_status` ARCHIVED). To delete a whole campaign on purpose use `DELETE /v1/ads/campaigns/{campaignId}`. ### Parents Only the ad is deleted; a campaign or ad set is never deleted while it still holds another ad. Parents created outside Zernio, and the parents of an ad imported from the platform, are always kept. ### Meta When the ad set and campaign were created by Zernio (by `POST /v1/ads/create` or `POST /v1/ads/boost`) and Meta lists no other ad in the ad set (archived ads count), the emptied ad set is deleted too. The campaign follows once it holds no other ad set. ### LinkedIn The ad is a creative inside a campaign inside a campaign group. - The creative is always removed. - The campaign is removed only when Zernio created it and LinkedIn lists no other creative in it that is not archived, canceled or deleted. - The campaign group is removed only when Zernio created it and LinkedIn lists no other campaign in it that is not canceled or deleted (archived campaigns count). If the creative itself cannot be removed the request fails and no parent is touched. ### X The ad is a promoted post inside a line item inside a campaign. - The promoted post is always removed. - The line item is removed only when Zernio created it (by `POST /v1/ads/create` or `POST /v1/ads/boost`) and X lists no other undeleted promoted post in it. - The campaign is removed only when Zernio created it and X lists no other undeleted line item in it. If X refuses the promoted post delete the request fails and no parent is touched.
pub async fn delete_ad(
configuration: &configuration::Configuration,
ad_id: &str,
) -> Result<models::DeleteAccountGroup200Response, Error<DeleteAdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_id = ad_id;
let uri_str = format!(
"{}/v1/ads/{adId}",
configuration.base_path,
adId = crate::apis::urlencode(p_path_ad_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAccountGroup200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteAccountGroup200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes a campaign on its platform, including a campaign that never got any ads. Only the campaign itself is sent to the platform: - Meta, Google, TikTok, LinkedIn and X delete it. - OpenAI, Reddit and Pinterest have no campaign delete and archive it instead (see below). Locally, all Ad documents for this campaign are marked `status: cancelled`. ### Empty campaigns A campaign with zero ads has no local Ad documents to resolve, so it is invisible to `/v1/ads/tree` and this endpoint would 404. That state comes from the two-step create flow (campaign, then ads via `existingCampaignId`) whenever Meta rejects the ad step. To delete such a shell, send `accountId` in the body or the query string. We skip the local lookup entirely and forward the delete to the platform of that connection. `accountId` is ignored when the campaign does have ads. ### Google, TikTok, LinkedIn, Pinterest, Reddit and OpenAI Google, TikTok, LinkedIn, Pinterest and Reddit take the ad account from the synced campaign (OpenAI needs none). When the campaign was never synced (or is synced under several ad accounts), the answer is 409 `invalid_resource_state` on `campaignId` and nothing is deleted: sync the ad account and retry. Before deleting on Google, TikTok, LinkedIn, Pinterest, OpenAI or Reddit, Zernio asks the platform whether the campaign still holds ad groups or ads. Google asset groups count; on LinkedIn, campaigns inside the campaign group count. If it does, or the platform cannot confirm it has none (a TikTok Smart+ campaign), the answer is 409 `invalid_resource_state` on `campaignId` and nothing is deleted. Either: - sync the ad account and delete the campaign again so its ads are cancelled with it, or - delete them on the platform first. ### X On X the ad account comes from the synced campaign, which wins over `adAccountId`. When the campaign was never synced, send `adAccountId` too. Before deleting, Zernio asks X whether the campaign still holds undeleted line items (ads not synced yet). If it does, the answer is 409 `invalid_field_value` on `campaignId` and nothing is deleted. - Line items that hold promoted posts: sync the ad account and retry. - Line items without promoted posts never sync, so delete them in X Ads Manager first. ### Reddit Ads Reddit Ads has no delete: the campaign is archived instead (`configured_status` ARCHIVED), which stops delivery for good. Its ad groups and ads keep their own switches but cannot deliver under an archived campaign. ### OpenAI Ads OpenAI Ads has no delete either: the campaign is archived (state `archive`). Its ad groups and ads are not touched on OpenAI.
pub async fn delete_ad_campaign(
configuration: &configuration::Configuration,
campaign_id: &str,
delete_ad_campaign_request: models::DeleteAdCampaignRequest,
) -> Result<models::DeleteAdCampaign200Response, Error<DeleteAdCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_delete_ad_campaign_request = delete_ad_campaign_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_delete_ad_campaign_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAdCampaign200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteAdCampaign200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAdCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes an ad set and its ads while keeping the campaign, archiving it instead on platforms without a hard delete. Locally, every Ad document under the ad set is marked `status: cancelled`. Delete is soft on platforms that have no hard delete: LinkedIn moves the campaign to `PENDING_DELETION`, Pinterest and Reddit archive the ad group, and X soft-flags the line item. Google removes the ad group. All remain readable for reporting.
pub async fn delete_ad_set(
configuration: &configuration::Configuration,
ad_set_id: &str,
) -> Result<models::DeleteAdSet200Response, Error<DeleteAdSetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAdSet200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteAdSet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAdSetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Hides an alert from `GET /v1/ads/alerts` for 30 days for the calling user. If the problem is still there after that, the alert comes back.
pub async fn dismiss_ads_alert(
configuration: &configuration::Configuration,
alert_id: &str,
) -> Result<models::DismissAdsAlert200Response, Error<DismissAdsAlertError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_alert_id = alert_id;
let uri_str = format!(
"{}/v1/ads/alerts/{alertId}/dismiss",
configuration.base_path,
alertId = crate::apis::urlencode(p_path_alert_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DismissAdsAlert200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DismissAdsAlert200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DismissAdsAlertError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Dismisses Google optimization suggestions so Google stops showing them. Dismiss up to 100 recommendations so Google stops suggesting them. Items run in partial-failure mode.
pub async fn dismiss_google_recommendations(
configuration: &configuration::Configuration,
dismiss_google_recommendations_request: models::DismissGoogleRecommendationsRequest,
) -> Result<models::ApplyGoogleRecommendations200Response, Error<DismissGoogleRecommendationsError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_body_dismiss_google_recommendations_request = dismiss_google_recommendations_request;
let uri_str = format!("{}/v1/ads/recommendations/dismiss", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_dismiss_google_recommendations_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ApplyGoogleRecommendations200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ApplyGoogleRecommendations200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DismissGoogleRecommendationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Copies a single Meta ad, optionally into another ad set, created paused so you can review it before launch. It duplicates the ad via Meta's native `POST /{ad-id}/copies`. The copy is created paused. - `adSetId` retargets the copy into another ad set; omitted = the source's own ad set. - Accepts the Zernio ad id or the platform ad id. - A sync discovery starts automatically and runs after the response (`syncAfter: false` to skip). The copy is readable through Zernio once it finishes, usually within a few minutes. Until then, calls that take a copied id return 404, so retry them. ### Creative settings Creative settings returned by Meta, including explicit promotion metadata and creativeFeatures, are preserved when the native copy requires a creative rebuild. Metadata Meta does not return cannot be recovered. ### Fallback rebuild When Meta refuses the native copy with its capability error (code 3), which happens for some creatives built by other tools, the ad is rebuilt instead: 1. A new creative from the source's returned spec. 2. A new ad in the target ad set, carrying the source name, status option, rename options and tracking specs.
pub async fn duplicate_ad(
configuration: &configuration::Configuration,
ad_id: &str,
idempotency_key: Option<&str>,
duplicate_ad_request: Option<models::DuplicateAdRequest>,
) -> Result<models::DuplicateAd200Response, Error<DuplicateAdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_id = ad_id;
let p_header_idempotency_key = idempotency_key;
let p_body_duplicate_ad_request = duplicate_ad_request;
let uri_str = format!(
"{}/v1/ads/{adId}/duplicate",
configuration.base_path,
adId = crate::apis::urlencode(p_path_ad_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_duplicate_ad_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DuplicateAd200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DuplicateAd200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DuplicateAdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Copies a campaign with its ad sets, ads, creatives and targeting, created paused so you can review it before launch. Ad sets, ads, creatives, and targeting are copied by default (`deepCopy: true`). The copy is created paused so callers can review before launching. ### Per-platform implementation - **Meta** copies one level at a time with Meta's `/copies` endpoint. See below. - **TikTok** has no native copy primitive. See below. - **LinkedIn** has no native copy primitive. See below. - Other platforms return 501 Not Implemented. ### Meta Zernio copies the campaign, then each of its ad sets (DELETED and ARCHIVED ones are skipped), then each ad of every ad set. So a campaign of any size copies: Meta refuses a single deep copy of 3 or more objects. - `statusOption` applies at every level. - If any child copy fails, the partial copy is deleted and the request fails with Meta's error, so a retry starts clean. - Each copied object takes a few seconds, so a large campaign takes minutes to answer. ### TikTok Zernio walks the source graph (`/v2/campaign/get/`, `/v2/adgroup/get/`, `/v2/ad/get/`) and recreates each entity via the corresponding `/create/` endpoints. It carries over budget / targeting / bid_type / bid_price / deep_bid_type / creative fields. Spark Ad linkage (`tiktok_item_id`) is preserved. ### LinkedIn Zernio walks the source CampaignGroup → Campaigns → Creatives and recreates each entity. It carries over these fields, plus every Creative's `content` object verbatim: - `type` / `costType` / `unitCost` / `optimizationTargetType` - `creativeSelection` / `objectiveType` / `format` - `dailyBudget` / `totalBudget` / `targetingCriteria` / `runSchedule` `statusOption: INHERITED_FROM_SOURCE` is evaluated **per entity**: any Group / Campaign / Creative whose source is `ACTIVE` gets its clone activated too. Duplicating an ACTIVE campaign with `INHERITED_FROM_SOURCE` starts a second front of spend the moment the clone activates. The safe default is `PAUSED`. ### Sync The copy exists on the platform when this call returns. The new hierarchy reaches our DB through a sync discovery that starts automatically and runs after the response, usually within a few minutes. Poll `/v1/ads/tree` until it appears; until then, calls that take a copied id return 404, so retry them. Set `syncAfter: false` to skip the sync; the copy then appears on a later scheduled sync.
pub async fn duplicate_ad_campaign(
configuration: &configuration::Configuration,
campaign_id: &str,
duplicate_ad_campaign_request: models::DuplicateAdCampaignRequest,
idempotency_key: Option<&str>,
) -> Result<models::DuplicateAdCampaign200Response, Error<DuplicateAdCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_duplicate_ad_campaign_request = duplicate_ad_campaign_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/duplicate",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_duplicate_ad_campaign_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DuplicateAdCampaign200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DuplicateAdCampaign200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DuplicateAdCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Copies an ad set, optionally with its ads and into another campaign, created paused so you can review it before launch. The copy is created paused so callers can review before launching. `campaignId` retargets the copy into another campaign; omitted = the source's own campaign. **Meta:** ads and creatives are included by default (`deepCopy: true`). - The ad set is copied with Meta's `/copies` endpoint, then each of its ads (DELETED and ARCHIVED ones are skipped) into the new ad set. - So an ad set with any number of ads copies: Meta refuses a single deep copy of 3 or more objects. - `statusOption` applies to the ad set and every ad. - If an ad copy fails, the partial ad set copy is deleted and the request fails with Meta's error. - A sync discovery starts automatically and runs after the response (`syncAfter: false` to skip). The copy is readable through Zernio once it finishes, usually within a few minutes. Until then, calls that take a copied id return 404, so retry them. TikTok: the ad group is read and recreated under the campaign with its targeting, bidding, budget and schedule (start reset to now); `deepCopy: true` recreates its ads too (default false). `startTime`, `endTime` and `renameStrategy` are ignored and `statusOption` must be PAUSED or absent. The copy appears on the next discovery sync.
pub async fn duplicate_ad_set(
configuration: &configuration::Configuration,
ad_set_id: &str,
duplicate_ad_set_request: models::DuplicateAdSetRequest,
idempotency_key: Option<&str>,
) -> Result<models::DuplicateAdSet200Response, Error<DuplicateAdSetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_body_duplicate_ad_set_request = duplicate_ad_set_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}/duplicate",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_duplicate_ad_set_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DuplicateAdSet200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DuplicateAdSet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DuplicateAdSetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Links new or existing assets to a Performance Max asset group and unlinks others in one change, keeping unlinked assets in the account library. Link existing assets or new content to the asset group, and unlink assets, in one atomic request. - Links are applied before unlinks, so swapping the last asset of a role does not trip Google's per-role minimum. - Unlinking removes the link only; the asset stays in the account library. - validateOnly: true validates without writing.
pub async fn edit_google_asset_group_assets(
configuration: &configuration::Configuration,
campaign_id: &str,
asset_group_id: &str,
edit_google_asset_group_assets_request: models::EditGoogleAssetGroupAssetsRequest,
) -> Result<models::EditGoogleAssetGroupAssets200Response, Error<EditGoogleAssetGroupAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_asset_group_id = asset_group_id;
let p_body_edit_google_asset_group_assets_request = edit_google_asset_group_assets_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/asset-groups/{assetGroupId}/assets",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
assetGroupId = crate::apis::urlencode(p_path_asset_group_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_edit_google_asset_group_assets_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EditGoogleAssetGroupAssets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EditGoogleAssetGroupAssets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<EditGoogleAssetGroupAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows one ad with its creative, targeting, status and performance metrics. ### Google Search ads Google Search ads include current creative.headlines, creative.descriptions and creative.finalUrls, preserving pinnedField. Top-level cachedAt and stale report cache freshness. Google mutations invalidate this read. RSA enrichment requires a stored advertisingChannelType of SEARCH. Ads with an unknown or other channel return their stored details without a Google read. If RSA enrichment fails, the stored ad is returned with HTTP 200 and without cache metadata. ### Accepted ad ids The `{adId}` path segment accepts any identifier dialect Zernio indexes for the ad: - the Zernio internal `_id` (24-char hex) - Meta's numeric `platformAdId` (the value shipped in `comment.received` webhooks as `comment.ad.id`) - the creative's `effective_object_story_id` (`{pageId}_{postId}` shape, Facebook side) - the creative's `effective_instagram_media_id` (Instagram side) - an Instagram media id an ad comment arrived on (`comment.platformPostId` of a `comment.received` carrying `comment.ad.id`), including the extra media Meta creates for placement variants Any of these resolve to the same ad, so the caller doesn't need a translation step. `creative.creativeFeatures` holds the stored requested settings, which do not confirm platform application. ### Facebook ad dark posts Meta gives an ad with per-placement assets one extra unpublished post per placement, and comments land on it. Meta exposes no link from that post to its ad. - When exactly one ad on the Page, created before the dark post, carries the same copy as the post, the dark post id resolves to that ad. - Otherwise, when the id is a dark post Zernio has seen comments on and its Page is connected, the response is `ad: null` plus `darkPost`. It carries the Meta Ads account and the ad accounts running ads for that Page. Read its comments with GET /v1/ads/{adId}/comments using the same id. ### Status freshness `status`, `configuredStatus`, `platformStatus`, `platformAdSetStatus` and `platformCampaignStatus` are the values Zernio last stored. Background sync refreshes them, typically within 15 to 60 minutes (Google up to about 3 hours), and ended or long-paused objects may be refreshed less often. Zernio's own status writes re-read the switches they change. A change made in the platform's own ads manager therefore shows up here only after the next sync. Controllers that act on a switch should pass `live=true`. It reads the switches from the platform now, stores them, and returns `statusReadAt` (null when the read failed and the stored values were returned). With `live=true` these are read live: - the ad's own switch (`configuredStatus`) - its delivery status (`status`, `platformStatus`) - its ad set and campaign switches (`platformAdSetStatus`, `platformCampaignStatus`) - on TikTok, the creative TikTok holds now: `creative.body` (ad text), `creative.callToAction`, `creative.linkUrl` (landing page), `creative.videoId`, `creative.adFormat`, `creative.identityId`, `creative.identityType`, `creative.identityAuthorizedBcId` and, on a Spark ad, `creative.tiktokItemId`. The TikTok creative comes from the same TikTok call as the switches. It replaces the stored values in the response only and is never stored. A key TikTok leaves empty keeps its stored value. ### Meta ads that are not synced yet Pass `accountId` with a Meta `platformAdId` to read an ad Zernio has not synced (for example one created in Ads Manager on an ad account reached only through a Facebook connection). The ad is read live from Meta and mapped exactly like a synced row: name, `status`, `platformStatus`, `configuredStatus`, `platformAdSetId`, `platformCampaignId`, campaign and ad set names, budgets, and `creative` with its `id`, body, link, image and video. It comes back with `synced: false`, no `id` (it has no Zernio row) and `statusReadAt` set to the time of the read. Synced ads answer `synced: true`. Only a numeric id takes this path, so dark post ids (`{pageId}_{postId}`) keep the dark post lookup above.
pub async fn get_ad(
configuration: &configuration::Configuration,
ad_id: &str,
live: Option<bool>,
account_id: Option<&str>,
) -> Result<models::GetAd200Response, Error<GetAdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_id = ad_id;
let p_query_live = live;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/ads/{adId}",
configuration.base_path,
adId = crate::apis::urlencode(p_path_ad_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_live {
req_builder = req_builder.query(&[("live", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAd200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAd200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows a Meta campaign's current settings straight from Meta, such as its objective, budget, bid strategy, schedule and delivery issues. It reads one campaign live from Meta, returned verbatim, so a caller that knows a campaign id no longer has to page `GET /v1/ads/campaigns` to find it. The default projection covers name, status, objective, buying type, bid strategy, budgets, spend cap, schedule and `issues_info`. ### Fields and errors - `fields` is a raw-passthrough override; unknown fields return Meta's 400 verbatim. - A campaign the resolved connection cannot see comes back as Meta's own 400, not a 404.
pub async fn get_ad_campaign_details(
configuration: &configuration::Configuration,
campaign_id: &str,
account_id: &str,
fields: Option<&str>,
) -> Result<models::GetAdCampaignDetails200Response, Error<GetAdCampaignDetailsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_account_id = account_id;
let p_query_fields = fields;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_fields {
req_builder = req_builder.query(&[("fields", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAdCampaignDetails200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAdCampaignDetails200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdCampaignDetailsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows whether the platform approved an ad, where it may not deliver, and every rejection reason, without re-enabling a paused ad. It reads the ad's review verdict from the platform now, including every rejection reason with TikTok's suggestion and the piece of content it refers to. It is read-only, so it works on a paused ad without re-enabling it. Supported on TikTok, Google and Meta. Other platforms return 501. ### Google Reads `ad_group_ad.policy_summary` live. `approvalStatus` and `reviewStatus` are Google's verbatim: - `approvalStatus`: APPROVED, APPROVED_LIMITED, AREA_OF_INTEREST_ONLY, DISAPPROVED, UNKNOWN. - `reviewStatus`: REVIEW_IN_PROGRESS, REVIEWED, UNDER_APPEAL, ELIGIBLE_MAY_SERVE. - `approved`: true for the three approved statuses, false for DISAPPROVED, null otherwise. `policyTopics` carries every policy topic entry with its `type` (PROHIBITED, LIMITED, ...) and Google's `evidences` and `constraints` verbatim. Each PROHIBITED topic is also listed in `rejections` (reason = the topic). The `forbidden*` arrays are TikTok-only and always empty on Google. ### Meta (Facebook and Instagram ads) Reads the Ad's `ad_review_feedback`, `effective_status` and `issues_info` live. - `reviewStatus`: Meta's `effective_status` verbatim (ACTIVE, PAUSED, PENDING_REVIEW, DISAPPROVED, PREAPPROVED, WITH_ISSUES, IN_PROCESS, ...). - `approved`: true for ACTIVE and PREAPPROVED, false for DISAPPROVED, null otherwise. - `reviewFeedback`: Meta's feedback verbatim, as `global` (reason -> explanation) and `placementSpecific` (placement -> reason -> explanation). - `issues`: Meta's `issues_info` verbatim. Each global reason is listed in `rejections`, and so is each placement-specific reason, with that placement in its `forbiddenPlacements`. The review's `forbiddenPlacements` lists every placement with feedback. `forbiddenAges`, `forbiddenLocations` and `forbiddenOperatingSystems` are always empty on Meta. When Meta returns no feedback (usually an ad in review or approved everywhere), the status comes back with empty `rejections` and empty `reviewFeedback` maps. An ACTIVE ad rejected on one placement still carries that placement's feedback. The `effective_status` read is also stored on the ad, so `GET /v1/ads/{adId}` returns it next. A deleted ad answers 404. ### Meta ads that are not synced yet Pass `accountId` with a Meta platform ad id that is not in Zernio's store to read its review live through that connection. The response then has `adId: null`, `synced: false`, and nothing is stored. Synced ads answer `synced: true`. ### TikTok TikTok uses `/ad/review_info/`. Use it alongside the ad's `platformStatus`: - `AD_STATUS_AUDIT`: the ad is in review (maps to `status: pending_review`). - `AD_STATUS_AD_PRE_ONLINE`: it passed and is about to deliver (also maps to `status: pending_review`). - `AD_STATUS_AUDIT_DENY`: maps to `rejected`.
pub async fn get_ad_review(
configuration: &configuration::Configuration,
ad_id: &str,
account_id: Option<&str>,
) -> Result<models::GetAdReview200Response, Error<GetAdReviewError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_id = ad_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/ads/{adId}/review",
configuration.base_path,
adId = crate::apis::urlencode(p_path_ad_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAdReview200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAdReview200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdReviewError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows a Meta ad set's current settings straight from Meta, including its learning phase, budget, schedule and targeting. The ad set is read live from Meta and returned verbatim. The default projection includes: - `learning_stage_info`: learning-phase status, LEARNING / SUCCESS / FAIL / WAIVING. Meta omits its `status` key on paused ad sets. - delivery settings, budgets and schedule - dayparting (`adset_schedule`, `pacing_type`) - targeting `fields` is a raw-passthrough override; unknown fields return Meta's 400 verbatim.
pub async fn get_ad_set_details(
configuration: &configuration::Configuration,
ad_set_id: &str,
account_id: &str,
fields: Option<&str>,
) -> Result<models::GetAdSetDetails200Response, Error<GetAdSetDetailsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_query_account_id = account_id;
let p_query_fields = fields;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_fields {
req_builder = req_builder.query(&[("fields", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAdSetDetails200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAdSetDetails200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdSetDetailsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows a Reddit ad group's live targeting and schedule in the same shape PUT /v1/ads/ad-sets/{adSetId} takes, so you can prefill an editor. It is read live from Reddit on every call. Reddit only; every other platform returns 501. ### How fields come back - Location and interest names are resolved with Reddit's targeting taxonomy. When Reddit cannot resolve them the ids stand in as names, and a location that is not a two-letter country is listed under `regions`. - Excluded DMAs are listed under `excludedLocations.regions`, since excluded locations have no metro list. - Languages come back as lowercase ISO 639-1 codes. - Targeting Zernio cannot edit (devices, platforms, carriers, automated expansion) is left out and kept on every edit.
pub async fn get_ad_set_targeting(
configuration: &configuration::Configuration,
ad_set_id: &str,
platform: Option<&str>,
) -> Result<models::GetAdSetTargeting200Response, Error<GetAdSetTargetingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_query_platform = platform;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}/targeting",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAdSetTargeting200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetAdSetTargeting200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdSetTargetingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows your campaigns with their ad sets and ads nested inside, with spend and results rolled up at every level. ### How it aggregates Uses a two-stage aggregation: ads are grouped into ad sets, then ad sets into campaigns. Metrics are computed over an optional date range, then rolled up from ad level to ad set and campaign levels. - Pagination is at the campaign level. - Ads without a campaign or ad set ID are grouped into synthetic \"Ungrouped\" buckets. - If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max. ### History When an ad account connects, Zernio imports its last 90 days of metrics, so the metrics hold no data for days before that. When `accountId` or `adAccountId` resolves to a Meta ad account, a range reaching further back answers `202` with `backfillPending: true` and the covered part. The older days (up to 730 days back) are imported in the background; repeat the request until it returns 200. A request scoped to no Meta account never returns `202`. ### Daily breakdown Pass `timeIncrement=1` to also get a daily breakdown: each node gains a `daily[]` array of per-day metrics (same fields as the aggregated `metrics`) in the same call. Use `dailyLevel` (`campaign` default, or `adset` / `ad`) to choose which levels carry the series. This replaces calling the tree once per day for per-campaign daily trends. ### Deleted objects stay in the tree Deleting an ad or a campaign is a soft delete: the Ad documents move to `status: cancelled` and are kept indefinitely. Their historical spend still counts toward the metrics of any date range they fall in. There is no pruning job and no retention window. Pass `status=not_deleted` if your view should hide them, but do that after reading the totals, not before.
pub async fn get_ad_tree(
configuration: &configuration::Configuration,
page: Option<i32>,
limit: Option<i32>,
source: Option<&str>,
platform: Option<&str>,
status: Option<&str>,
ad_account_id: Option<&str>,
page_id: Option<&str>,
account_id: Option<&str>,
profile_id: Option<&str>,
campaign_id: Option<&str>,
updated_since: Option<String>,
search: Option<&str>,
from_date: Option<String>,
to_date: Option<String>,
has_delivery: Option<bool>,
min_spend: Option<f64>,
sort: Option<&str>,
time_increment: Option<i32>,
daily_level: Option<&str>,
compare: Option<&str>,
results: Option<bool>,
) -> Result<models::AdTreeResponse, Error<GetAdTreeError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_page = page;
let p_query_limit = limit;
let p_query_source = source;
let p_query_platform = platform;
let p_query_status = status;
let p_query_ad_account_id = ad_account_id;
let p_query_page_id = page_id;
let p_query_account_id = account_id;
let p_query_profile_id = profile_id;
let p_query_campaign_id = campaign_id;
let p_query_updated_since = updated_since;
let p_query_search = search;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let p_query_has_delivery = has_delivery;
let p_query_min_spend = min_spend;
let p_query_sort = sort;
let p_query_time_increment = time_increment;
let p_query_daily_level = daily_level;
let p_query_compare = compare;
let p_query_results = results;
let uri_str = format!("{}/v1/ads/tree", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_source {
req_builder = req_builder.query(&[("source", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_id {
req_builder = req_builder.query(&[("pageId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_campaign_id {
req_builder = req_builder.query(&[("campaignId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_updated_since {
req_builder = req_builder.query(&[("updatedSince", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("fromDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to_date {
req_builder = req_builder.query(&[("toDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_has_delivery {
req_builder = req_builder.query(&[("hasDelivery", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_spend {
req_builder = req_builder.query(&[("minSpend", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_time_increment {
req_builder = req_builder.query(&[("timeIncrement", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_daily_level {
req_builder = req_builder.query(&[("dailyLevel", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_compare {
req_builder = req_builder.query(&[("compare", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_results {
req_builder = req_builder.query(&[("results", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdTreeResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AdTreeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdTreeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns an ads account's spend, results and other metrics day by day, ready for a daily performance chart. The result is a single time series of daily aggregate metrics across all ads in a SocialAccount: one row per calendar day and currency in the requested range (one row per day unless the account's ad accounts bill in different currencies). Use this for dashboards that draw a daily-spend or daily-conversions chart, instead of calling `/v1/ads/tree` once per day. ### Parameters - `accountId` is required. The lookup is sibling-expanded, so passing the `metaads` ID also includes ads under the linked `facebook` / `instagram` posting account (and vice-versa), the same convention as `/v1/ads/tree` and `/v1/ads`. - Date range defaults to the last 90 days. Capped at 730 days. - With adAccountId set to a Google customer id this is the customer-level performance report (clicks, cost, impressions, conversions, all conversions per day). ### History When an ad account connects, Zernio imports its last 90 days of metrics, so `rows` hold no data for days before that. When `accountId` or `adAccountId` resolves to a Meta ad account, a range reaching further back answers `202` with `backfillPending: true` and the covered part. The older days (up to 730 days back) are imported in the background; repeat the request until it returns 200. Other platforms never return `202`.
pub async fn get_ads_timeline(
configuration: &configuration::Configuration,
account_id: &str,
ad_account_id: Option<&str>,
from_date: Option<String>,
to_date: Option<String>,
platform: Option<&str>,
compare: Option<&str>,
) -> Result<models::AdsTimelineResponse, Error<GetAdsTimelineError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let p_query_platform = platform;
let p_query_compare = compare;
let uri_str = format!("{}/v1/ads/timeline", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("fromDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to_date {
req_builder = req_builder.query(&[("toDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_compare {
req_builder = req_builder.query(&[("compare", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdsTimelineResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AdsTimelineResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdsTimelineError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows the days and hours a Google campaign runs and its bid adjustments, optionally with performance by day and hour. The windows a Google campaign serves in, with the bid modifier on each, plus the criterion ids Google minted for them. An EMPTY `schedule` is meaningful and is not a failed lookup: Google has no \"all day\" criterion, so a campaign with no ad schedule serves around the clock. `servesAroundTheClock` states that explicitly. Set `includePerformance=true` to also get delivery split by day of week and by hour, which is the evidence for deciding what the schedule should be. It is one extra Google call segmented by both dimensions at once, so the two views always agree. Google Ads only. The response carries `cachedAt` and `stale`, set when a quota-exhausted call falls back to the last-good copy instead of a live read.
pub async fn get_campaign_ad_schedule(
configuration: &configuration::Configuration,
campaign_id: &str,
platform: Option<&str>,
include_performance: Option<bool>,
window_days: Option<i32>,
from_date: Option<String>,
to_date: Option<String>,
) -> Result<models::GetCampaignAdSchedule200Response, Error<GetCampaignAdScheduleError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_platform = platform;
let p_query_include_performance = include_performance;
let p_query_window_days = window_days;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/ad-schedule",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_performance {
req_builder = req_builder.query(&[("includePerformance", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_window_days {
req_builder = req_builder.query(&[("windowDays", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("fromDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to_date {
req_builder = req_builder.query(&[("toDate", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCampaignAdSchedule200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetCampaignAdSchedule200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignAdScheduleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows a Google campaign's current bidding strategy and targets, ready to prefill an edit. Reads the campaign's bidding strategy on Google, cached for the quota window, for pre-filling the bid strategy block before a PUT to /v1/ads/campaigns/{campaignId}. Google Ads only. `platform` is required and rejected when it is anything else, since a `campaignId` is not globally unique. The response carries `cachedAt` and `stale`, set when a quota-exhausted call falls back to the last-good copy instead of a live read. ### Strategy mapping Maps Google's bidding strategy onto the same triplet PUT accepts: - `LOWEST_COST_WITHOUT_CAP`: Maximize Conversions, no target - `COST_CAP` + `bidAmount`: Target CPA - `LOWEST_COST_WITH_MIN_ROAS` + `roasAverageFloor`: Target ROAS - `LOWEST_COST_WITH_BID_CAP` + `bidAmount`: Maximize Clicks with a CPC ceiling A campaign on a portfolio strategy returns `portfolio` (id + name) and `bidSpec.portfolioBidStrategyId` instead of the triplet. Anything else (Manual CPC, Target Impression Share, ...) returns `bidSpec: null`; show `biddingStrategyType` as-is.
pub async fn get_campaign_bidding(
configuration: &configuration::Configuration,
campaign_id: &str,
account_id: &str,
platform: &str,
ad_account_id: Option<&str>,
customer_id: Option<&str>,
) -> Result<models::GetCampaignBidding200Response, Error<GetCampaignBiddingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_account_id = account_id;
let p_query_platform = platform;
let p_query_ad_account_id = ad_account_id;
let p_query_customer_id = customer_id;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/bidding",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
req_builder = req_builder.query(&[("platform", &p_query_platform.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_customer_id {
req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCampaignBidding200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetCampaignBidding200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignBiddingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows which conversion goals a Google campaign bids on, and whether it follows the account defaults or uses its own or a custom goal. A Google campaign's conversion goals (CampaignConversionGoal, `biddable` per category and origin) and its goal config (ConversionGoalCampaignConfig): `goalConfigLevel` CUSTOMER means the campaign follows the account-default goals, CAMPAIGN means it uses its own goals or `customConversionGoalId`.
pub async fn get_campaign_conversion_goals(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::GetCampaignConversionGoals200Response, Error<GetCampaignConversionGoalsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/conversion-goals",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCampaignConversionGoals200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetCampaignConversionGoals200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignConversionGoalsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows a Google campaign's device, location, excluded location and language targeting so you can build an editor for it. Google Ads compliance requires geo, language, budget, and bidding targeting set at creation to stay editable afterwards. This reads the campaign state so an integrator can build an editor around it. - Cached for the quota window (10 minutes fresh, up to 7 days last-good), not always a live read. - Google only; every other platform returns 501. ### Devices `devices` lists the device criteria the campaign carries, which depends on its channel: - Search campaigns have MOBILE, DESKTOP and TABLET. - Display campaigns also have CONNECTED_TV. `bidModifier` is Google's bid adjustment for that device: `null` when it has none, and `0` when the device is switched off. `included` is false for exactly that case. ### Locations `excludedLocations` lists the campaign's negative location criteria (the places it never serves in). `locations` still lists every location criterion, each flagged with `negative`, so a client reading the targeted set filters `negative: false`.
pub async fn get_campaign_targeting(
configuration: &configuration::Configuration,
campaign_id: &str,
platform: Option<&str>,
) -> Result<models::GetCampaignTargeting200Response, Error<GetCampaignTargetingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_platform = platform;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/targeting",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetCampaignTargeting200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetCampaignTargeting200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignTargetingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows one Performance Max asset group with its linked assets, ad strength, status and product targeting tree. One asset group with its linked assets, ad strength, primary status and listing-group tree. Uses a 10-minute cache, served stale when Google quota is exhausted; any write below clears it.
pub async fn get_google_asset_group(
configuration: &configuration::Configuration,
campaign_id: &str,
asset_group_id: &str,
) -> Result<models::GetGoogleAssetGroup200Response, Error<GetGoogleAssetGroupError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_asset_group_id = asset_group_id;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/asset-groups/{assetGroupId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
assetGroupId = crate::apis::urlencode(p_path_asset_group_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetGoogleAssetGroup200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetGoogleAssetGroup200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetGoogleAssetGroupError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Shows which Spark post, video or carousel of an Upgraded Smart+ ad TikTok approved or rejected, with every rejection reason, keyed by the TikTok post id for a Spark post. It reads TikTok's `/smart_plus/ad/review_info/` live (read-only, works on a paused ad) for the Smart+ ad that holds `adId`. It returns the ad-level verdict plus one entry per creative. ### Which ad is read `adId` may be the Smart+ ad itself or any creative of it synced as its own ad. Zernio finds the Smart+ ad in the ad's ad group through `/smart_plus/ad/get/`, and uses the ad group's only Smart+ ad when no creative list names the ad. ### Creative fields `materialType`, `tiktokItemId`, `videoId`, `name` and `operationStatus` come from the Smart+ ad's `creative_list`. Some entries come back with the review verdict and null descriptive fields: - creatives TikTok added on its own, which it leaves out of that list (creator content, authorized TikTok posts, Creative Library content) - each image of a carousel, which TikTok lists under its own material id TikTok returns no review timestamp; `readAt` is when Zernio read it. ### Quota and caching TikTok's review endpoint has a strict quota of its own (TikTok documents neither the quota nor its scope). One TikTok call reads the review of the live Smart+ ads of the ad group, up to 50 creatives in total (TikTok refuses more). Each review is stored per connection, advertiser and Smart+ ad. A review read in the last 10 minutes is served from the store, so sibling ads are answered without a TikTok call and `readAt` can be up to 10 minutes old. An older one is read again. Read reviews when you need them instead of sweeping every ad on a loop. ### Over quota When TikTok answers over quota, Zernio returns 429. It then answers 429 for that advertiser and connection without calling TikTok: - for about 60 seconds at first - then 120, and up to 240, while TikTok keeps refusing - about 60 again after a successful call Each pause has up to 10% of random jitter, with the time left as `Retry-After`. Reviews read in the last 10 minutes are still served.
pub async fn get_tik_tok_smart_plus_ad_review(
configuration: &configuration::Configuration,
ad_id: &str,
) -> Result<models::GetTikTokSmartPlusAdReview200Response, Error<GetTikTokSmartPlusAdReviewError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_id = ad_id;
let uri_str = format!(
"{}/v1/ads/{adId}/tiktok-smart-plus-review",
configuration.base_path,
adId = crate::apis::urlencode(p_path_ad_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTikTokSmartPlusAdReview200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetTikTokSmartPlusAdReview200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTikTokSmartPlusAdReviewError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists your campaigns with spend, impressions and clicks summed across their ads, plus each campaign's status and budget. Campaigns are virtual aggregations over ad documents grouped by platform campaign ID. Metrics (spend, impressions, clicks, etc.) are summed across all ads in each campaign. Campaign status is derived from child ad statuses: active > pending_review > paused > error > completed > cancelled > rejected. Google campaign budgets include amountMicros, explicitlyShared, resourceName and deliveryMethod after the next successful sync. This endpoint does not fetch Google live. **Status freshness.** `status`, `configuredStatus`, `platformStatus`, `platformAdSetStatus` and `platformCampaignStatus` are the values Zernio last stored. Background sync refreshes them, typically within 15 to 60 minutes (Google up to about 3 hours), and ended or long-paused objects may be refreshed less often. Zernio's own status writes re-read the switches they change. A change made in the platform's own ads manager therefore shows up here only after the next sync. ### Live status reads Controllers that act on a switch should pass `live=true`. It reads the switches from the platform now, stores them, and returns `statusReadAt` (null when the read failed and the stored values were returned). - `live=true` needs `limit` of 20 or less. - Each returned campaign's own switch (`platformCampaignStatus`) is read live. - Live reads cover TikTok, Meta, Google, OpenAI and Reddit. - The rolled-up `status` is not re-derived by a live read. **Budgets here are SYNCED**, never read live, including with `live=true`. To read the current budgets (and status) of every campaign and ad set of a Meta ad account live in one call, for example as a pre-write spend gate, use GET /v1/ads/accounts/live.
pub async fn list_ad_campaigns(
configuration: &configuration::Configuration,
include_empty: Option<bool>,
page: Option<i32>,
limit: Option<i32>,
source: Option<&str>,
platform: Option<&str>,
status: Option<&str>,
ad_account_id: Option<&str>,
campaign_id: Option<&str>,
page_id: Option<&str>,
account_id: Option<&str>,
profile_id: Option<&str>,
from_date: Option<String>,
to_date: Option<String>,
has_delivery: Option<bool>,
min_spend: Option<f64>,
live: Option<bool>,
) -> Result<models::ListAdCampaigns200Response, Error<ListAdCampaignsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_include_empty = include_empty;
let p_query_page = page;
let p_query_limit = limit;
let p_query_source = source;
let p_query_platform = platform;
let p_query_status = status;
let p_query_ad_account_id = ad_account_id;
let p_query_campaign_id = campaign_id;
let p_query_page_id = page_id;
let p_query_account_id = account_id;
let p_query_profile_id = profile_id;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let p_query_has_delivery = has_delivery;
let p_query_min_spend = min_spend;
let p_query_live = live;
let uri_str = format!("{}/v1/ads/campaigns", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_include_empty {
req_builder = req_builder.query(&[("includeEmpty", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_source {
req_builder = req_builder.query(&[("source", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_campaign_id {
req_builder = req_builder.query(&[("campaignId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_id {
req_builder = req_builder.query(&[("pageId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("fromDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to_date {
req_builder = req_builder.query(&[("toDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_has_delivery {
req_builder = req_builder.query(&[("hasDelivery", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_spend {
req_builder = req_builder.query(&[("minSpend", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_live {
req_builder = req_builder.query(&[("live", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdCampaigns200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListAdCampaigns200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdCampaignsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the sitelinks, callouts, snippets and images attached directly to a Google ad group, not those inherited from the campaign or account. Fresh reads are cached for 10 minutes; exhausted quota may return the last successful read with stale=true. Inherited assets are not included.
pub async fn list_ad_group_assets(
configuration: &configuration::Configuration,
ad_set_id: &str,
account_id: &str,
ad_account_id: Option<&str>,
customer_id: Option<&str>,
) -> Result<models::ListAdGroupAssets200Response, Error<ListAdGroupAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_customer_id = customer_id;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}/assets",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_customer_id {
req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdGroupAssets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListAdGroupAssets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdGroupAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the keywords and negative keywords in your Google Search ad groups. Returns the Google Search keyword criteria (positive and negative) synced from connected Google Ads accounts, one row per ad-group keyword. Campaign-level negative keywords are not included; only ad-group-level criteria are. ### Freshness Keywords are refreshed about once a day per Google Ads customer (the keyword sweep rides the ads discovery pass on a slower slot). So keywords added on Google can take up to a day to appear. - A customer synced for the first time is populated on the next discovery pass rather than waiting for its daily slot. - Connecting an account or triggering a manual sync refreshes it immediately.
pub async fn list_ad_keywords(
configuration: &configuration::Configuration,
page: Option<i32>,
limit: Option<i32>,
account_id: Option<&str>,
ad_account_id: Option<&str>,
profile_id: Option<&str>,
campaign_id: Option<&str>,
ad_set_id: Option<&str>,
status: Option<&str>,
match_type: Option<&str>,
negative: Option<bool>,
search: Option<&str>,
) -> Result<models::ListAdKeywords200Response, Error<ListAdKeywordsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_page = page;
let p_query_limit = limit;
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_profile_id = profile_id;
let p_query_campaign_id = campaign_id;
let p_query_ad_set_id = ad_set_id;
let p_query_status = status;
let p_query_match_type = match_type;
let p_query_negative = negative;
let p_query_search = search;
let uri_str = format!("{}/v1/ads/keywords", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_campaign_id {
req_builder = req_builder.query(&[("campaignId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_set_id {
req_builder = req_builder.query(&[("adSetId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_match_type {
req_builder = req_builder.query(&[("matchType", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_negative {
req_builder = req_builder.query(&[("negative", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_search {
req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdKeywords200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListAdKeywords200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdKeywordsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists ad sets (ad groups on Google) with their targeting, bidding and optimization settings, optionally for one campaign. Returns the ad sets (Google ad groups) synced for the connection, optionally filtered by platform and campaignId. It reads the `ad_sets` table directly, independent of the `ads` rollup GET /v1/ads/tree uses. So a newly created standalone ad group with no ad yet (POST /v1/ads/ad-sets, Google only) is visible here. It stays invisible in the tree until an ad joins it via `adSetId` on POST /v1/ads/create. ### Paging Rows come newest first (by platform creation time, then id, so pages never overlap), 500 per page unless `limit` says otherwise. `pagination.total` counts every matching ad set and `page` reaches the rest. ### Synced config **This list is SYNCED, not live** (refreshed by background sync, see below). Each row also carries the ad set's config: `targeting`, `bidStrategy`, `bidAmount`, `optimizationGoal`, `billingEvent`, `promotedObject`. So `?accountId=...&adAccountId=act_...` returns the config of every ad set of an ad account in one call, without a `campaignId`. To read budgets, status, targeting, promoted object and bid strategy of every campaign and ad set of a Meta ad account LIVE in one call (for example as a pre-write spend gate), use GET /v1/ads/accounts/live instead. ### Status freshness `status`, `configuredStatus`, `platformStatus`, `platformAdSetStatus` and `platformCampaignStatus` are the values Zernio last stored. Background sync refreshes them, typically within 15 to 60 minutes (Google up to about 3 hours). Ended or long-paused objects may be refreshed less often. Zernio's own status writes re-read the switches they change. A change made in the platform's own ads manager therefore shows up here only after the next sync. ### Live reads (`live=true`) Controllers that act on a switch should pass `live=true`. It reads the switches from the platform now, stores them, and returns `statusReadAt` (null when the read failed and the stored values were returned). - `live=true` needs a `campaignId` or `adSetId` filter. - Each listed ad set's own switch (`platformAdSetStatus`) is read live for the first 20 rows of the page. Later rows keep their synced value with `statusReadAt: null`. - To read more ad sets live, page with `limit=20`. - Live reads cover TikTok, Meta, Google, OpenAI and Reddit. - The rolled-up `status` is not re-derived by a live read. ### TikTok live reads On TikTok the same live read also returns the ad group's applied `optimizationGoal` and `billingEvent`, as TikTok's adgroup/get reports them. So you can verify the goal TikTok applied rather than the one you requested. It also returns `nativeSettings`: a fixed subset of TikTok's own adgroup/get record for the ad group, with TikTok's own values, read in that same call. It covers budget, budget_mode, schedule, placements, locations, ages, gender, languages, interests, actions, audiences and exclusions, plus the advertiser's currency and timezone. TikTok's `schedule_start_time` / `schedule_end_time` are UTC wall clocks (\"YYYY-MM-DD HH:MM:SS\", no offset); Ads Manager displays them in `advertiser_timezone`. `configReadAt` says when it was read. It is null on every row whose native settings were not read now, so never treat a null as a match. These are read, not retained create payloads, and are not stored.
pub async fn list_ad_sets(
configuration: &configuration::Configuration,
account_id: Option<&str>,
ad_account_id: Option<&str>,
campaign_id: Option<&str>,
ad_set_id: Option<&str>,
platform: Option<&str>,
status: Option<models::AdStatus>,
page: Option<i32>,
limit: Option<i32>,
live: Option<bool>,
) -> Result<models::ListAdSets200Response, Error<ListAdSetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_campaign_id = campaign_id;
let p_query_ad_set_id = ad_set_id;
let p_query_platform = platform;
let p_query_status = status;
let p_query_page = page;
let p_query_limit = limit;
let p_query_live = live;
let uri_str = format!("{}/v1/ads/ad-sets", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_campaign_id {
req_builder = req_builder.query(&[("campaignId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_set_id {
req_builder = req_builder.query(&[("adSetId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_live {
req_builder = req_builder.query(&[("live", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdSets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListAdSets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdSetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists your ads with their performance over a date range, including ads created directly in each platform's ads manager. Returns a paginated list of ads with metrics computed over an optional date range. Use source=all to include externally-synced ads from platform ad managers. If no date range is provided, it defaults to the last 90 days. The date range is capped at 730 days max. ### History When an ad account connects, Zernio imports its last 90 days of metrics, so the metrics hold no data for days before that. When `accountId` or `adAccountId` resolves to a Meta ad account, a range reaching further back answers `202` with `backfillPending: true` and the covered part. The older days (up to 730 days back) are imported in the background; repeat the request until it returns 200. A request scoped to no Meta account never returns `202`. ### Finding the ad behind a comment To find the Zernio ad behind a comment you see in Meta Business Manager: 1. Filter by platformAdId (the Meta ad ID), effectiveObjectStoryId (Facebook), or effectiveInstagramMediaId (Instagram). Those are the post/media the ad's engagement lives on, and are also returned on each ad's `creative` object. 2. Call GET /v1/ads/{adId}/comments with the returned ad id.
pub async fn list_ads(
configuration: &configuration::Configuration,
page: Option<i32>,
limit: Option<i32>,
source: Option<&str>,
status: Option<models::AdStatus>,
platform: Option<&str>,
account_id: Option<&str>,
ad_account_id: Option<&str>,
page_id: Option<&str>,
profile_id: Option<&str>,
campaign_id: Option<&str>,
ad_set_id: Option<&str>,
platform_ad_id: Option<&str>,
effective_object_story_id: Option<&str>,
effective_instagram_media_id: Option<&str>,
from_date: Option<String>,
to_date: Option<String>,
) -> Result<models::AdsListResponse, Error<ListAdsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_page = page;
let p_query_limit = limit;
let p_query_source = source;
let p_query_status = status;
let p_query_platform = platform;
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_page_id = page_id;
let p_query_profile_id = profile_id;
let p_query_campaign_id = campaign_id;
let p_query_ad_set_id = ad_set_id;
let p_query_platform_ad_id = platform_ad_id;
let p_query_effective_object_story_id = effective_object_story_id;
let p_query_effective_instagram_media_id = effective_instagram_media_id;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let uri_str = format!("{}/v1/ads", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_source {
req_builder = req_builder.query(&[("source", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_id {
req_builder = req_builder.query(&[("pageId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_campaign_id {
req_builder = req_builder.query(&[("campaignId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_set_id {
req_builder = req_builder.query(&[("adSetId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform_ad_id {
req_builder = req_builder.query(&[("platformAdId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_effective_object_story_id {
req_builder = req_builder.query(&[("effectiveObjectStoryId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_effective_instagram_media_id {
req_builder = req_builder.query(&[("effectiveInstagramMediaId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("fromDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to_date {
req_builder = req_builder.query(&[("toDate", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdsListResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AdsListResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists what needs attention across your ads, most severe first: - ads created in the last 90 days that were rejected - campaigns the platform reports delivery issues on - Meta ad accounts with a failed or overdue payment, or disabled while holding live ads - campaigns that spent on 3 or more of the last 7 days without a result (conversion, lead, purchase or conversation goals) - budgets spent to their daily cap yesterday - ads connections that need reconnecting while they still hold live ads - ad accounts whose sync has been failing Built from stored data and the last 7 days of synced metrics, so it costs no platform call. Each alert has a stable `id`. Dismiss one with `POST /v1/ads/alerts/{alertId}/dismiss` to hide it for 30 days.
pub async fn list_ads_alerts(
configuration: &configuration::Configuration,
account_id: Option<&str>,
profile_id: Option<&str>,
include_dismissed: Option<bool>,
) -> Result<models::ListAdsAlerts200Response, Error<ListAdsAlertsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_profile_id = profile_id;
let p_query_include_dismissed = include_dismissed;
let uri_str = format!("{}/v1/ads/alerts", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_account_id {
req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_dismissed {
req_builder = req_builder.query(&[("includeDismissed", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdsAlerts200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListAdsAlerts200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdsAlertsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns an ads account's ads ranked by spend, impressions, clicks, results or ROAS over a date range, each with its creative (type, thumbnail, headline, body, link) and campaign. Use it to see which creatives perform best. `accountId` is sibling-expanded like `/v1/ads/timeline`. Money is ranked by its raw amount, so pass `adAccountId` when the connection's ad accounts bill in different currencies. A Meta range older than the imported history answers `202` with `backfillPending: true` and the covered part; repeat the request until it returns 200.
pub async fn list_ads_by_performance(
configuration: &configuration::Configuration,
account_id: &str,
from_date: String,
to_date: String,
ad_account_id: Option<&str>,
platform: Option<&str>,
sort_by: Option<&str>,
limit: Option<i32>,
) -> Result<models::AdsPerformanceResponse, Error<ListAdsByPerformanceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let p_query_ad_account_id = ad_account_id;
let p_query_platform = platform;
let p_query_sort_by = sort_by;
let p_query_limit = limit;
let uri_str = format!("{}/v1/ads/performance", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
req_builder = req_builder.query(&[("fromDate", &p_query_from_date.to_string())]);
req_builder = req_builder.query(&[("toDate", &p_query_to_date.to_string())]);
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort_by {
req_builder = req_builder.query(&[("sortBy", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdsPerformanceResponse`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AdsPerformanceResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdsByPerformanceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists a Google Ads account's shared bid strategies with how many campaigns use each and how they performed. The bidding strategy report covers type, status, campaign count, clicks, cost, cost per conversion, impressions, average CPC and conversions over the date range (default last 30 days). ### Data source It reads Google's `bidding_strategy` resource, cached for the quota window, and draws on the shared Google Ads operations budget. The response carries `cachedAt` and `stale`, set when a quota-exhausted call falls back to the last-good copy instead of a live read.
pub async fn list_bid_strategies(
configuration: &configuration::Configuration,
account_id: &str,
ad_account_id: Option<&str>,
customer_id: Option<&str>,
from_date: Option<String>,
to_date: Option<String>,
) -> Result<models::ListBidStrategies200Response, Error<ListBidStrategiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_customer_id = customer_id;
let p_query_from_date = from_date;
let p_query_to_date = to_date;
let uri_str = format!("{}/v1/ads/bid-strategies", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_customer_id {
req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from_date {
req_builder = req_builder.query(&[("fromDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to_date {
req_builder = req_builder.query(&[("toDate", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListBidStrategies200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListBidStrategies200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListBidStrategiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the sitelinks, callouts and other assets attached directly to a Google campaign. Fresh reads are cached for 10 minutes; exhausted quota may return the last successful read with stale=true. Inherited assets are not included.
pub async fn list_campaign_assets(
configuration: &configuration::Configuration,
campaign_id: &str,
account_id: &str,
ad_account_id: Option<&str>,
customer_id: Option<&str>,
) -> Result<models::ListCampaignAssets200Response, Error<ListCampaignAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_customer_id = customer_id;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/assets",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_customer_id {
req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListCampaignAssets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListCampaignAssets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the shared negative keyword lists attached to a Google campaign, separate from its own campaign-level negatives. Google Ads shared negative keyword lists (shared_set type NEGATIVE_KEYWORDS). Reads are cached for 10 minutes; quota exhaustion may return the last successful result for up to 7 days with stale=true. Customer selection is limited to this connection and its account scope.
pub async fn list_campaign_negative_keyword_lists(
configuration: &configuration::Configuration,
campaign_id: &str,
platform: Option<&str>,
) -> Result<
models::ListAdNegativeKeywordLists200Response,
Error<ListCampaignNegativeKeywordListsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_platform = platform;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/negative-keyword-lists",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdNegativeKeywordLists200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListAdNegativeKeywordLists200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignNegativeKeywordListsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the negative keywords set on a whole Google campaign, separate from ad group negatives. It returns the campaign-level negative keywords (`campaign_criterion.negative`), distinct from the ad-group-level negatives under `GET /v1/ads/keywords`. ### Caching and quota Results are cached for the quota window (not synced to Postgres) and gated by the shared Google Ads operations budget, like every other on-demand Google surface. The response carries `cachedAt` and `stale`, set when a quota-exhausted call falls back to the last-good copy instead of a live read. ### Platform The platform is always discovered from the campaign itself. A non-Google campaign returns 501 rather than 404, whether or not `platform` was passed.
pub async fn list_campaign_negative_keywords(
configuration: &configuration::Configuration,
campaign_id: &str,
platform: Option<&str>,
) -> Result<models::ListCampaignNegativeKeywords200Response, Error<ListCampaignNegativeKeywordsError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_platform = platform;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/negative-keywords",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListCampaignNegativeKeywords200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListCampaignNegativeKeywords200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignNegativeKeywordsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists a Performance Max campaign's asset groups with their linked text, image and YouTube assets. campaignId is the platform campaign id returned by creation or the campaign list. The campaign must be visible to the caller. ### Caching Uses a 10-minute cache, with the last successful response served as stale when Google quota is exhausted. ### What is left out - Removed groups and asset links are excluded. - Campaign-level brand assets on campaigns with brand guidelines enabled are not included.
pub async fn list_google_asset_groups(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::ListGoogleAssetGroups200Response, Error<ListGoogleAssetGroupsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/asset-groups",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListGoogleAssetGroups200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListGoogleAssetGroups200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListGoogleAssetGroupsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists Google's optimization suggestions for an ad account, with the estimated impact of each. ### What each recommendation includes - type - estimated impact (base vs potential metrics, cost in account currency units) - the campaign, ad group or budget they target - the type-specific payload Google returns (`details`, in Google's own shape with micros) Filter by campaignId and types. Cached for 10 minutes and cleared by apply or dismiss. Served stale when Google quota is exhausted.
pub async fn list_google_recommendations(
configuration: &configuration::Configuration,
account_id: &str,
ad_account_id: Option<&str>,
customer_id: Option<&str>,
campaign_id: Option<&str>,
types: Option<&str>,
) -> Result<models::ListGoogleRecommendations200Response, Error<ListGoogleRecommendationsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_customer_id = customer_id;
let p_query_campaign_id = campaign_id;
let p_query_types = types;
let uri_str = format!("{}/v1/ads/recommendations", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_customer_id {
req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_campaign_id {
req_builder = req_builder.query(&[("campaignId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_types {
req_builder = req_builder.query(&[("types", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListGoogleRecommendations200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListGoogleRecommendations200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListGoogleRecommendationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists a Google Ads account's shared budgets and how many campaigns draw from each. Lists the Google Ads customer's shared campaign budgets (`campaign_budget.explicitly_shared` = true, not removed), with how many campaigns use each. Move a campaign onto one with `sharedBudgetId` on PUT /v1/ads/campaigns/{campaignId}. Google only; other platforms return 501.
pub async fn list_shared_budgets(
configuration: &configuration::Configuration,
account_id: &str,
ad_account_id: Option<&str>,
) -> Result<models::ListSharedBudgets200Response, Error<ListSharedBudgetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let uri_str = format!("{}/v1/ads/shared-budgets", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListSharedBudgets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListSharedBudgets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListSharedBudgetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns the review verdict of every Upgraded Smart+ ad of one TikTok advertiser, with each creative's verdict, in one paginated read. Use it to refresh reviews periodically: one call (plus its pages) per advertiser per refresh, instead of `GET /v1/ads/{adId}/tiktok-smart-plus-review` per ad. ### How Zernio reads TikTok 1. Zernio lists the advertiser's Smart+ ads with `/smart_plus/ad/get/` (deleted ones only with `includeDeleted=true`). 2. It reads `/smart_plus/ad/review_info/` for Smart+ ads holding up to 50 creatives in total per call (TikTok refuses more). A Smart+ ad with more than 50 creatives is read alone. 3. Calls run across ad groups, one after another while TikTok accepts them, for up to 20 seconds per request. Ads not reached are read by the next request, which can come right away. One request per advertiser and connection refreshes at a time. A parallel request sends no review call and answers what is stored with `refreshState: paused` and `retryAfterSeconds: 20`. A full refresh of N Smart+ ads with C creatives in total costs about `ceil(N / 100)` listing calls and `ceil(C / 50)` review calls on TikTok. When TikTok still refuses a call for its creative count, Zernio lowers the creative cap for that advertiser and reads the same ads again in smaller calls, never resending the refused size. ### Stale while refreshing Every review is stored for 24 hours per connection, advertiser and Smart+ ad (shared with the single-ad read). `readAt` is always the time TikTok answered, never rewritten when served from the store. `maxAgeSeconds` (default 3600) is the freshness window: - A review read within it is fresh and costs no TikTok call. - An older one is still returned in `items` but is read again. - A Smart+ ad never read is also read. Each request alternates one batch of Smart+ ads never read (live, then deleted with `includeDeleted=true`) with one batch of stale ones, oldest `readAt` first. So a quota pause starves neither, progress carries over between requests, and an ad already read never goes back to pending. A stored review is replaced only by a successful read. ### Response fields - `counts`: splits the Smart+ ads on this page into `fresh`, `stale`, `pending` and `failed`. - `oldestReadAt`: the oldest `readAt` of `items`. - `incomplete`: true only while some Smart+ ad of the page has never been read (`pending > 0`). - `allFresh`: staleness is reported apart. True when every item and refusal of the page is within `maxAgeSeconds` and nothing is pending. - `refreshState`: `paused` or `refused` when Zernio could not refresh some due ads of the page because review reads are held or TikTok refused them over quota. - `retryAfterSeconds` (also in the `Retry-After` header): when that later read can reach TikTok, even with nothing pending. A page with stale items and nothing pending is complete (`incomplete: false`). Move on, and a later read refreshes it oldest first. On 2026-10-25 TikTok's quota allowed about 130 to 230 Smart+ ads per advertiser per hour (about 11.5 ads and 4 creatives per successful call). A larger advertiser cannot be fully refreshed within one hour, so its pages stay complete but not `allFresh`. ### Listing freshness The listing is stored with the time it was read (`listing.readAt`) and listed again when it is older than `maxAgeSeconds`. So it can be up to `maxAgeSeconds` old: a Smart+ ad created on TikTok appears after at most that long (one hour by default). - `listing.source: fresh`: the listing was read within `maxAgeSeconds`. - `listing.source: fallback`: relisting failed, so Zernio serves the stored listing, with the relist error in `listing.error`, instead of failing the request. Only when no listing was ever stored does the listing error fail the request. ### Review quota TikTok's review endpoint has a strict quota of its own (TikTok documents neither the quota nor its scope). One request keeps reading batches (up to 50 creatives each) while TikTok accepts them. Zernio may hold review reads after an overage: about 60 seconds, then 120 and up to 240 while TikTok keeps refusing, and about 60 again after a successful call, each with up to 10% of random jitter. When TikTok is over quota (or reads are held), Zernio stops calling TikTok and answers 200 with the reviews it has: - stale reviews in `items` - the Smart+ ads never read in `pendingSmartPlusAdIds` - `incomplete: true` when any are pending - `refreshState` (`paused` or `refused`) with `retryAfterSeconds` (also in the `Retry-After` header) whenever due ads were left unread Every Smart+ ad of the page is in `items`, `failedSmartPlusAds` or `pendingSmartPlusAdIds`. Wait `retryAfterSeconds` and read the same page again: only the stale and pending ads reach TikTok. ### Refused ads A Smart+ ad whose review TikTok refuses on its own (for example one deleted on TikTok since the listing was read) is returned in `failedSmartPlusAds` with TikTok's error and `refusedAt`. The rest of the page is still read. Zernio finds it by splitting the refused batch in halves, at most 16 extra TikTok calls per page. Ads still unresolved after that keep their stored review, or stay in `pendingSmartPlusAdIds` when they have none, and are read again by the next request, in turn with the other due ads. A refusal of a single ad is stored for 24 hours and read again once it is older than `maxAgeSeconds`. When an ad has both a stored review and a stored refusal, the more recent one is returned. When both halves of a refused batch are refused with the same TikTok error (for example a permission error), Zernio stops calling TikTok for that page: - If every Smart+ ad of the page has a stored review or refusal, it serves them and returns the refusal in `reviewError`. - If some ad was never read, the whole request fails with that error. ### Paging Items are sorted by `adGroupId`, then `smartPlusAdId`, so pages are stable. Keep one page in flight per advertiser and read its pages one after another. Parallel pages of one advertiser spend its review quota at the same time and come back incomplete. Production logs suggest the quota is counted per advertiser (not confirmed by TikTok), so different advertisers have been read in parallel without throttling each other.
pub async fn list_tik_tok_smart_plus_reviews(
configuration: &configuration::Configuration,
account_id: &str,
ad_account_id: &str,
include_deleted: Option<bool>,
max_age_seconds: Option<i32>,
page: Option<i32>,
page_size: Option<i32>,
) -> Result<models::ListTikTokSmartPlusReviews200Response, Error<ListTikTokSmartPlusReviewsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_include_deleted = include_deleted;
let p_query_max_age_seconds = max_age_seconds;
let p_query_page = page;
let p_query_page_size = page_size;
let uri_str = format!(
"{}/v1/ads/tiktok-smart-plus-reviews",
configuration.base_path
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
req_builder = req_builder.query(&[("adAccountId", &p_query_ad_account_id.to_string())]);
if let Some(ref param_value) = p_query_include_deleted {
req_builder = req_builder.query(&[("includeDeleted", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_age_seconds {
req_builder = req_builder.query(&[("maxAgeSeconds", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_size {
req_builder = req_builder.query(&[("pageSize", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListTikTokSmartPlusReviews200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListTikTokSmartPlusReviews200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTikTokSmartPlusReviewsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Detaches assets from a Google ad group without deleting them, so they stay in the account and on anything else they are attached to. Google assets cannot be deleted. Other attachments remain. assetResourceNames is retained for compatibility. Fields go in the query string. A JSON body with the same fields is also accepted and, when sent, the query string is ignored.
pub async fn remove_ad_group_assets(
configuration: &configuration::Configuration,
ad_set_id: &str,
account_id: &str,
asset_resource_names: Vec<String>,
ad_group_asset_resource_names: Vec<String>,
ad_account_id: Option<&str>,
customer_id: Option<&str>,
) -> Result<models::RemoveCampaignAssets200Response, Error<RemoveAdGroupAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_query_account_id = account_id;
let p_query_asset_resource_names = asset_resource_names;
let p_query_ad_group_asset_resource_names = ad_group_asset_resource_names;
let p_query_ad_account_id = ad_account_id;
let p_query_customer_id = customer_id;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}/assets",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_customer_id {
req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
}
req_builder = match "multi" {
"multi" => req_builder.query(
&p_query_asset_resource_names
.into_iter()
.map(|p| ("assetResourceNames".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"assetResourceNames",
&p_query_asset_resource_names
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
req_builder = match "multi" {
"multi" => req_builder.query(
&p_query_ad_group_asset_resource_names
.into_iter()
.map(|p| ("adGroupAssetResourceNames".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"adGroupAssetResourceNames",
&p_query_ad_group_asset_resource_names
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RemoveCampaignAssets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RemoveCampaignAssets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveAdGroupAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Removes a single keyword or negative keyword from a Google Search ad group. Removes one keyword criterion (positive or negative) from its ad group (M.140).
pub async fn remove_ad_keyword(
configuration: &configuration::Configuration,
keyword_id: &str,
) -> Result<models::RemoveAdKeyword200Response, Error<RemoveAdKeywordError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_keyword_id = keyword_id;
let uri_str = format!(
"{}/v1/ads/keywords/{keywordId}",
configuration.base_path,
keywordId = crate::apis::urlencode(p_path_keyword_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RemoveAdKeyword200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RemoveAdKeyword200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveAdKeywordError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Detaches assets from a Google campaign without deleting them, so they stay in the account and on anything else they are attached to. Google assets cannot be deleted. Other attachments remain. assetResourceNames is retained for compatibility. Fields go in the query string. A JSON body with the same fields is also accepted and, when sent, the query string is ignored.
pub async fn remove_campaign_assets(
configuration: &configuration::Configuration,
campaign_id: &str,
account_id: &str,
asset_resource_names: Vec<String>,
campaign_asset_resource_names: Vec<String>,
ad_account_id: Option<&str>,
customer_id: Option<&str>,
) -> Result<models::RemoveCampaignAssets200Response, Error<RemoveCampaignAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_account_id = account_id;
let p_query_asset_resource_names = asset_resource_names;
let p_query_campaign_asset_resource_names = campaign_asset_resource_names;
let p_query_ad_account_id = ad_account_id;
let p_query_customer_id = customer_id;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/assets",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_customer_id {
req_builder = req_builder.query(&[("customerId", ¶m_value.to_string())]);
}
req_builder = match "multi" {
"multi" => req_builder.query(
&p_query_asset_resource_names
.into_iter()
.map(|p| ("assetResourceNames".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"assetResourceNames",
&p_query_asset_resource_names
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
req_builder = match "multi" {
"multi" => req_builder.query(
&p_query_campaign_asset_resource_names
.into_iter()
.map(|p| ("campaignAssetResourceNames".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"campaignAssetResourceNames",
&p_query_campaign_asset_resource_names
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RemoveCampaignAssets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RemoveCampaignAssets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveCampaignAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Permanently removes an asset group from a Performance Max campaign (this cannot be undone). Removes the asset group on Google (status REMOVED, not reversible). Pass validateOnly=true to validate without removing.
pub async fn remove_google_asset_group(
configuration: &configuration::Configuration,
campaign_id: &str,
asset_group_id: &str,
validate_only: Option<bool>,
) -> Result<models::RemoveGoogleAssetGroup200Response, Error<RemoveGoogleAssetGroupError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_asset_group_id = asset_group_id;
let p_query_validate_only = validate_only;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/asset-groups/{assetGroupId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
assetGroupId = crate::apis::urlencode(p_path_asset_group_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_validate_only {
req_builder = req_builder.query(&[("validateOnly", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RemoveGoogleAssetGroup200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RemoveGoogleAssetGroup200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveGoogleAssetGroupError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sets exactly which shared negative keyword lists apply to a Google campaign, or detaches them all, without changing the lists themselves. Send listIds=[] to detach all negative keyword lists. Only campaign_shared_set links are changed; the lists and their keywords are preserved. Every list must belong to the campaign customer and have type NEGATIVE_KEYWORDS.
pub async fn replace_campaign_negative_keyword_lists(
configuration: &configuration::Configuration,
campaign_id: &str,
replace_campaign_negative_keyword_lists_request: models::ReplaceCampaignNegativeKeywordListsRequest,
) -> Result<
models::ReplaceAdNegativeKeywordListKeywords200Response,
Error<ReplaceCampaignNegativeKeywordListsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_replace_campaign_negative_keyword_lists_request =
replace_campaign_negative_keyword_lists_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/negative-keyword-lists",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_replace_campaign_negative_keyword_lists_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReplaceAdNegativeKeywordListKeywords200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ReplaceAdNegativeKeywordListKeywords200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReplaceCampaignNegativeKeywordListsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Replaces a Google campaign's full list of campaign-level negative keywords, or clears it. Replaces the FULL set of campaign-level negative keywords (C.270): the desired list is diffed against what Google already has, and the difference is applied as one `create`/`remove` mutate. Send an empty array to clear every campaign negative. The platform is always discovered from the campaign itself; a non-Google campaign returns 501 rather than 404, whether or not `platform` was sent.
pub async fn replace_campaign_negative_keywords(
configuration: &configuration::Configuration,
campaign_id: &str,
replace_campaign_negative_keywords_request: models::ReplaceCampaignNegativeKeywordsRequest,
) -> Result<
models::ReplaceCampaignNegativeKeywords200Response,
Error<ReplaceCampaignNegativeKeywordsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_replace_campaign_negative_keywords_request =
replace_campaign_negative_keywords_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/negative-keywords",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_replace_campaign_negative_keywords_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReplaceCampaignNegativeKeywords200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ReplaceCampaignNegativeKeywords200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReplaceCampaignNegativeKeywordsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Replaces the product targeting tree of a Performance Max retail asset group; only works on campaigns linked to Merchant Center. The current product (listing-group) tree is removed and the new one created in one atomic request. Read the current tree with GET on the asset group. - Requires a campaign linked to Merchant Center. Other campaigns return 400 LISTING_SOURCE_NOT_ALLOWED from Google. - validateOnly: true validates without writing.
pub async fn replace_google_listing_group_filters(
configuration: &configuration::Configuration,
campaign_id: &str,
asset_group_id: &str,
replace_google_listing_group_filters_request: models::ReplaceGoogleListingGroupFiltersRequest,
) -> Result<
models::ReplaceGoogleListingGroupFilters200Response,
Error<ReplaceGoogleListingGroupFiltersError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_asset_group_id = asset_group_id;
let p_body_replace_google_listing_group_filters_request =
replace_google_listing_group_filters_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/asset-groups/{assetGroupId}/listing-group-filters",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
assetGroupId = crate::apis::urlencode(p_path_asset_group_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_replace_google_listing_group_filters_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReplaceGoogleListingGroupFilters200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ReplaceGoogleListingGroupFilters200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReplaceGoogleListingGroupFiltersError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Changes an ad's status, budget, targeting or creative and applies the change on the platform. Patch one or more fields on an ad. Status, budget, targeting, and creative changes are propagated to the platform. ### Per-platform support - **Meta** (Facebook + Instagram): all fields supported. - **TikTok**: status, budget, `name` (renames the ad), targeting (via `/v2/adgroup/update/`), and creative (via `/v2/ad/update/` patch-style: `headline` is ignored, `body` becomes `ad_text`). - **Google**: see the Google sections below. - **LinkedIn**: status, budget, targeting and creative (details below). - **Pinterest / X / OpenAI Ads**: status + budget only. Sending `targeting` or `creative` returns 501 with code `feature_not_available`. OpenAI Ads budget is the campaign's spend cap, daily or lifetime (see `budget.type` below). - **Reddit Ads**: status, budget, `name` (renames the ad) and targeting (details below). ### Google Supported: status, budget, and these targeting edits: - KEYWORD edits via `targeting.keywords` / `targeting.negativeKeywords` - DEVICE bid adjustments via `targeting.devices` - LOCATION edits via `targeting.locations` (or the equivalent top-level `targeting.countries` / `regions` / `cities` / `zips` / `metros`) - LANGUAGE edits via `targeting.languages` Each list you send becomes the FULL new set of its kind: criteria not in the list are removed. Devices are the exception: Google cannot remove them, so they are switched off with a bid modifier of 0 instead. A kind left out is untouched. Any other `targeting` field returns 400: Google cannot mutate it post-create without recreating the campaign. Creative edits are dispatched on the ad's `advertisingChannelType`. Every supported field replaces a whole set; a field you omit is preserved. - **Search**: top-level `headlines`, `descriptions` and `finalUrls`. Use 3-15 headlines (1-30 characters) and 2-4 descriptions (1-90 characters). Omit an asset to remove it; omit pinnedField on an included asset to unpin it. Updates do not pad or truncate text. The legacy creative fields remain unsupported. - **Display**: top-level `headlines` (1-5, no pinnedField, display ads have no pinned positions), `descriptions` (1-5) and `finalUrls`, plus `creative.longHeadline`, `creative.businessName`, `creative.imageUrl` (the landscape marketing image) and `creative.squareImageUrl`. - **Performance Max**: top-level `assetGroup`, which swaps asset roles on the ad's asset group. The other creative fields return 422 for this channel, and `assetGroup` returns 422 on any other channel. - **Demand Gen**: top-level `demandGen` (see GoogleDemandGenUpdate): creative, channel and audience changes in one atomic Google request. The other creative fields return 422 for this channel. For Display, each image URL is uploaded as a new Google asset and the ad is pointed at it. Google assets are immutable, so the previous asset stays in the account's asset library. A new landscape image also updates `creative.assetResourceName` to the new asset, and each replaced image updates its own role in `creative.assets`. For Demand Gen, `targeting` takes locations, languages, `locationTargetingType` and `devices`. Locations and languages are written to the ad's ad group, which Demand Gen requires, so they apply to every ad in that ad group. Campaigns migrated from Discovery that still target on the campaign keep being written there. ### LinkedIn - **Status and budget**: supported. - **Targeting**: countries or regions, excludedLocations (countries), the B2B facets, and audience segments. Applied to the LinkedIn Campaign via PARTIAL_UPDATE, and REPLACES the campaign's entire targetingCriteria, not a merge. - **Creative**: uploads new media, creates a replacement inline creative on the same campaign, and removes the old one (it is deleted, the ad's `platformAdId` and `creative.creativeId` move to the new creative, and the new creative keeps the old one's held-off state: `DRAFT` stays `DRAFT`). - **Name**: updating `name` returns 400 (LinkedIn does not support renaming an ad). ### Reddit Ads - `budget` goes to the ad's ad group, or to its campaign when the ad group spends a campaign budget. It keeps its daily or lifetime type (422 to switch). - `targeting` REPLACES the ad group's whole targeting (geo, communities, conversation keywords, interests, audiences, languages, gender), so it applies to every ad in the ad group. - `creative` returns 501: a Reddit ad runs a post, so create a new ad with the new creative instead. ### Google location and language replacement Locations, languages and devices are campaign-level criteria on Google, so these edits apply to every ad group and ad in the ad's campaign. Send the complete list you want to keep. Zernio diffs it against the campaign's live criteria and sends the removes and the creates in ONE `googleAds:mutate`, so the campaign is never left with a half-applied set. Criteria already in the list keep their criterion ID and history. Excluded (negative) locations are left untouched. - An empty location list returns 400. A Google campaign with no location criteria targets every country, which is never what \"remove my locations\" means, so omit the field instead. - Send either `targeting.locations` or the top-level geo fields, not both: mixing them returns 400. ### Google radius targeting `customLocations` is editable and is replaced the same way, but as its OWN set. Google models a place (LOCATION) and a point plus radius (PROXIMITY) as different criterion types, so the two are independent: - Sending `customLocations` replaces every radius and leaves the cities and countries alone. - Sending places replaces those and leaves the radius alone. - Send `customLocations: []` to drop radius targeting entirely. A circle you re-send unchanged keeps its criterion ID rather than being removed and recreated. ### Google keyword replacement These edits affect the ad's entire ad group, including sibling ads. Positive (`targeting.keywords`) and negative (`targeting.negativeKeywords`) sets are independent: omit a field to leave that set unchanged, or send `[]` to remove every keyword of that kind. Zernio compares each supplied set with Google's live criteria by case-insensitive keyword text and match type. Text comparison does not trim whitespace. A matching criterion is left untouched, retaining its criterion ID, enabled/paused status, keyword-level bid overrides, labels, and criterion-associated history/statistics. Zernio does not reset its quality score; Google continues to calculate scores and statistics normally. A bare string or an object without `matchType` means `broad`, not the existing criterion's match type. For example, resending an existing `{ \"text\": \"plumber\", \"matchType\": \"exact\" }` preserves it; sending `\"plumber\"` instead removes that EXACT criterion and requests a BROAD one. Changing text or match type removes criteria no longer requested and creates any missing criteria. New criteria get new IDs and do not inherit removed criteria's bid overrides, labels, or history. Historical reporting for a removed criterion is not transferred to its replacement. ### Other keyword endpoints - To add keywords without replacing a set, use [POST /v1/ads/keywords](https://docs.zernio.com/ad-campaigns/add-ad-keywords). - Use `PATCH /v1/ads/keywords/{keywordId}` to pause/enable one keyword. - Use `DELETE /v1/ads/keywords/{keywordId}` to remove it.
pub async fn update_ad(
configuration: &configuration::Configuration,
ad_id: &str,
update_ad_request: models::UpdateAdRequest,
) -> Result<models::UpdateAd200Response, Error<UpdateAdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_id = ad_id;
let p_body_update_ad_request = update_ad_request;
let uri_str = format!(
"{}/v1/ads/{adId}",
configuration.base_path,
adId = crate::apis::urlencode(p_path_ad_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateAd200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateAd200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Changes a campaign's settings, such as its name, budget, bidding or tracking URLs. Send at least one of `budget`, `bidStrategy`, `portfolioBidStrategyId`, `targetImpressionShare`, `manualCpc`, `networkSettings`, `trackingUrlTemplate`, `finalUrlSuffix`, `sharedBudgetId`, `name` or `platformSpecificData`. An unsupported field is always an error, never a silent drop. | Body field | Meta | Google | Others | |---|---|---|---| | `bidStrategy` | Yes | Yes | 501 | | `bidAmount`, `roasAverageFloor` | 400 (ad-set level) | Yes | 400 | | `portfolioBidStrategyId` | 400 | Yes | 400 | | `targetImpressionShare` | 400 | Search only | 400 | | `manualCpc` | 400 | Search and Display | 400 | | `networkSettings` | 400 | Search only | 400 | | `trackingUrlTemplate`, `finalUrlSuffix` | 400 | Yes | 400 | | `sharedBudgetId` | 400 | Yes | 400 | | `budget` (CBO; ABO returns 409) | Yes | Daily only | OpenAI and Reddit: daily or lifetime; others 501 | | `name` | Yes | 501 | Reddit: Yes; others 501 | | `platformSpecificData.spendCap` | Yes | 400 | 400 | | `accountId` (empty campaigns) | Yes | - | - | ### Meta Meta budget edits check the live campaign budget, so an older local ABO stamp cannot block a CBO campaign. A successful edit repairs local ad budget fields. A live ABO campaign still returns 409 with the ad-set budget endpoint. `accountId` forwards the update straight to Meta for a campaign with zero ads, which would otherwise 404. The response then carries `updated: 0`. ### Google bidding - `LOWEST_COST_WITHOUT_CAP` = Maximize Conversions - `COST_CAP` + `bidAmount` = Target CPA - `LOWEST_COST_WITH_MIN_ROAS` + `roasAverageFloor` = Target ROAS - `LOWEST_COST_WITH_BID_CAP` + `bidAmount` = Maximize Clicks with a CPC ceiling - `portfolioBidStrategyId` attaches a portfolio strategy instead (exclusive with `bidStrategy`) - `targetImpressionShare` switches the campaign to Target impression share - `manualCpc: { maxCpc }` switches to Manual CPC: every ad group of the campaign gets `maxCpc` as its bid, in the same mutate `targetImpressionShare` and `manualCpc` are each exclusive with every other strategy field. Setting the standard triplet on a campaign that is currently on a PORTFOLIO strategy is rejected. Detach it in Google Ads first, since it is shared across campaigns. ### Google network and tracking URLs `networkSettings`, `trackingUrlTemplate` and `finalUrlSuffix` go out in one campaign update. Each field is sent written on its own leaf, so an omitted one keeps its current value. An empty string clears a URL field. ### Google budgets Google budget updates read the current budget before mutation. Shared budgets return 409 unless allowSharedBudgetUpdate=true is explicitly supplied, because the change affects every campaign using that budget. A budget counts as shared when Google flags it as shared or when more than one campaign uses it (older budgets can serve several campaigns without the flag). Unknown sharing state also returns 409. ### Google shared budgets (`sharedBudgetId`) - `sharedBudgetId` moves the campaign onto a shared budget from GET /v1/ads/shared-budgets. It also needs `allowSharedBudgetUpdate: true` (409 otherwise), because the campaign then splits that budget with every campaign on it. `budget` cannot ride along. - `sharedBudgetId: null` moves it back onto a new budget of its own, sized by `budget` (required, daily). The new budget and the switch go out in one atomic Google mutate. - A campaign that already has its own budget returns 409 for null. The budget a campaign leaves is not removed. The response carries the budget the campaign now uses. ### OpenAI Ads Campaigns carry exactly one spend cap. `budget.type` daily or lifetime replaces whichever cap the campaign had, with a minimum of 1 in the ad account's currency (422 below it). Lifetime can switch to daily, but OpenAI never switches a daily cap back to lifetime (422). ### Reddit Ads - `budget` changes the amount of a campaign budget (Reddit campaign budget optimization). - A campaign whose ad groups carry the budget returns 409 or 422; use PUT /v1/ads/ad-sets/{adSetId} there. - Reddit cannot switch a published budget between daily and lifetime, so `budget.type` must match the current one (422 otherwise). - `bidStrategy` is set per ad group on Reddit (PUT /v1/ads/ad-sets/{adSetId}).
pub async fn update_ad_campaign(
configuration: &configuration::Configuration,
campaign_id: &str,
update_ad_campaign_request: models::UpdateAdCampaignRequest,
) -> Result<models::UpdateAdCampaign200Response, Error<UpdateAdCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_update_ad_campaign_request = update_ad_campaign_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_campaign_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateAdCampaign200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateAdCampaign200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Pauses or resumes a campaign, leaving the on/off switches of its ad sets and ads as they are. It writes the campaign's own on/off switch and nothing else, on every platform: Meta, TikTok, Google, LinkedIn campaign group, Pinterest, X, ChatGPT (OpenAI). Its ad sets and ads keep their own switches: - Pausing stops their delivery through the campaign. - Resuming lets each of them deliver again only if its own switch is on. An ad set or ad you paused individually stays paused. Resume it with PUT /v1/ads/ad-sets/{adSetId}/status or PUT /v1/ads/{adId}/status. See the Status model in the Ad Campaigns tag. ### Live read, then write The campaign's switch is read from the platform first. - **Already in the requested state:** nothing is written (`updated: 0`, `skipped: 1`, with the reason). - **Otherwise:** the switch is written (`updated: 1`), read back and stored. The delivery status of the ads under it (up to 20) is re-read and stored, so an immediate GET returns what the platform now reports. When the campaign delivers in the requested state but some of its ads are stored in the other state, those ads are re-read and stored (up to 20, at most once every 10 minutes per campaign). An example is ads switched on in the platform's own UI and still stored `paused`. A stored switch never skips a write, and when the platform cannot be read the write always goes out. On Meta the check reads the campaign's own `status`, so a delivery status such as `IN_PROCESS` or `WITH_ISSUES` does not force a write. ### Retrying Retrying the same request is safe: when the first call already switched the campaign, the live read answers `skipped: 1` and nothing is written twice. A call that timed out on your side may still have completed, so retry it instead of assuming it failed. These errors fail the same way on every retry until something changes: - `401` `reconnect_required`: the platform no longer accepts the connection's token (on Meta, code 190: expired, revoked, password changed or security checkpoint). Reconnect the account, then retry. - `422` `ad_account_unusable`: the ad account's status does not allow edits. Resolve it in the platform, then retry. - `400` `platform_api_error` saying the campaign was deleted or archived (Meta subcodes 1487566 and 3858863): there is nothing left to switch. A Meta code 190 with subcode 464 means Meta considers the Facebook user unconfirmed. It answers `400` `platform_api_error` and retrying does not clear it: the user must log in to facebook.com and complete what Meta asks (usually confirming their email or phone), then retry.
pub async fn update_ad_campaign_status(
configuration: &configuration::Configuration,
campaign_id: &str,
update_ad_campaign_status_request: models::UpdateAdCampaignStatusRequest,
) -> Result<models::UpdateAdCampaignStatus200Response, Error<UpdateAdCampaignStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_update_ad_campaign_status_request = update_ad_campaign_status_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/status",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_campaign_status_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateAdCampaignStatus200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateAdCampaignStatus200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdCampaignStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Edits a Google ad group's existing assets in place; the change applies everywhere that asset is used. Send updates with assetResourceName and the fields to change. An asset is shared: changes affect every attachment using it. Omitted fields stay unchanged. The operation consumes the Google operations budget and invalidates affected cached lists.
pub async fn update_ad_group_assets(
configuration: &configuration::Configuration,
ad_set_id: &str,
update_campaign_assets_request: models::UpdateCampaignAssetsRequest,
) -> Result<models::UpdateCampaignAssets200Response, Error<UpdateAdGroupAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_body_update_campaign_assets_request = update_campaign_assets_request;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}/assets",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_campaign_assets_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateCampaignAssets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateCampaignAssets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdGroupAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Pauses or re-enables a single Google Search keyword. Changes `ad_group_criterion.status` for one keyword criterion (M.140). Negative keywords have no status on Google and cannot be paused or enabled.
pub async fn update_ad_keyword(
configuration: &configuration::Configuration,
keyword_id: &str,
update_ad_keyword_request: models::UpdateAdKeywordRequest,
) -> Result<models::UpdateAdKeyword200Response, Error<UpdateAdKeywordError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_keyword_id = keyword_id;
let p_body_update_ad_keyword_request = update_ad_keyword_request;
let uri_str = format!(
"{}/v1/ads/keywords/{keywordId}",
configuration.base_path,
keywordId = crate::apis::urlencode(p_path_keyword_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_keyword_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateAdKeyword200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateAdKeyword200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdKeywordError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Changes an ad set's settings, such as its budget, bid strategy, status or delivery options. At least one updatable field is required. Use it for: - ABO budget updates. - Ad-set-scoped pause/resume. - Bid-strategy edits. - Meta value-rule-set attach/detach. - Meta beneficiary and payer: `dsaBeneficiary` / `dsaPayor` for the EU, `regionalRegulatedCategories` / `regionalRegulationIdentities` for the regional regimes. - Meta-only post-launch delivery settings via `platformSpecificData`. ### Value rule sets (Meta only) See `/v1/ads/value-rule-sets`. - ATTACH or REPLACE: send `valueRuleSetId`. Attachment is driven by the id's presence, so `valueRulesApplied: true` is optional. Sending a different id replaces the previous association; there is no separate replace call. - DETACH: send `valueRulesApplied: false` and OMIT `valueRuleSetId`. - Sending `valueRulesApplied: false` TOGETHER with `valueRuleSetId` returns 400 `mutually_exclusive_fields`. - Eligibility: only ad sets on `LOWEST_COST_WITHOUT_CAP` or `COST_CAP`. Meta rejects the rest server-side. - Read back with `GET /v1/ads/ad-sets/{adSetId}?fields=value_rule_set_id`. Meta does not document `value_rules_applied` as a readable ad-set field, so the boolean cannot be read back. The `mutually_exclusive_fields` error is deliberate. Meta attaches the rule set whenever `value_rule_set_id` is present, even with `value_rules_applied` false, so echoing stored state while asking to detach would silently keep the bid adjustments live. ### Bid strategy compatibility (per Meta's spec) - `LOWEST_COST_WITHOUT_CAP`: no `bidAmount`, no `roasAverageFloor`. - `LOWEST_COST_WITH_BID_CAP` / `COST_CAP`: `bidAmount` REQUIRED (whole currency units). - `LOWEST_COST_WITH_MIN_ROAS`: `roasAverageFloor` REQUIRED (decimal multiplier, e.g. 2.0 = 2.0x ROAS). Meta only: send `bidAmount` WITHOUT `bidStrategy` to change the cap amount on an ad set whose strategy (its own, or the campaign's under CBO) is COST_CAP / LOWEST_COST_WITH_BID_CAP, leaving the strategy untouched. Send `roasAverageFloor` WITHOUT `bidStrategy` the same way to change the floor of a LOWEST_COST_WITH_MIN_ROAS ad set. Either field against an incompatible current strategy is a 400. Meta CBO (the campaign holds the budget): the campaign also holds the bid strategy, so only `bidAmount` or `roasAverageFloor` is written on the ad set. A `bidStrategy` equal to the campaign's is accepted; a different one is a 409 (change it with PUT /v1/ads/campaigns/{campaignId}). ### Delivery settings and budget Delivery settings are validated by Meta against the campaign objective. Incompatible combinations (e.g. a billingEvent the optimization goal doesn't allow) surface as 400s from Meta. When updating `budget` on an ad set whose campaign holds the budget (CBO), the response is 409 with code `invalid_field_value`. Send it to PUT /v1/ads/campaigns/{campaignId} instead. ### Status `status` behaves exactly as PUT /v1/ads/ad-sets/{adSetId}/status describes. Only the ad set's own switch is written and its ads keep theirs. `statusUpdated` / `statusSkipped` report whether that switch was written or a live read showed it already in place. ### Placements and targeting (Meta only) `placements` and `targeting` take the same shapes as POST /v1/ads/create. Meta replaces an ad set's targeting wholesale, so Zernio reads the live targeting first, changes only what the request names and writes the merged spec back. Custom audiences, geo, age, interest groups and `targeting_automation` you do not send are kept. - `placements` replaces the whole placement set. - `placements: null` returns the ad set to automatic placements. - Omitting it leaves placements as they are. Other platforms return 400 for either field before anything in the request is written (use PUT /v1/ads/{adId} with `targeting` where that platform supports it). The live read and the `incomeTier` lookup run before any other field is written, so a 502 or 422 from them leaves the ad set unchanged. ### Reddit Ads: budget, name and bidding - `budget` changes the ad group's amount. An ad group that spends its campaign budget returns 422 (update the campaign instead). - Reddit cannot switch a published budget between daily and lifetime, so `budget.type` must match the current one (422 otherwise). - `name` renames the ad group. `bidStrategy` maps to the ad group's `bid_strategy`: - LOWEST_COST_WITHOUT_CAP: automatic bidding (BIDLESS). - LOWEST_COST_WITH_BID_CAP: MANUAL_BIDDING with `bidAmount` as the bid. - COST_CAP: MAXIMIZE_VOLUME with `bidAmount` as the cap. - LOWEST_COST_WITH_MIN_ROAS: returns 422. ### Reddit Ads: targeting and schedule `targeting` (same shape as on create; `placements` is a 400) and `startDate` / `endDate` change the ad group with one PATCH to Reddit. Read the current values with GET /v1/ads/ad-sets/{adSetId}/targeting. Zernio reads the live ad group first and replaces only the targeting groups the request names: - The included locations (`countries`, `regions`, `metros`, `cities`, `zips`) are one list on Reddit, so sending any of them replaces all included locations. - Devices, platforms, carriers and automated expansion set in Reddit Ads Manager are kept. The schedule is checked against the campaign before anything in the request is written. Each of these returns 400 naming `startDate` or `endDate`: - The ad group starts before a campaign that starts in the future. - The ad group ends after the campaign's end. - Under campaign budget optimization, it must end by the campaign end (and has no end date when the campaign has none). Zernio never resends the PATCH on its own, so after a 5xx read the ad group back before retrying.
pub async fn update_ad_set(
configuration: &configuration::Configuration,
ad_set_id: &str,
update_ad_set_request: models::UpdateAdSetRequest,
) -> Result<models::UpdateAdSet200Response, Error<UpdateAdSetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_body_update_ad_set_request = update_ad_set_request;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_set_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateAdSet200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateAdSet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdSetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Pauses or resumes one ad set without touching its campaign, its sibling ad sets or the switches of its ads. It is a thin wrapper over PUT /v1/ads/ad-sets/{adSetId} for callers that only want the status toggle and prefer a symmetric URL to /v1/ads/campaigns/{campaignId}/status. ### What is written It writes the ad set's own on/off switch and nothing else, on every platform: - Meta: `configured_status` - TikTok: ad group `operation_status` - Google: ad group status - LinkedIn: campaign - Pinterest: ad group - X: line item - ChatGPT (OpenAI): ad group - Reddit: ad group `configured_status` Its ads keep their own switches: an ad you paused individually stays paused when the ad set resumes. The campaign above is not touched either, so an ad set resumed under a paused campaign reads `status: paused` until the campaign is resumed too. See the Status model in the Ad Campaigns tag. ### Live read, then write The ad set's switch is read from the platform first. - When that live read shows it already in the requested state, nothing is written (`updated: 0`, `skipped: 1`, with the reason). - In that case, when the ad set delivers in that state but some of its ads are stored in the other state, those ads (up to 20, at most once every 10 minutes per ad set) are re-read and stored. - Otherwise the switch is written (`updated: 1`), read back and stored. The delivery status of its ads (up to 20) is re-read and stored, so an immediate GET returns what the platform now reports. A stored switch never skips a write, and when the platform cannot be read the write always goes out. On Meta and Reddit the check reads the ad set's own switch (`status` / `configured_status`). So a repeated request skips even while `platformAdSetStatus` reads `CAMPAIGN_PAUSED`, `WITH_ISSUES` or `IN_PROCESS`.
pub async fn update_ad_set_status(
configuration: &configuration::Configuration,
ad_set_id: &str,
update_ad_campaign_status_request: models::UpdateAdCampaignStatusRequest,
) -> Result<models::UpdateAdSetStatus200Response, Error<UpdateAdSetStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_set_id = ad_set_id;
let p_body_update_ad_campaign_status_request = update_ad_campaign_status_request;
let uri_str = format!(
"{}/v1/ads/ad-sets/{adSetId}/status",
configuration.base_path,
adSetId = crate::apis::urlencode(p_path_ad_set_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_campaign_status_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateAdSetStatus200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateAdSetStatus200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdSetStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Pauses or resumes a single ad without touching its ad set, campaign or sibling ads. ### What it flips Ad-scoped pause/resume flips ONLY this ad's own switch, never its parent ad set or campaign, so sibling ads keep running: - Meta `configured_status` - TikTok `operation_status` - Google ad group ad status - LinkedIn creative - Pinterest ad - Reddit ad `configured_status` X is the exception: its smallest switch is the line item. It is a thin wrapper over the `status` field of PUT /v1/ads/{adId}, for callers that want a URL symmetric to /v1/ads/campaigns/{campaignId}/status and /v1/ads/ad-sets/{adSetId}/status. ### Own switch vs delivery status The ad's own switch is independent of its delivery status. - An ad paused only because its campaign or ad set is off (`status: paused`, `configuredStatus: ACTIVE`) can still be switched off here. - Switching an ad on under a paused campaign leaves it `paused` until the campaign is resumed. After the write the switch is read back from the platform and returned as `configuredStatus`, together with the resulting delivery `status`. ### Identifiers `{adId}` accepts the same identifier dialects as GET/PUT /v1/ads/{adId}: Zernio hex `_id`, Meta numeric `platformAdId`, or the creative's effective story/media IDs. `platform` is inferred from the ad, so it's not required in the body. ### Skips These requests are skipped: - Ads in terminal statuses (rejected, completed, cancelled). - A request whose target already matches the ad's own switch as read LIVE from the platform. A stored value is never trusted alone, since the switch may have been changed in the platform's own UI. A skip also returns that live read. The rolled-up `status` never decides a skip.
pub async fn update_ad_status(
configuration: &configuration::Configuration,
ad_id: &str,
update_ad_keyword_request: models::UpdateAdKeywordRequest,
) -> Result<models::UpdateAdStatus200Response, Error<UpdateAdStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_ad_id = ad_id;
let p_body_update_ad_keyword_request = update_ad_keyword_request;
let uri_str = format!(
"{}/v1/ads/{adId}/status",
configuration.base_path,
adId = crate::apis::urlencode(p_path_ad_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_keyword_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateAdStatus200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateAdStatus200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Renames a shared Google Ads bid strategy or changes its target CPA or ROAS. The strategy's status is output only on Google's side, so it cannot be changed here; remove a strategy in Google Ads. ### When to send `type` `type` is only needed alongside `targetCpa`/`targetRoas`, to disambiguate the field Google writes to: - TARGET_CPA and MAXIMIZE_CONVERSIONS both take a target CPA. - TARGET_ROAS and MAXIMIZE_CONVERSION_VALUE both take a target ROAS. The strategy's family is otherwise immutable once created.
pub async fn update_bid_strategy(
configuration: &configuration::Configuration,
strategy_id: &str,
update_bid_strategy_request: models::UpdateBidStrategyRequest,
) -> Result<models::UpdateBidStrategy200Response, Error<UpdateBidStrategyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_strategy_id = strategy_id;
let p_body_update_bid_strategy_request = update_bid_strategy_request;
let uri_str = format!(
"{}/v1/ads/bid-strategies/{strategyId}",
configuration.base_path,
strategyId = crate::apis::urlencode(p_path_strategy_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_bid_strategy_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateBidStrategy200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateBidStrategy200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateBidStrategyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Replaces the days and hours a Google campaign runs, or clears them so it serves around the clock. This is a REPLACE, not a merge: windows you leave out stop serving. Send `schedule: []` to clear dayparting, which returns the campaign to serving around the clock. ### Rules Google rules are enforced here, so you get a named field instead of a criterion error: - at most 6 windows per day - a window must end after it starts - windows on the same day may not overlap - `endHour` 24 is midnight and cannot carry minutes - minutes are quarter-hours only (0, 15, 30, 45) - `bidModifier` is 0.1-10.0. Google's 0 means \"off\" for devices only, so a window is switched off by leaving it out. Windows are half-open (Google is exclusive of the end minute), so 09:00-12:00 and 12:00-17:00 on the same day are adjacent and both valid. ### How it is applied Google cannot edit an ad schedule in place (every AdScheduleInfo field is prohibited on update). So this removes the live criteria and creates the new ones in a single atomic mutate. The response is read back from Google and carries the new criterion ids.
pub async fn update_campaign_ad_schedule(
configuration: &configuration::Configuration,
campaign_id: &str,
update_campaign_ad_schedule_request: models::UpdateCampaignAdScheduleRequest,
) -> Result<models::UpdateCampaignAdSchedule200Response, Error<UpdateCampaignAdScheduleError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_update_campaign_ad_schedule_request = update_campaign_ad_schedule_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/ad-schedule",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_campaign_ad_schedule_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateCampaignAdSchedule200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateCampaignAdSchedule200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCampaignAdScheduleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Edits a Google campaign's existing assets, such as sitelinks or callouts, in place; the change applies everywhere that asset is used. Send updates with assetResourceName and the fields to change. An asset is shared: changes affect every attachment using it. Omitted fields stay unchanged. The operation consumes the Google operations budget and invalidates affected cached lists.
pub async fn update_campaign_assets(
configuration: &configuration::Configuration,
campaign_id: &str,
update_campaign_assets_request: models::UpdateCampaignAssetsRequest,
) -> Result<models::UpdateCampaignAssets200Response, Error<UpdateCampaignAssetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_update_campaign_assets_request = update_campaign_assets_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/assets",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_campaign_assets_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateCampaignAssets200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateCampaignAssets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCampaignAssetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Changes which conversions a Google campaign bids on, switching between account-default goals, its own goals or a custom goal. In one mutate, it can: - set `biddable` on campaign goals - switch `goalConfigLevel` - point the campaign at a custom conversion goal `customConversionGoalId: null` clears it. Google refuses that (400) while the campaign stays at CAMPAIGN level with no biddable goals, so send `goalConfigLevel: CUSTOMER` with it to fall back to the account goals. Returns the re-read campaign goals.
pub async fn update_campaign_conversion_goals(
configuration: &configuration::Configuration,
campaign_id: &str,
update_campaign_conversion_goals_request: models::UpdateCampaignConversionGoalsRequest,
) -> Result<
models::UpdateCampaignConversionGoals200Response,
Error<UpdateCampaignConversionGoalsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_update_campaign_conversion_goals_request = update_campaign_conversion_goals_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/conversion-goals",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_campaign_conversion_goals_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateCampaignConversionGoals200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateCampaignConversionGoals200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCampaignConversionGoalsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Changes a Google campaign's device, location, excluded location or language targeting after it was created. Google only; every other platform returns 501. Google Ads compliance row M.10: geo and language targeting set at creation must stay editable afterwards. Send at least one of `devices`, `locations`, `excludedLocations`, `languages`, `locationTargetingType`. Each provided field REPLACES that field's existing criteria on the campaign (a full set, not a delta). Fields left out of the body are untouched. ### Fields - `devices`: the full set of device bid modifiers. A supported device you leave out is switched off with a bid modifier of 0, since Google cannot remove a device criterion. A device the campaign's channel does not carry, and a set that switches every device off, both return 422. - `locations`: see below. - `excludedLocations`: see below. - `languages`: an array of Google's language codes (ISO 639-1, plus variants such as `zh_CN`). An unknown code returns 400. - `locationTargetingType`: switches who the location targeting reaches. `presence` (people in or regularly in the locations) or `presence_or_interest` (also people searching for or interested in them). Example: `{ \"platform\": \"google\", \"targeting\": { \"locationTargetingType\": \"presence\" } }`. ### Locations `locations` accepts the same shapes as campaign creation: a bare array of ISO country codes, or an object with `countries`/`regions`/`cities`/`zips`/`metros` key lists (`key` from GET /v1/ads/targeting/search?dimension=geo). Excluded locations are left untouched by `locations`. An empty location list returns 400 instead of removing every criterion: a Google campaign with no location criteria targets every country, so omit `locations` to leave targeting alone. ### Excluded locations `excludedLocations` takes the same two shapes and replaces the campaign's negative location criteria (the places it never serves in), leaving the targeted `locations` untouched. - An empty list (or `{}`) removes every exclusion. - Radius exclusions are not supported. - A place cannot be both targeted and excluded: a request whose result would leave one on both sides returns 400 before anything is written. - Moving a place from one side to the other in the same request is applied atomically. Example: `{ \"platform\": \"google\", \"targeting\": { \"excludedLocations\": { \"countries\": [\"CA\"], \"regions\": [\"21137\"] } } }`. ### Atomic writes and response The removes and the creates go out in ONE Google `googleAds:mutate`, so a failed edit leaves the campaign's previous set intact rather than a half-applied one. The response includes the refreshed `devices`/`locations`/`excludedLocations`/`languages` state read back from Google after the edit. It also invalidates the cached copy `GET` on this campaign would otherwise keep serving. ### Demand Gen Google keeps a Demand Gen campaign's locations and languages on its ad groups and refuses them on the campaign. - With one ad group, they are written there and the response carries its `adGroupId` (the campaign-level `locations`/`languages` read back then stay empty). - With several ad groups, the call returns 400 naming them. Edit each one with PUT /v1/ads/{adId} `targeting` on an ad of that ad group. - Campaigns migrated from Discovery that still target on the campaign keep being written there. - `devices` and `locationTargetingType` stay campaign-level. - `excludedLocations` is not available on Demand Gen yet and returns 400.
pub async fn update_campaign_targeting(
configuration: &configuration::Configuration,
campaign_id: &str,
update_campaign_targeting_request: models::UpdateCampaignTargetingRequest,
) -> Result<models::UpdateCampaignTargeting200Response, Error<UpdateCampaignTargetingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_update_campaign_targeting_request = update_campaign_targeting_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/targeting",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_campaign_targeting_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateCampaignTargeting200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateCampaignTargeting200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCampaignTargetingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Changes a Performance Max asset group's name, status, final URLs or display paths. Change the name, status (ENABLED or PAUSED), final URLs or display paths. Only the fields sent are written; null on path1 or path2 clears it. Change assets with the /assets endpoint and product targeting with /listing-group-filters. validateOnly: true validates without writing.
pub async fn update_google_asset_group(
configuration: &configuration::Configuration,
campaign_id: &str,
asset_group_id: &str,
update_google_asset_group_request: models::UpdateGoogleAssetGroupRequest,
) -> Result<models::UpdateGoogleAssetGroup200Response, Error<UpdateGoogleAssetGroupError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_asset_group_id = asset_group_id;
let p_body_update_google_asset_group_request = update_google_asset_group_request;
let uri_str = format!(
"{}/v1/ads/campaigns/{campaignId}/asset-groups/{assetGroupId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
assetGroupId = crate::apis::urlencode(p_path_asset_group_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_google_asset_group_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UpdateGoogleAssetGroup200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UpdateGoogleAssetGroup200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateGoogleAssetGroupError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}