Create a PG Campaign
IQM’s REST API enables you to interact with most of our platform's applications.
The following endpoints will be used to create a PG Campaign:
/api/v3/ua/login/api/v3/cmp/pg/campaigns/add
/api/v2/cmp/campaign/{campaignId}
About IQM PG Campaigns
IQM's Programmatic Guaranteed (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.
See How Do I Set Up a Programmatic Guaranteed (PG) Campaign for more information.
Before You Begin
To create a PG Campaign, the following are required:
- An Account On the IQM Platform
- See Getting Started section to create an account and request a Client ID and Client Secret
- An Approved and Running Creative
- See Upload a Creative Quickstart Guide to upload a Creative
- An Insertion Order
- See Create a Campaign Quickstart Guide to create a new Insertion Order
- A Conversion
- See Create a Conversion Tutorial
- A PG Deal
Create a PG Campaign Using the IQM API
This Quickstart Guide will cover how to create a Campaign and upload a Creative.
The minimum requirements to perform this task are: logging in with authentication credentials, uploading a Creative, and creating a Campaign. Once these steps are accomplished, more can be learned about IQM's API through the Guidelines pages.
- Log In
- Optional if you have already logged in and have a token
- Create a PG Campaign
- 2.1 Create a PG Campaign, provide necessary targeting parameters
- 2.2 Check Campaign's status
Step 1: Log in
POST /api/v3/ua/loginTo log in, the Authentication: Basic header is required. The Login API returns an OAuth-compliant response with an Organization Workspace ID (owId), a unique identifier for each Organization. This ID will be used for any further API communications.
For further information see the complete Login API Documentation.
Headers | |
---|---|
Authentication string required | Authentication bearer token See Authentication Guide |
X-IAA-HOST string required | Workspace URL |
Request Schema | |
---|---|
grantType string required | OAuth Grant Types |
email string required | User account email |
password string required | User account password |
- JSON
- TypeScript
{
"grantType": "password",
"email": "pratik.t+ihp@iqm.com",
"password": "123456"
}
{
"success": true,
"data":
{
"access_token": "106adb25-37b0-4cab-8381-d682fe7cc3c8",
"refresh_token": "eac4c1f6-781e-4b04-baff-9c2e415d1f64",
"scope": "read write",
"token_type": "bearer",
"expires_in": 35999,
"owId": 200001
}
}
More Responses
{
"success": false,
"data":
{
"status": "On Hold",
"reason": "The particular account is kept on hold due to missed payment dates for last 3 months.",
"supportEmail": "support@iqm.com"
},
"errorObjects":
[
{
"error": "User is not allowed to access provided customer",
"reason": "User is not associated with any active organization."
}
]
}
{
"success": false,
"errorObjects":
[
{
"error": "User doesn't exist or user is not allowed to provided workspace."
}
]
}
See TypeScript Prerequisites page for usage.
import {
getInstance
} from "prerequisites"
const axios = getInstance();
interface Responses {
200: {
content: {
"application/json": {
success: boolean;
data: {
access_token: string;
refresh_token: string;
scope: string;
token_type: string;
expires_in: number;
owId: number;
};
};
};
};
400: {
content: {
"application/json": {
success: boolean;
data: {
status: string;
reason: string;
supportEmail: string;
};
errorObjects: {
error: string;
reason: string;
}[];
};
};
};
403: {
content: {
"application/json": {
success: boolean;
errorObjects: {
error: string;
}[];
};
};
};
};
function Login(): Promise < Responses > {
const options = {
method: 'POST',
url: 'https://app.iqm.com/api/v3/ua/login',
requestBody: {
content: {
"application/json": {
email: `string`,
password: `string`,
}
}
}
};
return axios.request(options).then(({ data }: { data: Responses }) => data);
}
Step 2: Create a PG Campaign
Step 2.1 Create Campaign
POST /api/v3/cmp/pg/campaigns/addOnce you are logged in and have met the prerequisite conditions (see Before You Begin), you can create a PG Campaign. You will need a Creative, an Insertion Order, a Conversion, and a PG Deal to create a PG Campaign. Review the Request Schema table below for all the other parameters required for this endpoint.
Make sure that the budgetTypeId of your PG Campaign matches the ioBudgetTypeId of your Insertion Order.
Headers | |
---|---|
Authentication string required | Authentication bearer token See Authentication Guide |
X-IAA-OW-ID integer required | Organization Workspace ID Header |
Request Schema | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pgCampaignInfo object | Object containing Campaign information | |||||||||||||||||||||||
|
campaignName string | Name of Campaign |
ioId integer | Insertion Order ID |
timeZoneId integer | Timezone ID |
totalImpressions integer optional | Targeted impressions for impression-based Campaign as budget, use if not a dollars-based Campaign |
budgetTotal integer optional | Total budget of the Campaign for dollars-based Campaign, use if not an impressions-based Campaign |
maxBid integer | Maximum allowed bid price for Campaign |
startTime integer | Unix epoch start time of Campaign, in milliseconds |
endTime integer | Unix epoch end time of Campaign, in milliseconds |
budgetTypeId integer | Budget Type ID of given Campaign (impression-based or dollar-based) |
campaignTypeId integer | Campaign Type ID 2: PG Campaign |
advertiserDomain string | Domain of the Advertiser user |
creativeTargeting
object
creativeTargeting
object properties
creativeTypeId integer | Creative Type ID |
creativeIds array of integers | IDs of Creatives attached to this Campaign |
inventoryTargeting
object
inventoryTargeting
object properties
pgDealIds array of integers | PG Deal IDs attached to this Campaign |
conversionTargeting
object
conversionTargeting
object properties
conversionTypeId integer | Conversion type ID attached to this Campaign |
conversionIds array of integers | IDs of Conversions attached to this Campaign |
politicalAdvertiserClientId
integer
countryId
integer
- JSON
- TypeScript
{
"pgCampaignInfo": {
"campaignName": "test imps PG campaign",
"ioId": 95179,
"timeZoneId": 29,
"totalImpressions": 12345,
"maxBid": 8,
"startTime": 1715662337,
"endTime": 1717128000,
"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
]
},
"politicalAdvertiserClientId": 989898,
"countryId": 23
}
{
"success": true,
"data": {
"message": "PG Campaign Created successfully",
"campaignId": 2
}
}
More Responses
{
"success": false,
"errorObjects": [
{
"error": "Invalid campaign Type provided"
}
]
}
See TypeScript Prerequisites page for usage.
import {
getInstance
} from "prerequisites"
const axios = getInstance();
interface Responses {
200: {
content: {
"application/json": {
success: boolean;
data: {
message: string;
campaignId: number
}
}
};
};
422: {
content: {
"application/json": {
success: boolean;
errorObjects: {
error: string
}
}
};
};
}
function addPGCampaign(): Promise<Responses> {
const options = {
method: 'POST',
url: 'https://app.iqm.com/api/v3/cmp/pg/campaigns/add',
requestBody: {
content: {
"application/json": {
countryId?: `number`,
politicalAdvertiserClientId?: `number`,
conversionTargeting?: {
conversionTypeId?: `number`,
conversionIds: `array of numbers`,
},
creativeTargeting: {
creativeTypeId: `number`,
creativeIds: `array of numbers`,
},
inventoryTargeting: {
pgDealIds: `array of numbers`,
paymentTypeId?: `number`,
},
pgCampaignInfo: {
campaignName: `string`,
timeZoneId: `number`,
spendingBudget?: `number`,
maxBid: `number`,
startTime: `number`,
endTime?: `number`,
totalImpressions?: `number`,
advertiserDomain: `string`,
ioId: `number`,
budgetTypeId: `number`,
campaignTypeId?: `number`,
owId?: `number`,
uowId?: `number`,
creativeTypeId?: `number`,
status?: `string`,
configObj?: `string`,
totalBudget?: `number`,
pgFeesPercentage?: `number`,
}
}
}
}
};
return axios.request(options).then(({ data }: { data: Responses }) => data);
}
Step 2.2: Check Campaign Status
GET /api/v2/cmp/campaign/{campaignId}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 string required | Campaign ID |
Headers | |
---|---|
Authentication string required | Authentication Bearer Token See Authentication Guide |
X-IAA-OW-ID integer required | Organization Workspace ID Header |
- JSON
- TypeScript
{
"statusCode": 200,
"responseObject": {
"owId": 1,
"parentOrganizationName": "IQM Corporation",
"id": 25859,
"uowId": 9216,
"campaignName": "Test Campaign",
"advertiserDomain": "https://iqm.com",
"creativeType": 11,
"campaignType": 1,
"totalBudgetPacing": false,
"isTvAd": false,
"budgetDay": 10.0,
"budgetTotal": 100.0,
"maxBid": 10.0,
"timezone": 433,
"startTime": 1703794800,
"endTime": 1704614400,
"status": "running",
"dspMargin": 0,
"platformMargin": 0,
"userDealMargin": 0,
"spentScale": false,
"creativeIds": "148971",
"conversionType": "None",
"bidOptimization": true,
"bidPacing": true,
"impressionCapping": 0,
"maxDayImpressions": 0,
"maxDayClicks": 0,
"maxDayConversions": 0,
"totalImpressions": 0,
"totalClicks": 0,
"totalConversions": 0,
"deviceType": "13,15,11,12",
"trafficType": "11,12",
"exchanges": "55,61,58,41,39,47,59,1,54,56,45,16,11,37,57,50,46,53,60",
"isLocationWithOrFilter": true,
"countryId": "30100001",
"locationDetails": {},
"isCampaignFromNewPlatform": true,
"organizationName": "IQM Corporation 1",
"userEmail": "domo@iqm.com",
"userName": "Domo Integration",
"conversionTypeId": 0,
"isUnapprovedAudienceTargeted": false,
"isAllAudienceUnapproved": false,
"createDate": 1703794110,
"ioId": 2695,
"ioName": "Sanity test Io",
"prebidAudienceSegmentIdList": [],
"budgetTypeId": 1,
"isAdvanceAudioVideoTargeted": false,
"isEstimatorAvailable": true,
"isEditAccess": true,
"isApprovalAccess": false,
"isMarginSet": true,
"isParentInvoiceTemplateSet": true
}
}
See TypeScript Prerequisites page for usage.
import {
getInstance
} from "prerequisites"
const axios = getInstance();
interface Responses {
200: {
content: {
"application/json": {
statusCode: number;
responseObject: {
owId: number;
parentOrganizationName: string;
id: number;
uowId: number;
campaignName: string;
advertiserDomain: string;
creativeType: number;
campaignType: number;
totalBudgetPacing: boolean;
isTvAd: boolean;
budgetDay: number;
budgetTotal: number;
maxBid: number;
timezone: number;
startTime: number;
endTime: number;
status: string;
dspMargin: number;
platformMargin: number;
userDealMargin: number;
spentScale: boolean;
creativeIds: string;
spent: number;
conversionType: string;
bidOptimization: boolean;
bidPacing: boolean;
impressionCapping: number;
deviceType: string;
trafficType: string;
exchanges: string;
countryId: string;
locationDetails: Record<string, never>;
isCampaignFromNewPlatform: boolean;
organizationName: string;
userName: string;
isEditAccess: boolean;
isApprovalAccess: boolean;
isMarginSet: boolean;
isParentInvoiceTemplateSet: boolean;
isUnapprovedAudienceTargeted: boolean;
isAllAudienceUnapproved: boolean;
};
};
};
};
};
function Getcampaigndetails(): Promise < Responses > {
const options = {
method: 'GET',
url: 'https://app.iqm.com/api/v2/cmp/campaign/{campaign_id}',
params: {
path: {
campaign_id: `number`
},
query: {
isSpentRequired: `boolean`
}
},
};
return axios.request(options).then(({ data }: { data: Responses }) => data);
}