Page tree


The Ad Tag API lets you generate ad tags using the methods and parameters described below.

For more information about UAS Inventory Management Services APIs, refer to Inventory Management Services (UAS).

Supported Operations

Service Name: /adtags/

Method PathHTTP Method TypeDescriptionLink to Definition
/adtags/generate/adunit/{id}?adUnitFormats={id}
GET

Generates an Ad Tag based on parameters (Ad Unit Id and Ad Format Id).

Supported Ad Unit Formats:

  • 3 = Banner/Rich Media
  • 12 = Native
  • 13 = Video 
Generate an Ad Tag


Generate an Ad Tag

This API let you generate an ad tag based on the parameters provided.

Request


Request Headers

Header nameType ValueRequiredDescription
Content-TypeStringapplication/jsonYesMedia type for request.
AuthorizationStringBearer ${access_token}Yes

Publisher Token to authenticate and authorize the user calling the Unified Ad Server API. Send the access token generated for authentication at the place of ${access_token} in the request.

For more information about access tokens, refer to Getting Started with PubMatic APIs.


Request Body Parameters

Parameter NameTypeRequiredValidationDescription
adUnitFormat
NumericYesShould be valid and exist in the systemAd unit format of an ad unit for which the ad tag is generated. You can retrieve ad unit format using the Ad Format API.
generateSecureTag
BooleanNoDefault is false.Pass true if you would like to have a secure Ad Tag to be set up on secured pages for provided Ad Unit Format; otherwise, pass false.


Request Sample URL

https://api.pubmatic.com/v1/uas/adtags/generate/adunit/1?adUnitFormats=3

Response

The standard response contains JSON describing the new ad tag. The response for native ad unit format contains RTB JSON for all native templates associated with an ad unit, using the native template name as key and the RTB request JSON as value.

Sample Response JSON: Non-Native

{
  "DISPLAY": {
    "tag": {
      "head": "<!-- Part 1 -->\r\n<!-- Head section, should be included only once on a page 
-->\r\n<script type='text/javascript'>\r\n   \tvar Phoenix = {};\r\n\tPhoenix.EQ = [];
\r\n\t(function(){\r\n\t\tvar scriptElement = document.createElement('script');\r\n\t\
tscriptElement.async = true;\r\n\t\tscriptElement.type = 'text/javascript';\t\t\r\n\t\
tscriptElement.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + 
'//ads.pubmatic.com/AdServer/js/phoenix.js';\r\n\t\tvar node = document.getElementsByTagName
('script')[0];\r\n\t\tnode.parentNode.insertBefore(scriptElement, node);\t\t\t\t\r\n\t})
();\r\n</script>\r\n<!-- Part 2 -->\r\n<!-- AdSlot declaration section, will repeat for 
number of slots -->\r\n<script type='text/javascript'>\r\n\tPhoenix.EQ.push
(\r\n\t\tfunction(){\r\n\t\t\tPhoenix.enableSingleRequestCallMode();\r\n\t\t\
tPhoenix.defineAdSlot('929',[],'Div_ID_To_Render_This_Slot');\t\t\t\r\n\t\t}\r\n\t);
\t\r\n</script>\r\n",
      "body": "<!-- Part 3 -->\r\n<!-- Document Body, This part should be added where 
adSlot is expected to render creative  -->\r\n<div id='Div_ID_To_Render_This_Slot'>\r\n\t
<script type='text/javascript'>\r\n\t\tPhoenix.EQ.push(\r\n\t\t\tfunction(){\r\n\t\t\t\
tPhoenix.display('Div_ID_To_Render_This_Slot');\r\n\t\t\t}\r\n\t\t);\t\r\n\t</script>
\r\n</div>\r\n"
    }
  }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Sample Response JSON: Native

{
  "NATIVE": {
    "tag": "http://adserverbeta.pubmatic.com/ad?&req_type=4&res_format=2&au=929&ntid=
<NATIVE_TEMPLATE_ID>&iid=<IMPRESSION_ID>&rndn=<RANDOM_NUMBER_CACHE_BURSTING>\n\t\n",
    "templateRequestJsonMap": {
      "Test-AdTemplate-001-Apps": "{\"assets\":[{\"id\":1,\"required\":1,\"img\":null,
\"title\":{\"len\":100},\"data\":null,\"video\":null},{\"id\":2,\"required\":1,\"img\"
:{\"type\":1,\"wmin\":null,\"hmin\":null,\"mimes\":[\"image/png\"],\"aspect_ratio\":null,
\"w\":75,\"h\":75},\"title\":null,\"data\":null,\"video\":null},{\"id\":3,\"required\":1,
\"img\":{\"type\":3,\"wmin\":null,\"hmin\":null,\"mimes\":[\"image/png\"],\"aspect_ratio\
":null,\"w\":480,\"h\":320},\"title\":null,\"data\":null,\"video\":null},{\"id\":4,
\"required\":1,\"img\":null,\"title\":null,\"data\":{\"type\":2,\"len\":200},\"video\
":null},{\"id\":5,\"required\":1,\"img\":null,\"title\":null,\"data\":{\"type\":3,\"len\
":10},\"video\":null}],\"adunit_id\":null,\"layout_id\":null}"
    }
  }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍




⇧ Top