This document refers to an outdated version of Graph API. Please use the latest version.
Graph API Version

Canvas Ads

You can easily create Canvas campaigns on Facebook through the API. By using sight, sound, and motion, the video format allows advertisers to effectively drive both brand and direct response objectives.

Canvases consists of Canvas Elements

  • Header
  • Footer
  • Carousel
  • Button
  • Text
  • Photo
  • Video
  • Product set
  • Store Locator

In this examples we show how you can create each element and how they're used to create a canvas. See Clicks to Website: Canvas on Facebook Ads guide for a visual example on each element.

Create Canvas

use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'name' => 'Canvas Name',
  'background_color' => 'FFFFFF',
  'body_element_ids' => array(<CANVAS_PHOTO_ID>),
  'is_hidden' => false,
  'is_published' => true,
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvases',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'name=Canvas Name' \
  -F 'background_color=FFFFFF' \
  -F 'body_element_ids=["<CANVAS_PHOTO_ID>"]' \
  -F 'is_hidden=' \
  -F 'is_published=1' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvases

Canvas Header

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_header' => array(
    'name' => 'Canvas Header Name',
    'background_color' => 'FFFFFF',
    'child_elements' => array(<CANVAS_PHOTO_ID>),
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_header={ 
    "name": "Canvas Header Name", 
    "background_color": "FFFFFF", 
    "child_elements": ["<CANVAS_PHOTO_ID>"] 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements
Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'name' => 'Canvas Header Name',
  'background_color' => 'FFFFFF',
  'child_elements' => array(<CANVAS_PHOTO_ID>),
);

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_HEADER_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'name=Canvas Header Name' \
  -F 'background_color=FFFFFF' \
  -F 'child_elements=["<CANVAS_PHOTO_ID>"]' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_HEADER_ID>
Delete
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_ID>,
  RequestInterface::METHOD_DELETE,
  array())->getContent();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_ID>

Canvas Footer

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_footer' => array(
    'name' => 'Canvas Footer Name',
    'child_elements' => array(<CANVAS_BUTTON_ID>),
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_footer={"name":"Canvas Footer Name","child_elements":["<CANVAS_BUTTON_ID>"]}' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements
Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'name' => 'Canvas Footer Name',
  'child_elements' => array(<CANVAS_BUTTON_ID>),
);

$data = Api::instance()->call(
  '/'.<CANVAS_ELEMENT_FOOTER_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'name=Canvas Footer Name' \
  -F 'child_elements=["<CANVAS_BUTTON_ID>"]' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_FOOTER_ID>
Delete
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_ID>,
  RequestInterface::METHOD_DELETE,
  array())->getContent();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_ID>

Canvas Carousel

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_carousel' => array(
    'bottom_padding' => 12,
    'child_elements' => array(
      <CANVAS_PHOTO_ID_1>,
      <CANVAS_PHOTO_ID_2>,
      <CANVAS_PHOTO_ID_3>,
    ),
    'name' => 'Canvas Carousel Name',
    'style' => 'FIT_TO_WIDTH',
    'top_padding' => 12,
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_carousel={ 
    "bottom_padding": 12, 
    "child_elements": [ 
      "<CANVAS_PHOTO_ID_1>", 
      "<CANVAS_PHOTO_ID_2>", 
      "<CANVAS_PHOTO_ID_3>" 
    ], 
    "name": "Canvas Carousel Name", 
    "style": "FIT_TO_WIDTH", 
    "top_padding": 12 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements
Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'bottom_padding' => 12,
  'child_elements' => array(
    <CANVAS_PHOTO_ID_1>,
    <CANVAS_PHOTO_ID_2>,
    <CANVAS_PHOTO_ID_3>,
  ),
  'name' => 'Canvas Carousel Name',
  'style' => 'FIT_TO_WIDTH',
  'top_padding' => 12,
);

$data = Api::instance()->call(
  '/'.<CANVAS_ELEMENT_CAROUSEL_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'bottom_padding=12' \
  -F 'child_elements=[ 
    "<CANVAS_PHOTO_ID_1>", 
    "<CANVAS_PHOTO_ID_2>", 
    "<CANVAS_PHOTO_ID_3>" 
  ]' \
  -F 'name=Canvas Carousel Name' \
  -F 'style=FIT_TO_WIDTH' \
  -F 'top_padding=12' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_CAROUSEL_ID>
Delete
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_ID>,
  RequestInterface::METHOD_DELETE,
  array())->getContent();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_ID>

Options

NameRequired or OptionalDescription

style

Optional

FIT_TO_WIDTH or FIT_TO_HEIGHT

