Skip to main content

Create a PG campaign

Create a Programmatic Guaranteed (PG) campaign with this in-depth tutorial using IQM's API.

The following endpoints are used to create a PG campaign:

POST
POST
GET

About IQM PG campaigns​

IQM's PG campaigns define the individual marketing strategies of your ads with an inventory purchased directly from a specific publisher. By specifying the supported parameters you can use the API to create a new PG campaign.

More resources​

Before you begin​

To create a PG campaign, the following are required:

  1. An account on the IQM platform
    • See Getting started section to create an account and request a Client ID and Client Secret
  2. An uploaded creative
  3. An insertion order
  4. A conversion (optional)
  5. An active PG deal
    • See Create a deal tutorial
    • The deal's status must be active (statusId 1). If you attach more than one deal, they must all use the same payment type.

Create a PG campaign using the IQM API​

This tutorial covers how to create a PG campaign and check its status.

The minimum requirements to perform this task are: logging in with authentication credentials and creating a PG campaign. Once these steps are accomplished, more can be learned about IQM's API through the guidelines pages.

  1. Log in
    • Optional if you have already logged in and have a token
  2. Create a PG campaign
    • 2.1 Create a PG campaign, provide necessary targeting parameters
    • 2.2 Check campaign's status

Authentication​

Use the following header parameters for all requests after logging in:

Headers
Authorization
string required
Bearer followed by the access_token from the login response.
See Sign up and authenticate.
X-IAA-OW-ID
integer required
Organization Workspace ID header.

Step 1: Log in​

POST

To log in, send the Authorization: Basic header with your Base64-encoded Client ID and Client Secret, and send the request body as form data (application/x-www-form-urlencoded). The response contains an OAuth access token.

To find the Organization Workspace IDs that you have access to, use Get list of accessible Organizations.

For further information see OAuth token.

Headers
Authorization
string required
Basic followed by your Base64-encoded client_id:client_secret.
See Sign up and authenticate.
Content-Type
string required
application/x-www-form-urlencoded. Send the request body as form data.
Request schema
grant_type
string required
password for login.
See OAuth Grant Types.
username
string required
User account email.
password
string required
User account password.
Request sample
curl -i --location 'https://api.iqm.com/api/v3/ua/oauth/token' \
--header 'accept: application/json, text/plain, */*' \
--header 'Authorization: Basic <Client ID/Client Secret>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=user@iqm.com' \
--data-urlencode 'password=<your password>'
Response 200
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIn0...",
"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCIgOiAiSldUIn0...",
"scope": "read write",
"token_type": "bearer",
"expires_in": 86399
}
More responses
Response 401
{
"success": false,
"errorObjects": [
{
"error": "Bad Credentials or invalid grant type"
}
]
}
Response 403
{
"error": "Client details are not provided."
}

Step 2: Create a PG campaign​

Step 2.1: Create campaign​

POST

Once you are logged in and have met the prerequisite conditions (see Before you begin), you can create a PG campaign. You need a creative, an insertion order, and an active PG deal to create a PG campaign. A conversion is optional. Review the request schema table below for all the other parameters required for this endpoint.

info

Make sure that the budgetTypeId of your PG campaign matches the ioBudgetTypeId of your insertion order.

