RTB API

Using merchenta.io for real-time bidding

Facebook ad campaign 

Using the RTB API, it’s possible to run campaigns on Facebook Exchange. These are a little bit different from standard display or mobile campaigns - the ad formats are specific to Facebook and Facebook provides limited targeting options.

Typically, people use Facebook Exchange for retargeting campaigns - this is a simple example of a Facebook campaign retargeting consumers in a segment we’ve already created, with a daily budget. Note that the placements types must be for all types of placenment (ATF, BTF, Unknown) and the inventory type should include blind and transparent inventory (even though this is for ads known to run on facebook.com).

Generate authentication token 

/v3/oauth/accessToken?username={username}&password={password}&advertiser={advertiser}
  • Parameters
  • username
    string (required) Example: username

    username

    password
    string (required) Example: password

    password

    advertiser
    string (required) Example: MERCHENTA

    advertiser code

  • Curl
  • Copy
    curl -i \ -X GET \ https://sandbox.rtbapi.io/v3/oauth/accessToken?username=username&password=password&advertiser=MERCHENTA
  • Response  200
  • Headers
    Content-Type: application/json
    Example body
    {
            "status": "success",
            "data": {
                "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZHYiOiJNRVJDSEVOVEEiLCJleHAiOiIyMDE0LTEwLTA3VDEwOjIwOjEyLjQ4OSIsInJsbSI6IkFETUlOIiwidXNyIjoidGVzdEBtZXJjaGVudGEuY29tIiwiaWF0IjoiMjAxNC0xMC0wN1QwOToyMDoxMi40NTAifQ.7fb8007c49abb7e083f4aca024512ef3c9d32ea1ab0502d2603f4c2c92545b80"
            }
        }

Upload creative file 

/v3/creatives/upload/push
  • Curl
  • Copy
    curl -i \ -X POST \ -H 'Authorization: Bearer {YOUR_TOKEN_HERE}' \ -F creative=@[YOUR_FILENAME_HERE] \ https://sandbox.rtbapi.io/v3/creatives/upload/push
  • Request
  • Headers
    Authorization: Bearer {YOUR_TOKEN_HERE}
    Content-Type: multipart/form-data
    Content-Disposition: form-data; name="creative"; filename="[YOUR_FILENAME_HERE]"
  • Response  200
  • Headers
    Content-Type: application/json
    Example body
    {
            "status": "success",
            "data": {
                "id": "MERCHENTA-b021a5e27751d90f56803375d4329d9a33e72bad.jpg",
                "location": "https://cdn3.merchenta.com/static/assets/MERCHENTA-b021a5e27751d90f56803375d4329d9a33e72bad.jpg"
            }
        }

Create Facebook ad campaign 

/v3/campaigns/{ADVERTISER_CODE}-facebook

Facebook retargeting campaign with:

  • an audience segment (retargeting) for segment ID: ‘uDVvnEvjqR’
  • blind inventory
  • daily budget $100
  • all ad placement types: ATF/BTF/UNKNOWN
  • facebook title
  • facebook body
  • Curl
  • Copy
    curl -i \ -X PUT \ -H 'Authorization: Bearer {YOUR_TOKEN_HERE}' \ -H 'Content-Type: application/json' \ -d '{ "creatives":[ { "code":"{ADVERTISER_CODE}-facebook-1", "creativeId":"MERCHENTA-afed737deeedbc6e21f3b2148c9f2865cbdba68b.jpg", "dimensions":{ "width":254, "height":133 }, "clickthroughUrl":"http://merchenta.com", "type":"FB_SIDEBAR", "facebook": { "title": "Go Beyond Retargeting", "body": "Your brand could be here! CPA retargeting from merchenta.com" } } ], "inventorySettings":{ "inventoryType":"BLIND", "placementType":[ "ATF", "BTF", "UNKNOWN" ], "exchangeBlockList": ["GD", "BS"] }, "biddingSettings":{ "biddingStrategy":{ "strategy":"CPMCappedBiddingStrategy", "maxBid":2 }, "budget":{ "daily":100 }, "pacingType":"ACCELERATED" }, "targetingSettings": { "retargetingSettings" : { "firstPartySegments": "uDVvnEvjqR" } } }' \ https://sandbox.rtbapi.io/v3/campaigns/{ADVERTISER_CODE}-facebook
  • Request
  • Headers
    Authorization: Bearer {YOUR_TOKEN_HERE}
    Content-Type: application/json
    Example body
    {
        "creatives":[
            {
                "code":"{ADVERTISER_CODE}-facebook-1",
                "creativeId":"MERCHENTA-afed737deeedbc6e21f3b2148c9f2865cbdba68b.jpg",
                "dimensions":{
                    "width":254,
                    "height":133
                },
                "clickthroughUrl":"http://merchenta.com",
                "type":"FB_SIDEBAR",
                "facebook": {
                    "title": "Go Beyond Retargeting",
                    "body": "Your brand could be here! CPA retargeting from merchenta.com"
                }
            }
        ],
        "inventorySettings":{
            "inventoryType":"BLIND",
            "placementType":[
                "ATF",
                "BTF",
                "UNKNOWN"
            ],
            "exchangeBlockList": ["GD", "BS"]
        },
        "biddingSettings":{
            "biddingStrategy":{
                "strategy":"CPMCappedBiddingStrategy",
                "maxBid":2
            },
            "budget":{
                "daily":100
            },
            "pacingType":"ACCELERATED"
        },
        "targetingSettings": {
            "retargetingSettings" : {
                "firstPartySegments": "uDVvnEvjqR"
            }
        }
    }
  • Response  200
  • Headers
    Content-Type: application/json
    Example body
    {
            "status": "success"
        }
Next page  Previous page