Canvas Button

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_button' => array(
    'bottom_padding' => 0,
    'button_color' => 'FF000000',
    'button_style' => 'BUTTON_FILLED',
    'font_family' => 'sans-serif',
    'font_size' => 15,
    'line_height' => 1,
    'name' => 'Canvas Button Name',
    'open_url_action' => array('url' => '<URL>'),
    'rich_text' => array('plain_text' => 'Click Me'),
    'text_alignment' => 'CENTER',
    'text_color' => 'FF777777',
    'top_padding' => 0,
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_button={ 
    "bottom_padding": 0, 
    "button_color": "FF000000", 
    "button_style": "BUTTON_FILLED", 
    "font_family": "sans-serif", 
    "font_size": 15, 
    "line_height": 1, 
    "name": "Canvas Button Name", 
    "open_url_action": {"url":"<URL>"}, 
    "rich_text": {"plain_text":"Click Me"}, 
    "text_alignment": "CENTER", 
    "text_color": "FF777777", 
    "top_padding": 0 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements
Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'bottom_padding' => 0,
  'button_color' => 'FF000000',
  'button_style' => 'BUTTON_FILLED',
  'font_family' => 'sans-serif',
  'font_size' => 15,
  'line_height' => 1,
  'name' => 'Canvas Button Name',
  'open_url_action' => array('url' => '<URL>'),
  'rich_text' => array('plain_text' => 'Click Me'),
  'text_alignment' => 'CENTER',
  'text_color' => 'FF777777',
  'top_padding' => 0,
);

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_BUTTON_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'bottom_padding=0' \
  -F 'button_color=FF000000' \
  -F 'button_style=BUTTON_FILLED' \
  -F 'font_family=sans-serif' \
  -F 'font_size=15' \
  -F 'line_height=1' \
  -F 'name=Canvas Button Name' \
  -F 'open_url_action={"url":"<URL>"}' \
  -F 'rich_text={"plain_text":"Click Me"}' \
  -F 'text_alignment=CENTER' \
  -F 'text_color=FF777777' \
  -F 'top_padding=0' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_BUTTON_ID>
Delete
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_ID>,
  RequestInterface::METHOD_DELETE,
  array())->getContent();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_ID>

Options

NameRequired or OptionalDescription

button_style

Required

BUTTON_OUTLINE, BUTTON_FILLED

Canvas Text

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_text' => array(
    'name' => 'Canvas Text Name',
      'rich_text' => array(
        'plain_text' => 'Canvas Text',
        'inline_styles' => array(
          array('offset' => 10, 'length' => 9, 'style' => 'underline'),
          array('offset' => 20, 'length' => 9, "style" => 'bold'),
       ),
     ),
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_text={ 
    "name": "Canvas Text Name", 
    "rich_text": { 
      "plain_text": "Canvas Text", 
      "inline_styles": [ 
        { 
          "offset": 10, 
          "length": 9, 
          "style": "underline" 
        }, 
        { 
          "offset": 20, 
          "length": 9, 
          "style": "bold" 
        } 
      ] 
    } 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements
Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'name' => 'Canvas Text Name',
    'rich_text' => array(
      'plain_text' => 'Canvas Text',
      'inline_styles' => array(
        array('offset' => 10, 'length' => 9, 'style' => 'underline'),
        array('offset' => 20, 'length' => 9, "style" => 'bold'),
     ),
   ),
);

$data = Api::instance()->call(
  '/'.<CANVAS_ELEMENT_TEXT_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'name=Canvas Text Name' \
  -F 'rich_text={ 
    "plain_text": "Canvas Text", 
    "inline_styles": [ 
      { 
        "offset": 10, 
        "length": 9, 
        "style": "underline" 
      }, 
      { 
        "offset": 20, 
        "length": 9, 
        "style": "bold" 
      } 
    ] 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_TEXT_ID>
Delete
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_ID>,
  RequestInterface::METHOD_DELETE,
  array())->getContent();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_ID>

Canvas Photo

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_photo' => array(
    'bottom_padding' => 20,
    'name' => 'Canvas Photo Name',
    'open_url_action' => array('url' => '<URL>'),
    'photo_id' => <PHOTO_ID>,
    'style' => 'FIT_TO_WIDTH',
    'top_padding' => 20,
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_photo={ 
    "bottom_padding": 20, 
    "name": "Canvas Photo Name", 
    "open_url_action": {"url":"<URL>"}, 
    "photo_id": "<PHOTO_ID>", 
    "style": "FIT_TO_WIDTH", 
    "top_padding": 20 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements
Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'bottom_padding' => 20,
  'name' => 'Canvas Photo Name',
  'open_url_action' => array('url' => '<URL>'),
  'photo_id' => <PHOTO_ID>,
  'top_padding' => 20,
);

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_PHOTO_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'bottom_padding=20' \
  -F 'name=Canvas Photo Name' \
  -F 'open_url_action={"url":"<URL>"}' \
  -F 'photo_id=<PHOTO_ID>' \
  -F 'top_padding=20' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_PHOTO_ID>