Request schema
pgCampaignInfo
object required
Object containing campaign information.
pgCampaignInfo object properties
campaignName
string required
Name of campaign.
ioId
integer required
Insertion Order ID.
timeZoneId
integer required
Timezone ID.
totalImpressions
integer optional
Targeted impressions for impression-based campaign as budget, use if not a dollars-based campaign.
spendingBudget
number optional
Total budget of the campaign for dollars-based campaign, use if not an impressions-based campaign.
maxBid
number required
Maximum allowed bid price for campaign.
startTime
integer required
Unix epoch start time of campaign, in seconds.
endTime
integer
Unix epoch end time of campaign, in seconds.
budgetTypeId
integer required
Budget type ID of given campaign (impression-based or dollar-based).
Supported values
1Budget
2Impression
campaignTypeId
integer
Campaign type ID.
Supported values
1Advanced campaign
2PG campaign
advertiserDomain
string required
Domain of the Advertiser user.
creativeTargeting
object required
Object containing creative targeting details.
creativeTargeting object properties
creativeTypeId
integer
Creative type ID.
Supported values
0All
11Image
13HTML
14Video
15Native
17Audio
creativeIds
array of integers
IDs of creatives attached to this campaign.
inventoryTargeting
object required
Object containing inventory targeting details.
inventoryTargeting object properties
pgDealIds
array of integers
PG deal IDs attached to this campaign.
conversionTargeting
object
Object containing campaign conversion targeting details.
conversionTargeting object properties
conversionTypeId
integer
Conversion type ID attached to this campaign.
Supported values
1Pixel
2Postback
3Universal Pixel
conversionIds
array of integers
IDs of conversions attached to this campaign.
politicalAdvertiserClientId
integer optional
Advertiser client ID if user is Political Advertiser. Omit it otherwise.
countryId
integer
ID of targeted country (for example, 30100001 for the US).
Request sample
{
"pgCampaignInfo": {
"campaignName": "test imps PG campaign",
"ioId": 95179,
"timeZoneId": 29,
"totalImpressions": 12345,
"maxBid": 8,
"startTime": 1803859200,
"endTime": 1806451200,
"budgetTypeId": 2,
"campaignTypeId": 2,
"advertiserDomain": "https://www.xyz.com"
},
"creativeTargeting": {
"creativeTypeId": 11,
"creativeIds": [
644506
]
},
"inventoryTargeting": {
"pgDealIds": [
30,
12
]
},
"conversionTargeting": {
"conversionTypeId": 1,
"conversionIds": [
465,
687,
987
]
},
"countryId": 30100001
}
Response 201
{
"success": true,
"data": {
"campaignId": 625981,
"message": "PG Campaign Created successfully"
}
}
More responses
Response 422
{
"success": false,
"errorObjects": [
{
"error": "Invalid country/countries"
}
]
}

Step 2.2: Check campaign status​

GET

To run a campaign, it must be approved. Use the campaignId returned from the last step to check the created campaign's status.

Path parameter
campaignId
integer required
Campaign ID.
Response 200
{
"statusCode": 200,
"responseObject": {
"owId": 204851,
"parentOrganizationName": "Example Workspace",
"id": 625981,
"uowId": 291477,
"campaignName": "test imps PG campaign",
"advertiserDomain": "https://www.xyz.com",
"creativeType": 11,
"campaignType": 1,
"totalBudgetPacing": false,
"isTvAd": false,
"budgetDay": 0.0,
"budgetTotal": 108.636,
"maxBid": 8.0,
"allowedMinBid": 0.0,
"timezone": 29,
"startTime": 1803859200,
"endTime": 1806451200,
"status": "pending",
"dspMargin": 0,
"platformMargin": 0,
"userDealMargin": 0,
"spentScale": false,
"creativeIds": "803406",
"conversionType": "None",
"bidOptimization": true,
"bidPacing": true,
"isBidShading": false,
"impressionCapping": 0,
"frequencyCapEnabled": false,
"totalImpressions": 12345,
"exchanges": "",
"isLocationWithOrFilter": true,
"countryId": "30100001",
"locationDetails": {},
"isCampaignFromNewPlatform": true,
"organizationName": "Example Organization",
"userEmail": "user@example.com",
"userName": "Jane Smith",
"conversionIds": "8072",
"conversionTypeId": 1,
"isUnapprovedAudienceTargeted": false,
"isAllAudienceUnapproved": false,
"createDate": 1793041194,
"ioId": 29317,
"ioName": "PG IO 1",
"prebidAudienceSegmentIdList": [],
"campaignTypeId": 2,
"pgDealIds": [
2680
],
"spendingBudget": 98.76,
"pgFeesPercentage": 10.0,
"pgFeesBudget": 9.876,
"pgPaymentTypeId": 2,
"budgetTypeId": 2,
"isEstimatorAvailable": true,
"isAdvanceAudioVideoTargeted": false,
"isEditAccess": true,
"isParentInvoiceTemplateSet": true,
"isMarginSet": true,
"isApprovalAccess": false
}
}
Have a question?
Was this page helpful?