Page tree




Before using PubMatic APIs, first generate the API Token. For more information, refer to  Getting Started with PubMatic APIs .  


You can use Device Type Targeting API to deliver the line items on type of device like feature phone, smart phone etc.


Important Note:

  1. This API will not validate targetValue (that is, ID's for respective targeting), provided in the POST call.  Retrieve the valid target details using Common Mobile Device Type API and provide ID's for respective targeting.
  2. Make sure that the same targetValues are not getting included / excluded at same time for same line item.

This API must be called after creating/updating line items successfully since it requires lineitemId during targeting.

For more information about UAS Line Item Targeting Services, refer to Line Item Targeting Services (UAS)

Supported Operations


Method PathHTTP MethodDescriptionLink to Definition
/lineitems/{lineItemId}/targets/devicetypesPOSTAdd/Update/Remove Device Type Targeting for the Line Item LevelConfigure Device Type Targeting
/lineitems/{lineItemId}/targets/devicetypesGETRetrieve Device Type Targeting Details for a Line ItemRetrieve Targeted Device Type for a Line Item


Configure Device Type Targeting

This API enables you to add, update or remove Device Type for a Line Item.

Request


URIHTTP Method
https://api.pubmatic.com/v1/uas/lineitems/{lineItemId}/targets/devicetypes/POST


Request Headers

Header nameType ValueRequiredDescription
Content-TypeStringapplication/jsonYesMedia type for request.
Authorization StringBearer ${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

This API accepts array of target objects, where each object must contain following attributes.

Parameter NameTypeRequiredValidationsDescriptions
targetLevelNumericYes

Should not be null.

Should not be empty.

Device Type has only a single target level

The following are the valid Target Levels for Device Type targeting:

Target LevelTargetDescriptionURL for obtaining target level list
1Device TypeDevice Type Targeting

You can retrieve all supported OS details using following URL

http://$URI_PREFIX/api/common/mobileDeviceType

targetValueNumeric

Yes

Should not be null.

Should not be empty.

Target Value can contain a reference value.e.g., To target a Device Type Tablet then targetValue=2

The following are supported data types:

Target TypeTarget Value Data TypeReference/Actual Value
Device TypeNumericReference Value.   id  attribute from the response returned Common  API
excludeBooleanYes

Default will be false.

Valid values can be true or false.

This value indicates whether the OS is to be included / excluded while targeting the Line Item

Sample Request URL

https://api.pubmatic.com/v1/uas/lineitems/{lineItemId}/targets/devicetypes/ 


Sample Request JSON

{
    "targets": [
        {
            "targetValue": 1,
            "exclude": true,
            "targetLevel": 1
        },
        {
            "targetValue": 2,
            "exclude": true,
            "targetLevel": 1
        }
    ]
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Sample Request JSON: Remove Device Type Targeting for a LIne Item

{
    "targets": []
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

Response

Sample Response JSON

{
  "entity": {
    {
        targetid associated with lineitem},
        "isPreset": 0
 },
  "targets": [
    {
      "targetValue": 1,
      "exclude": true,
      "targetLevel": 1,
      "deviceTypeId": 1,
      "deviceType": "Feature Phone"
    },
    {
      "targetValue": 2,
      "exclude": true,
      "targetLevel": 1,
      "deviceTypeId": 2,
      "deviceType": "Smart Phone"
    }
  ]
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Retrieve Targeted Device Type for a Line Item

This API enables you to retrieve Device Type for a Line Item.

Request



Request Headers

Header nameType ValueRequiredDescription
Content-TypeStringapplication/jsonYesMedia type for request.
Authorization StringBearer ${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

This API accepts array of target objects, where each object must contain following attributes.

Parameter NameTypeRequiredValidationsDescriptions
targetLevelNumericYes

Should not be null.

Should not be empty.

Device Type has only a single target level

The following are the valid Target Levels for Device Type targeting:

Target LevelTargetDescriptionURL for obtaining target level list
1Device TypeDevice Type Targeitng

You can retrieve all supported OS details using following URL

http://$URI_PREFIX/api/common/mobileDeviceType

targetValueNumeric

Yes

Should not be null.

Should not be empty.

Target Value can contain a reference value.e.g., To target a Device Type Tablet then targetValue=2

The following are supported data types:

Target TypeTarget Value Data TypeReference/Actual Value
Device TypeNumericReference Value.   id  attribute from the response returned Common  API
excludeBooleanYes

Default will be false.

Valid values can be true or false.

This value indicates whether the OS is to be included / excluded while targeting the Line Item


Sample Request URL

https://api.pubmatic.com/v1/uas//lineitems/{lineItemId}/targets/os/ 

Response

Sample Response JSON    

{
    "targets": [
        {
            "targetValue": 1,
            "exclude": true,
            "deviceTypeId": 1,
            "deviceType": "Feature Phone"
        },
        {
            "targetValue": 2,
            "exclude": true,
            "deviceTypeId": 2,
            "deviceType": "Smart Phone"
        }
    ]
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Error Codes For Device Type Targeting

Error codes will be displayed with row information. Row indicates the order of the target object in the request.

Sr. No Error Codes Error Message Description
1.PH_MISSING_OR_INVALID_PARAMETERMissing or Invalid Target ValueWhen any target object contains NULL or an empty target value
2.PH_MISSING_OR_INVALID_PARAMETER_MSGMissing or Invalid Target LevelWhen any target object contains NULL or an empty target level
3.PH_MISSING_OR_INVALID_PARAMETERMissing or Invalid entity id [ ]When an Invalid Line item Id is provided in the request

⇧ Top