Get Ad Preview

For Instagram Ads, you can get a preview of:

Preview Existing Ads

You can use format options with an ad or ad creative ID to preview an existing ad. For ad_format, you have:

FormatDescription

INSTAGRAM_EXPLORE_CONTEXTUAL

Instagram Explore Feed format. Learn more about ads in Instagram Explore.

INSTAGRAM_EXPLORE_IMMERSIVE

Instagram Explore Video format. Learn more about ads in Instagram Explore.

INSTAGRAM_REELS

Instagram Reels placement.

INSTAGRAM_STANDARD

Instagram feed post format.

INSTAGRAM_STORY

Instagram story format.

The ad preview call looks like this:

use FacebookAds\Object\Ad;
use FacebookAds\Object\Values\AdPreviewAdFormatValues;

$adgroup = new Ad(<AD_ID>);
$preview = $adgroup->getPreviews(array(), array(
  'ad_format' => AdPreviewAdFormatValues::INSTAGRAM_STANDARD,
))->current();
from facebookads.adobjects.ad import Ad
from facebookads.adobjects.adpreview import AdPreview

ad = Ad(<AD_ID>)
ad.get_previews(params={
    'ad_format': AdPreview.AdFormat.instagram_standard,
})
curl -G \
  -d 'ad_format=INSTAGRAM_STANDARD' \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/<AD_ID>/previews

Preview Before Adding Creative

To preview an ad before providing ad creative, pass the creative's object_story_spec in the preview's creative parameter. You must provide instagram_actor_id and page_id for both Instagram only placement and mixed placement ads:

use FacebookAds\Object\AdAccount;
use FacebookAds\Object\AdCreative;
use FacebookAds\Object\AdCreativeLinkData;
use FacebookAds\Object\Values\AdCreativeCallToActionTypeValues;
use FacebookAds\Object\Fields\AdCreativeFields;
use FacebookAds\Object\Fields\AdCreativeLinkDataFields;
use FacebookAds\Object\Fields\AdCreativeObjectStorySpecFields;
use FacebookAds\Object\Fields\AdPreviewFields;
use FacebookAds\Object\AdCreativeObjectStorySpec;
use FacebookAds\Object\Values\AdPreviewAdFormatValues;

$creative = new AdCreative();
$creative->setData(array(
  AdCreativeFields::OBJECT_STORY_SPEC =>
    (new AdCreativeObjectStorySpec())->setData(array(
      AdCreativeObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
      AdCreativeObjectStorySpecFields::INSTAGRAM_ACTOR_ID =>
        <INSTAGRAM_ACTOR_ID>,
      AdCreativeObjectStorySpecFields::LINK_DATA =>
        (new AdCreativeLinkData())->setData(array(
          AdCreativeLinkDataFields::IMAGE_HASH => '<IMAGE_HASH>',
          AdCreativeLinkDataFields::MESSAGE => 'Ad Message',
          AdCreativeLinkDataFields::CAPTION => 'www.example.com',
          AdCreativeLinkDataFields::LINK => '<URL>',
          AdCreativeLinkDataFields::CALL_TO_ACTION => array(
            'type' => AdCreativeCallToActionTypeValues::LEARN_MORE,
            'value' => array(
              'link' => '<URL>',
            ),
          ),
      )),
    )),
));

$account = new AdAccount('act_<AD_ACCOUNT_ID>');
$preview = $account->getGeneratePreviews(array(), array(
  AdPreviewFields::CREATIVE => $creative,
  AdPreviewFields::AD_FORMAT => AdPreviewAdFormatValues::INSTAGRAM_STANDARD,
))->current();
from facebookads.adobjects.adaccount import AdAccount
from facebookads.adobjects.adcreative import AdCreative
from facebookads.adobjects.adcreativelinkdatacalltoaction \
    import AdCreativeLinkDataCallToAction
from facebookads.adobjects.adcreativelinkdata import AdCreativeLinkData
from facebookads.adobjects.adcreativeobjectstoryspec \
    import AdCreativeObjectStorySpec
from facebookads.adobjects.adpreview import AdPreview

account = AdAccount('act_<AD_ACCOUNT_ID>')

link_data = AdCreativeLinkData()
link_data.set_data({
    AdCreativeLinkData.Field.image_hash: '<IMAGE_HASH>',
    AdCreativeLinkData.Field.message: 'Ad message',
    AdCreativeLinkData.Field.caption: 'www.example.com',
    AdCreativeLinkData.Field.link: '<URL>',
    AdCreativeLinkData.Field.call_to_action: {
        'type': AdCreativeLinkDataCallToAction.Type.learn_more,
        'value': {
            'link': '<URL>',
        },
    },
})

story = AdCreativeObjectStorySpec()
story.set_data({
    AdCreativeObjectStorySpec.Field.page_id: <PAGE_ID>,
    AdCreativeObjectStorySpec.Field.instagram_actor_id: <INSTAGRAM_ACTOR_ID>,
    AdCreativeObjectStorySpec.Field.link_data: link_data,
})

creative = AdCreative()
creative.set_data({
    AdCreative.Field.object_story_spec: story,
})

preview = account.get_generate_previews(params={
    'creative': creative,
    'ad_format': AdPreview.AdFormat.instagram_standard,
})
APINodeList<AdPreview> adPreviews = new AdAccount(act_<AD_ACCOUNT_ID>, context).getGeneratePreviews()
  .setCreative(
    new AdCreative()
      .setFieldObjectStorySpec(
        new AdCreativeObjectStorySpec()
          .setFieldInstagramActorId(<INSTAGRAM_ACTOR_ID>)
          .setFieldLinkData(
            new AdCreativeLinkData()
              .setFieldCallToAction(
                new AdCreativeLinkDataCallToAction()
                  .setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LEARN_MORE)
                  .setFieldValue(
                    new AdCreativeLinkDataCallToActionValue()
                      .setFieldLink(<URL>)
                  )
              )
              .setFieldCaption("www.example.com")
              .setFieldImageHash(<IMAGE_HASH>)
              .setFieldLink(<URL>)
              .setFieldMessage("Ad Message")
          )
          .setFieldPageId(<PAGE_ID>)
      )
  )
  .setAdFormat(AdPreview.EnumAdFormat.VALUE_INSTAGRAM_STANDARD)
  .execute();
curl -G \
  --data-urlencode 'creative={ 
    "object_story_spec": { 
      "instagram_actor_id": "<INSTAGRAM_ACTOR_ID>", 
      "link_data": { 
        "call_to_action": {"type":"LEARN_MORE","value":{"link":"<URL>"}}, 
        "caption": "www.example.com", 
        "image_hash": "<IMAGE_HASH>", 
        "link": "<URL>", 
        "message": "Ad Message" 
      }, 
      "page_id": "<PAGE_ID>" 
    } 
  }' \
  -d 'ad_format=INSTAGRAM_STANDARD' \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/generatepreviews

Preview After Adding Creative

After you provide ad creative, you can get the URL for the corresponding Instagram post, and can see responses to the ad post. The post is not identical to the one your audience sees. It does not have "Sponsored" or a call-to-action.

This URL is not available with Dynamic Ad creatives, which is when you use template_data in object_story_spec. This URL is also unavailable for ad creatives for ads in Instagram stories.

curl -X GET \ -d 'fields="instagram_permalink_url"' \ -d 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v21.0/<CREATIVE_ID>/
'use strict'; const bizSdk = require('facebook-nodejs-business-sdk'); const AdCreative = bizSdk.AdCreative; const access_token = '<ACCESS_TOKEN>'; const app_secret = '<APP_SECRET>'; const app_id = '<APP_ID>'; const id = '<AD_CREATIVE_ID>'; const api = bizSdk.FacebookAdsApi.init(access_token); const showDebugingInfo = true; // Setting this to true shows more debugging info. if (showDebugingInfo) { api.setDebug(true); } const logApiCallResult = (apiCallName, data) => { console.log(apiCallName); if (showDebugingInfo) { console.log('Data:' + JSON.stringify(data)); } }; let fields, params; fields = [ 'instagram_permalink_url', ]; params = { }; const sample_code = (new AdCreative(id)).get( fields, params ); logApiCallResult('sample_code api call complete.', sample_code);
require __DIR__ . '/vendor/autoload.php'; use FacebookAds\Object\AdCreative; use FacebookAds\Api; use FacebookAds\Logger\CurlLogger; $access_token = '<ACCESS_TOKEN>'; $app_secret = '<APP_SECRET>'; $app_id = '<APP_ID>'; $id = '<AD_CREATIVE_ID>'; $api = Api::init($app_id, $app_secret, $access_token); $api->setLogger(new CurlLogger()); $fields = array( 'instagram_permalink_url', ); $params = array( ); echo json_encode((new AdCreative($id))->getSelf( $fields, $params )->exportAllData(), JSON_PRETTY_PRINT);
from facebook_business.adobjects.adcreative import AdCreative from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<AD_CREATIVE_ID>' FacebookAdsApi.init(access_token=access_token) fields = [ 'instagram_permalink_url', ] params = { } print AdCreative(id).get( fields=fields, params=params, )
import com.facebook.ads.sdk.*; import java.io.File; import java.util.Arrays; public class SAMPLE_CODE_EXAMPLE { public static void main (String args[]) throws APIException { String access_token = \"<ACCESS_TOKEN>\"; String app_secret = \"<APP_SECRET>\"; String app_id = \"<APP_ID>\"; String id = \"<AD_CREATIVE_ID>\"; APIContext context = new APIContext(access_token).enableDebug(true); new AdCreative(id, context).get() .requestInstagramPermalinkUrlField() .execute(); } }
require 'facebook_ads' access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<AD_CREATIVE_ID>' FacebookAds.configure do |config| config.access_token = access_token config.app_secret = app_secret end ad_creative = FacebookAds::AdCreative.get(id ,'instagram_permalink_url')

The response:

{
  "instagram_permalink_url": "<INSTAGRAM_POST_URL>",
  "id": "<AD_CREATIVE_ID>"
}