Facebook Developers
DocsToolsSupportNewsApps
Log In
  • Social Plugins
  • Facebook Login
  • Open Graph
  • Facebook APIs
    • Graph API
    • FQL
    • Open Graph
    • Dialogs
    • Chat
    • Internationalization
    • Ads
  • Games
  • Media
  • Payments
  • App Center
  • Promote Your App
  • iOS
  • Android
  • Web
  • Technology Partners
  • Best Practices
    • Batch Requests
    • Using ETags
  • Reference
    • Conversion pixels
    • Cost Per Action (CPA) Ads
    • Currencies
    • Homepage Ads via API
    • Introduction to Action Spec
    • Introduction to Sponsored Stories
    • Mobile App Install Ads
    • Optimized CPM
    • Real Time Bidded Exchange protocol
    • Sponsored Results
    • Thrift file for Real Time Bidded Exchange protocol
  • Specs
    • Action Specs
    • Conversion Specs
    • Creative Specs
    • Targeting Specs
    • Tracking Specs
  • Advanced Targeting
    • Action Spec Targeting
    • Custom Audience targeting
    • Partner Categories
    • Topic Targeting
    • ZIP Code Targeting
  • Queries
    • Action Estimate
    • Action Spec Ad Previews
    • Ad Statistics
    • Autocomplete Data
    • Broad Target Categories
    • Connection Objects
    • Conversion Stats
    • Keyword Stats
    • Reach estimate
    • Targeting Description
  • Objects
    • Ad account
    • Ad account group
    • Ad campaign
    • Ad creative
    • Ad group
    • Ad image
    • Ad user

Ad image

Facebook APIs › Ads › Ad image

Images for use in ads can be uploaded and managed independently of ads or creatives.

The image used in an ad group can be specified in the following ways:

  • By image hash value of a previously uploaded image.
  • By uploading the image at ad or creative creation time.

Note: The image of sponsored stories is defined by the story being boosted and not by the ad group creative.

Fields

Name Description Permission Returns
hash The hash which uniquely identifies the image. ads_management string
url A temporary URL which the image can be retrieved at. ads_management string

Read

Reading the ad images of a given account

To retrieve the available images of an ads account, specify adimages:

act_AccountID/adimages

The images used in every creative in the account should appear in the list of images. Using the image_hash property you can specify the image to be used with new creatives or ad groups.

Reading specific ad images

To retrieve specific images from an ads account specify the hashes of the images in a "hashes" array as follows:

act_AccountID/adimages?hashes=["0d500843a1d4699a0b41e99f4137a5c3","012feg987e98g789f789e87976210983"]

Both of these methods returns an array of adimages as follows:

{
  "data": {
    "0d500843a1d4699a0b41e99f4137a5c3": {
      "hash": "0d500843a1d4699a0b41e99f4137a5c3",
      "url": "https://fbcdn-photos-a.akamaihd.net/photos-ak    snc1/v41818/flyers/5/36/1314272071984394364_1_88aed216.jpg"
    },{
    "012feg987e98g789f789e87976210983": {
      "hash": "012feg987e98g789f789e87976210983",
      "url": "https://fbcdn-photos-a.akamaihd.net/photos-ak    snc1/v41818/flyers/5/36/1319872345987987364_1_88443gea.jpg"
    }
  },
  "count": 2,
  "limit": 100,
  "offset": 0
}

Upload

Image only

You can upload an image or zip file and use the generated hash to specify the image for use in an ad group or creative. You must include an extension with your filename, e.g. 'sample.jpg' and not just 'sample' or 'sample.tmp', etc.

Zip file.:

curl -F "test.zip=@test.zip" "https://graph.facebook.com/
act_368811234/adimages?access_token=____"

Image file (bmp, jpeg, gif).:

curl -F "test.jpg=@test.jpg" "https://graph.facebook.com/
act_368811234/adimages?access_token=____"

The response is of the following form.:

{"images":{"8cf726a44ab7008c5cc6b4ebd2491234":
{"hash":"8cf726a44ab7008c5cc6b4ebd2491234",
"url":"https:\/\/fbcdn-photos-a.akamaihd.net
\/photos-ak-snc1\/v41818\/flyers\/19\/58\/13117189501439916725_1_3b571234.jpg"}}}

Ad groups and creatives can be created using an image hash as follows.

curl -F "campaign_id=6003417011234" -F "bid_type=1" 
-F "max_bid=30" -F "targeting={'countries':['US']}" 
-F "creative={'title':'testtitle','body':'test',
'link_url':'http:\/\/www.test.com',
'image_hash':'8cf726a44ab7008c5cc6b4ebd2491234'}" 
-F "name=adgroupname" 
"https://graph.facebook.com/act_368811234/adgroups?access_token=____"

The response will be similar to the following:

{"id":6003494271234]}

Uploading an image during ad or creative creation

To directly upload an image (instead of using an image hash), add the image file to the multi-part MIME POST and specify the file name.

For example, you could specify the following:

curl -F "campaign_id=6003417011234" -F "bid_type=1" 
-F "max_bid=30" -F "targeting={'countries':['US']}" 
-F "creative={'title':'test','body':'test',
'link_url':'http:\/\/www.test.com','image_file':'test.jpg'}" 
-F "name=test" -F "test.jpg=@.\test.jpg" 
"https://graph.facebook.com/act_368811234/adgroups?access_token=___"

The response will be similar to the following:

{"id":6003485421234}

Copy an image from one ad account to another.

To copy an adimage from one account to another supply the source account and hash of the image in a "copy_from" POST parameter.

curl -F 'access_token=...' 
 -F 'copy_from=["source_account_id":SourceAccountID, "hash":"02bee5277ec507b6fd0f9b9ff2f22d9c"]' 
 https://graph.facebook.com/act_DestAccountID/adimages

Note: This copies the adimage from the SourceAccountID and to the DestAccountID account. You must have access to read the creatives from SourceAccountID or you won't be able to copy the images from the account.

Updated about 3 months ago
Facebook © 2013 · English (US)
AboutAdvertisingCareersPlatform PoliciesPrivacy Policy