get_campaign_by_id
Retrieve detailed Facebook ad campaign data by campaign ID, including objective, status, budgets, and configuration. Use this to inspect or audit a specific campaign's settings.
Instructions
Retrieves detailed information about a specific Facebook ad campaign by its ID.
This function accesses the Facebook Graph API to retrieve information about a single campaign, including details about its objective, status, budget settings, and other campaign-level configurations.
Args: campaign_id (str): The ID of the campaign to retrieve information for. fields (Optional[List[str]]): A list of specific fields to retrieve. If None, a default set of fields will be returned. Available fields include: - 'id': The campaign's ID - 'name': The campaign's name - 'account_id': The ID of the ad account this campaign belongs to - 'adlabels': Labels applied to the campaign - 'bid_strategy': The bid strategy for the campaign. Options include: 'LOWEST_COST_WITHOUT_CAP', 'LOWEST_COST_WITH_BID_CAP', 'COST_CAP' - 'boosted_object_id': The ID of the boosted object - 'brand_lift_studies': Brand lift studies associated with this campaign - 'budget_rebalance_flag': Whether budget rebalancing is enabled - 'budget_remaining': The remaining budget (in cents/smallest currency unit) - 'buying_type': The buying type. Options include: 'AUCTION', 'RESERVED', 'DEPRECATED_REACH_BLOCK' - 'can_create_brand_lift_study': Whether a brand lift study can be created - 'can_use_spend_cap': Whether a spend cap can be used - 'configured_status': Status set by the user. Options include: 'ACTIVE', 'PAUSED', 'DELETED', 'ARCHIVED' - 'created_time': When the campaign was created - 'daily_budget': The daily budget (in cents/smallest currency unit) - 'effective_status': The effective status accounting for the ad account and other factors. Options include: 'ACTIVE', 'PAUSED', 'DELETED', 'PENDING_REVIEW', 'DISAPPROVED', 'PREAPPROVED', 'PENDING_BILLING_INFO', 'CAMPAIGN_PAUSED', 'ARCHIVED', 'IN_PROCESS', 'WITH_ISSUES' - 'has_secondary_skadnetwork_reporting': Whether secondary SKAdNetwork reporting is available - 'is_budget_schedule_enabled': Whether budget scheduling is enabled - 'is_skadnetwork_attribution': Whether the campaign uses SKAdNetwork attribution (iOS 14.5+) - 'issues_info': Information about issues with this campaign - 'last_budget_toggling_time': Last time the budget was toggled - 'lifetime_budget': The lifetime budget (in cents/smallest currency unit) - 'objective': The campaign's advertising objective. Options include: 'APP_INSTALLS', 'BRAND_AWARENESS', 'CONVERSIONS', 'EVENT_RESPONSES', 'LEAD_GENERATION', 'LINK_CLICKS', 'LOCAL_AWARENESS', 'MESSAGES', 'OFFER_CLAIMS', 'PAGE_LIKES', 'POST_ENGAGEMENT', 'PRODUCT_CATALOG_SALES', 'REACH', 'STORE_VISITS', 'VIDEO_VIEWS' - 'pacing_type': List of pacing types. Options include: 'standard', 'no_pacing' - 'primary_attribution': Primary attribution settings - 'promoted_object': The object this campaign is promoting - 'recommendations': Recommendations for improving this campaign - 'smart_promotion_type': Smart promotion type if applicable - 'source_campaign': Source campaign if this was created by copying - 'source_campaign_id': ID of the source campaign if copied - 'special_ad_categories': Array of special ad categories. Options include: 'EMPLOYMENT', 'HOUSING', 'CREDIT', 'ISSUES_ELECTIONS_POLITICS', 'NONE' - 'special_ad_category': Special ad category (deprecated in favor of special_ad_categories) - 'spend_cap': The spending cap (in cents/smallest currency unit) - 'start_time': When the campaign starts (in ISO 8601 format unless date_format specified) - 'status': Deprecated. Use 'configured_status' or 'effective_status' instead - 'stop_time': When the campaign stops (in ISO 8601 format unless date_format specified) - 'topline_id': Topline ID for this campaign - 'updated_time': When this campaign was last updated date_format (Optional[str]): Format for date responses. Options: - 'U': Unix timestamp (seconds since epoch) - 'Y-m-d H:i:s': MySQL datetime format - None: ISO 8601 format (default)
Returns: Dict: A dictionary containing the requested campaign information.
Example: ```python # Get basic campaign information campaign = get_campaign_by_id( campaign_id="23843211234567", fields=["name", "objective", "effective_status", "budget_remaining"] )
# Get detailed budget information with Unix timestamps
campaign_budget_details = get_campaign_by_id(
campaign_id="23843211234567",
fields=["name", "daily_budget", "lifetime_budget", "start_time", "stop_time"],
date_format="U"
)
```
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | ||
| campaign_id | Yes | ||
| date_format | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |