Marketing API Version

Ad Video Creative

This document explains how to create an ad video creative.

Before you Start

You will need:

  • manage_page or ads_management permissions
  • a video uploaded to the act_{ad-account-id}/advideos endpoint

Create an Ad Video Creative

Send a POST request to the /act_{ad-account-id}/adcreative endpoint and include the video_data field:

curl -X POST \ -F 'name="Sample Creative"' \ -F 'object_story_spec={ "page_id": "<PAGE_ID>", "video_data": { "image_url": "<IMAGE_URL>", "video_id": "<VIDEO_ID>", "call_to_action": { "type": "LIKE_PAGE", "value": { "page": "<PAGE_ID>" } } } }' \ -F 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v7.0/act_<AD_ACCOUNT_ID>/adcreatives
'use strict'; const bizSdk = require('facebook-nodejs-business-sdk'); const AdAccount = bizSdk.AdAccount; const AdCreative = bizSdk.AdCreative; const access_token = '<ACCESS_TOKEN>'; const app_secret = '<APP_SECRET>'; const app_id = '<APP_ID>'; const id = '<AD_ACCOUNT_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 = [ ]; params = { 'name' : 'Sample Creative', 'object_story_spec' : {'page_id':'<pageID>','video_data':{'image_url':'<imageURL>','video_id':'<videoID>','call_to_action':{'type':'LIKE_PAGE','value':{'page':'<pageID>'}}}}, }; const adcreatives = (new AdAccount(id)).createAdCreative( fields, params ); logApiCallResult('adcreatives api call complete.', adcreatives);
require __DIR__ . '/vendor/autoload.php'; use FacebookAds\Object\AdAccount; 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_ACCOUNT_ID>'; $api = Api::init($app_id, $app_secret, $access_token); $api->setLogger(new CurlLogger()); $fields = array( ); $params = array( 'name' => 'Sample Creative', 'object_story_spec' => array('page_id' => '<pageID>','video_data' => array('image_url' => '<imageURL>','video_id' => '<videoID>','call_to_action' => array('type' => 'LIKE_PAGE','value' => array('page' => '<pageID>')))), ); echo json_encode((new AdAccount($id))->createAdCreative( $fields, $params )->exportAllData(), JSON_PRETTY_PRINT);
from facebook_business.adobjects.adaccount import AdAccount 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_ACCOUNT_ID>' FacebookAdsApi.init(access_token=access_token) fields = [ ] params = { 'name': 'Sample Creative', 'object_story_spec': {'page_id':'<pageID>','video_data':{'image_url':'<imageURL>','video_id':'<videoID>','call_to_action':{'type':'LIKE_PAGE','value':{'page':'<pageID>'}}}}, } print AdAccount(id).create_ad_creative( 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_ACCOUNT_ID>\"; APIContext context = new APIContext(access_token).enableDebug(true); new AdAccount(id, context).createAdCreative() .setName(\"Sample Creative\") .setObjectStorySpec( new AdCreativeObjectStorySpec() .setFieldPageId(\"<pageID>\") .setFieldVideoData( new AdCreativeVideoData() .setFieldCallToAction( new AdCreativeLinkDataCallToAction() .setFieldType(AdCreativeLinkDataCallToAction.EnumType.VALUE_LIKE_PAGE) .setFieldValue( new AdCreativeLinkDataCallToActionValue() .setFieldPage(\"<pageID>\") ) ) .setFieldImageUrl(\"<imageURL>\") .setFieldVideoId(\"<videoID>\") ) ) .execute(); } }
require 'facebook_ads' access_token = '<ACCESS_TOKEN>' app_secret = '<APP_SECRET>' app_id = '<APP_ID>' id = '<AD_ACCOUNT_ID>' FacebookAds.configure do |config| config.access_token = access_token config.app_secret = app_secret end ad_account = FacebookAds::AdAccount.get(id) adcreatives = ad_account.adcreatives.create({ name: 'Sample Creative', object_story_spec: {'page_id':'<pageID>','video_data':{'image_url':'<imageURL>','video_id':'<videoID>','call_to_action':{'type':'LIKE_PAGE','value':{'page':'<pageID>'}}}}, })

If you do not specify images for your video thumbnails, Facebook will select an image from the video. Thumbnail images may be enhanced slightly, such as changes in brightness or contrast, before use. Applies to video ads only.

Custom images that you have supplied as your video thumbnails will not be altered.