Delete
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_ID>,
  RequestInterface::METHOD_DELETE,
  array())->getContent();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_ID>

Options

NameRequired or OptionalDescription

style

Optional

FIT_TO_WIDTH, FIT_TO_WIDTH_EXPANDABLE, FIT_TO_HEIGHT

Canvas Video

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_video' => array(
    'bottom_padding' => 24,
    'name' => 'Canvas Video Name',
    'style' => 'FIT_TO_WIDTH',
    'top_padding' => 24,
    'video_id' => <VIDEO_ID>,
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_video={ 
    "bottom_padding": 24, 
    "name": "Canvas Video Name", 
    "style": "FIT_TO_WIDTH", 
    "top_padding": 24, 
    "video_id": "<VIDEO_ID>" 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements

Options

NameRequired or OptionalDescription

style

Optional

FIT_TO_WIDTH, FIT_TO_HEIGHT

Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'bottom_padding' => 20,
  'name' => 'Canvas Video Name',
  'style' => 'FIT_TO_WIDTH',
  'top_padding' => 20,
  'video_id' => <VIDEO_ID>,
);

$data = Api::instance()->call(
  '/'.<CANVAS_ELEMENT_VIDEO_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'bottom_padding=20' \
  -F 'name=Canvas Video Name' \
  -F 'style=FIT_TO_WIDTH' \
  -F 'top_padding=20' \
  -F 'video_id=<VIDEO_ID>' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_VIDEO_ID>
Delete
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_ID>,
  RequestInterface::METHOD_DELETE,
  array())->getContent();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_ID>

Canvas Product Set

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_product_set' => array(
    'bottom_padding' => 8,
    'max_items' => 6,
    'name' => 'Canvas Product Set Name',
    'product_set_id' => <PRODUCT_SET_ID>,
    'top_padding' => 24,
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_product_set={ 
    "bottom_padding": 8, 
    "max_items": 6, 
    "name": "Canvas Product Set Name", 
    "product_set_id": "<PRODUCT_SET_ID>", 
    "top_padding": 24 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements
Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'bottom_padding' => 8,
  'max_items' => 6,
  'name' => 'Canvas Product Set Name',
  'product_set_id' => <PRODUCT_SET_ID>,
  'top_padding' => 24,
);

$data = Api::instance()->call(
  '/'.<CANVAS_ELEMENT_PRODUCT_SET_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'bottom_padding=8' \
  -F 'max_items=6' \
  -F 'name=Canvas Product Set Name' \
  -F 'product_set_id=<PRODUCT_SET_ID>' \
  -F 'top_padding=24' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_PRODUCT_SET_ID>

Canvas Store Locator

Create
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'canvas_store_locator' => array(
    'header_background_color' => 'FF000000',
    'name' => 'Canvas Store Locator Name',
    'page_set_id' => <PLACE_PAGE_SET_ID>,
    'typeface' => 'HelveticaNeue-Light',
  ),
);

$data = Api::instance()->call(
  '/'.<PAGE_ID>.'/canvas_elements',
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'canvas_store_locator={ 
    "header_background_color": "FF000000", 
    "name": "Canvas Store Locator Name", 
    "page_set_id": "<PLACE_PAGE_SET_ID>", 
    "typeface": "HelveticaNeue-Light" 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<PAGE_ID>/canvas_elements
Update
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$params = array(
  'header_background_color' => 'FF000000',
  'name' => 'Canvas Store Locator Name',
  'page_set_id' => <PLACE_PAGE_SET_ID>,
  'typeface' => 'HelveticaNeue-Light',
);

$data = Api::instance()->call(
  '/'.<CANVAS_ELEMENT_STORE_LOCATOR_ID>,
  RequestInterface::METHOD_POST,
  $params)->getContent();
curl \
  -F 'header_background_color=FF000000' \
  -F 'name=Canvas Store Locator Name' \
  -F 'page_set_id=<PLACE_PAGE_SET_ID>' \
  -F 'typeface=HelveticaNeue-Light' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_STORE_LOCATOR_ID>
Delete
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;

$data = Api::instance()->call(
  '/' . <CANVAS_ELEMENT_ID>,
  RequestInterface::METHOD_DELETE,
  array())->getContent();
curl -X DELETE \
  -d 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/<CANVAS_ELEMENT_ID>

Canvas Preview

curl \
-F 'user_ids=[<USER_ID>]' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.8/<CANVAS_ID>/preview_notifications

This will trigger a notification sent to your phone.

Create Canvas Ad

In this example we create a canvas ad using an existing canvas ID.

Create Canvas Ad Creative

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

$link_data = new AdCreativeLinkData();
$link_data->setData(array(
  AdCreativeLinkDataFields::IMAGE_HASH => '<IMAGE_HASH>',
  AdCreativeLinkDataFields::LINK => '<CANVAS_LINK>',
  AdCreativeLinkDataFields::NAME => 'Creative message',
  AdCreativeLinkDataFields::CALL_TO_ACTION => array(
    'type' => AdCreativeCallToActionTypeValues::LEARN_MORE,
  ),
));

$story = new AdCreativeObjectStorySpec();
$story->setData(array(
  AdCreativeObjectStorySpecFields::LINK_DATA => $link_data,
  AdCreativeObjectStorySpecFields::PAGE_ID => <PAGE_ID>,
));

$creative = new AdCreative(null, 'act_<AD_ACCOUNT_ID>');
$creative->setData(array(
  AdCreativeFields::IMAGE_HASH => '<IMAGE_HASH>',
  AdCreativeFields::OBJECT_STORY_SPEC => $story,
));

$creative->create();
curl \
  -F 'image_hash=<IMAGE_HASH>' \
  -F 'object_story_spec={ 
    "link_data": { 
      "call_to_action": {"type":"LEARN_MORE"}, 
      "image_hash": "<IMAGE_HASH>", 
      "link": "<CANVAS_LINK>", 
      "name": "Creative message" 
    }, 
    "page_id": "<PAGE_ID>" 
  }' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/adcreatives

Create Ad

use FacebookAds\Object\Ad;
use FacebookAds\Object\Fields\AdFields;

$data = array(
  AdFields::NAME => 'My Ad',
  AdFields::ADSET_ID => <AD_SET_ID>,
  AdFields::CREATIVE => array(
    'creative_id' => <CREATIVE_ID>,
  ),
);

$ad = new Ad(null, 'act_<AD_ACCOUNT_ID>');
$ad->setData($data);
$ad->create(array(
  Ad::STATUS_PARAM_NAME => Ad::STATUS_PAUSED,
));
from facebookads.adobjects.ad import Ad

ad = Ad(parent_id='act_<AD_ACCOUNT_ID>')
ad[Ad.Field.name] = 'My Ad'
ad[Ad.Field.adset_id] = <AD_SET_ID>
ad[Ad.Field.creative] = {
    'creative_id': <CREATIVE_ID>,
}
ad.remote_create(params={
    'status': Ad.Status.paused,
})
Ad ad = new AdAccount(act_<AD_ACCOUNT_ID>, context).createAd()
  .setName("My Ad")
  .setAdsetId(<AD_SET_ID>)
  .setCreative(
    new AdCreative()
      .setFieldId(<CREATIVE_ID>)
  )
  .setStatus(Ad.EnumStatus.VALUE_PAUSED)
  .execute();
curl \
  -F 'name=My Ad' \
  -F 'adset_id=<AD_SET_ID>' \
  -F 'creative={"creative_id":"<CREATIVE_ID>"}' \
  -F 'status=PAUSED' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/ads

Create Ad Set

use FacebookAds\Object\AdSet;
use FacebookAds\Object\Fields\AdSetFields;
use FacebookAds\Object\Fields\TargetingFields;
use FacebookAds\Object\Values\AdSetBillingEventValues;
use FacebookAds\Object\Targeting;
use FacebookAds\Object\Values\AdSetOptimizationGoalValues;

$adset = new AdSet(null, 'act_<AD_ACCOUNT_ID>');
$adset->setData(array(
  AdSetFields::NAME => 'My Ad Set',
  AdSetFields::OPTIMIZATION_GOAL => AdSetOptimizationGoalValues::REACH,
  AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
  AdSetFields::BID_AMOUNT => 2,
  AdSetFields::DAILY_BUDGET => 1000,
  AdSetFields::CAMPAIGN_ID => <CAMPAIGN_ID>,
  AdSetFields::TARGETING => (new Targeting())->setData(array(
    TargetingFields::GEO_LOCATIONS => array(
      'countries' => array('US'),
    ),
  )),
));
$adset->create(array(
  AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED,
));
from facebookads.adobjects.adset import AdSet
from facebookads.adobjects.targeting import Targeting

