Skip to main content

Request

The Ad Placement API can be called from either client side or server side.

When using client side implementation, the browser may perform a pre-flight request. If you wish to avoid this, in the request header, use Content-Type: text/plain. This will ensure that the browser qualifies the request as "simple" and therefore skips the pre-flight request.

Also, when calling the API on the client side, IPs are not actually required as it can be difficult to detect IP using frontend and Javascript. Instead, our API detects the IP from the connection when the request is made.

When using server side implementation, in order to ensure correct targeting, the correct IP of the user should be passed explicitly. Otherwise, ads will be targeted for server location and this may cause impressions to be invalidated by an IP mismatch later.

Whether client or server is used, if an IP is passed, it will be prioritised over the one we detect.

In order to perform a request to the ad placement API, you need to pass two objects: user and zones. The request is made in JSON using HTTP POST.

user

ParameterRequired?Description
idNoThe ID of the user
ipRecommendedThe user IP address.
uaYesThe User Agent: A string containing the user's browser/app and device/OS.
languageNoSets the language of the request using the standard two-character ISO code plus an optional 2-character region code. e.g. en-us for United States English.
refererNoThe address of the site where the ad will be shown.
elNoThe Base64-encoded email of the user.
screen_resolutionNoScreen resolution of the device used by user
window_orientationNoThis should be "portrait" if the site has a mobile layout and "landscape" if it's a desktop one.
gdprNoPrivacy advised extensions (Object).

user.gdpr

ParameterDescription
gdprThis should be 0 if the caller believes that the user is not under GDPR, and 1 if the user is under GDPR .
consentThis is the consent string required by the IAB Standards.

zones

ParameterRequired?Description
idYesThe ID of the ad zone
subNoThe Sub ID of the ad zone
keywordsNoAny keywords associated to the traffic that might match with a specific type of advertising. If there are no keywords, the URL of the site will be used for matching
custom_targetingNoCustom zone values (Object)

zones.custom_targeting

ParameterDescription
ex_avThis should be 0 if Undefined, 1 if Age Verified and 2 if Age Not Verified

Example

It is possible to request many ad zones in a single request. Each zone will have a different ID, as you can see in the example below.

{
"user": {
"id": "abdef8u9",
"ip": "10.42.0.1",
"ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36",
"language": "en-US",
"referer": "https://blabla.com",
"gdpr" : {
"gdpr" : 1,
"consent": "CPAoZRHPArq3hBcADBENBJCgAAAAAAAAAAqIHKQAAOUgAAAA"
}
},
"zones": [
{
"id": 4031007,
"sub": 111,
"keywords": "humour, general"
},
{
"id": 4031015,
"sub": 222
},
{
"id": 4031019,
"sub": 222
}
]
}