adset = AdSet(parent_id='act_<AD_ACCOUNT_ID>')
adset.update({
    AdSet.Field.name: 'My Ad Set',
    AdSet.Field.campaign_id: <CAMPAIGN_ID>,
    AdSet.Field.daily_budget: 1000,
    AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
    AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
    AdSet.Field.bid_amount: 2,
    AdSet.Field.targeting: {
        Targeting.Field.geo_locations: {
            'countries': ['US'],
        },
    },
})

adset.remote_create(params={
    'status': AdSet.Status.paused,
})
print(adset)
AdSet adSet = new AdAccount(act_<AD_ACCOUNT_ID>, context).createAdSet()
  .setName("My Ad Set")
  .setOptimizationGoal(AdSet.EnumOptimizationGoal.VALUE_REACH)
  .setBillingEvent(AdSet.EnumBillingEvent.VALUE_IMPRESSIONS)
  .setBidAmount(2L)
  .setDailyBudget(1000L)
  .setCampaignId(<CAMPAIGN_ID>)
  .setTargeting(
    new Targeting()
      .setFieldGeoLocations(
        new TargetingGeoLocation()
          .setFieldCountries(Arrays.asList("US"))
      )
  )
  .setStatus(AdSet.EnumStatus.VALUE_PAUSED)
  .execute();
String ad_set_id = adSet.getId();
curl \
  -F 'name=My Ad Set' \
  -F 'optimization_goal=REACH' \
  -F 'billing_event=IMPRESSIONS' \
  -F 'bid_amount=2' \
  -F 'daily_budget=1000' \
  -F 'campaign_id=<CAMPAIGN_ID>' \
  -F 'targeting={"geo_locations":{"countries":["US"]}}' \
  -F 'status=PAUSED' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/adsets

Create Ad Campaign

use FacebookAds\Object\Campaign;
use FacebookAds\Object\Fields\CampaignFields;
use FacebookAds\Object\Values\CampaignObjectiveValues;

$campaign = new Campaign(null, 'act_<AD_ACCOUNT_ID>');
$campaign->setData(array(
  CampaignFields::NAME => 'My campaign',
  CampaignFields::OBJECTIVE => CampaignObjectiveValues::LINK_CLICKS,
));

$campaign->create(array(
  Campaign::STATUS_PARAM_NAME => Campaign::STATUS_PAUSED,
));
from facebookads.adobjects.campaign import Campaign

campaign = Campaign(parent_id='act_<AD_ACCOUNT_ID>')
campaign.update({
    Campaign.Field.name: 'My Campaign',
    Campaign.Field.objective: Campaign.Objective.link_clicks,
})

campaign.remote_create(params={
    'status': Campaign.Status.paused,
})
Campaign campaign = new AdAccount(act_<AD_ACCOUNT_ID>, context).createCampaign()
  .setName("My campaign")
  .setObjective(Campaign.EnumObjective.VALUE_LINK_CLICKS)
  .setStatus(Campaign.EnumStatus.VALUE_PAUSED)
  .execute();
String campaign_id = campaign.getId();
curl \
  -F 'name=My campaign' \
  -F 'objective=LINK_CLICKS' \
  -F 'status=PAUSED' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/campaigns

Engagement Audiences for Canvas

Automatically create audiences for people who engaged with Canvas, this is known as an engagement audience.

Creating Audience

Create a Canvas engagement audience by creating a Custom Audience with subtype set to ENGAGEMENT, object_id to the <CANVAS_ID>, and the rule to track one of the following Canvas events:

People who opened the Canvas

curl \
    -F 'name=Canvas Engagement Audience' \
    -F 'subtype=ENGAGEMENT' \
    -F 'description=People who opened this Canvas' \
    -F 'rule=[{"object_id":"<CANVAS_ID>","event_name":"instant_shopping_document_open"}]' \
    -F 'access_token=<ACCESS_TOKEN>' \  
https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/customaudiences

People who clicked any links in the Canvas

curl \
    -F 'name=Canvas Engagement Audience' \
    -F 'subtype=ENGAGEMENT' \
    -F 'description=People who clicked any links in this Canvas' \
    -F 'rule=[{"object_id":"<CANVAS_ID>","event_name":"instant_shopping_element_click"}]' \
    -F 'access_token=<ACCESS_TOKEN>' \  
https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/customaudiences

For more information about custom audiences, see Custom Audience, Reference.