Skip to main content

Campaign Management

A campaign is an advertising activity unit that allows advertisers to execute specific ads and measure performance according to their set goals. A2 provides the essential APIs needed to manage campaigns, including creating new campaigns, retrieving campaigns, and modify and deleting in existing campaigns, as well as APIs related to approvals for campaigns.

Create Campaign

First, you need to create a campaign to ads. When you create a campaign, you can set a number of settings, including the duration of the campaign, the budget to use, the bidding strategy, and the campaign goals.
Create Campaign Example
curl --request POST \
  --url https://your_a2_service/campaigns \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "test campaign",
  "description": "test campaign",
  "start_date": "2025-04-12 16:47:03.773",
  "end_date": "2025-05-13 16:47:03.773",
  "goal": "impression",
  "sub_goal": "maximize_volume",
  "status": "okay",
  "budget": "10000",
  "bid_strategy": "bid_cap",
  "owner_id": "{owner-user-id}"
}'

Create Creative

Creating a campaign isn’t enough to run an ad. You can prepare to run an ad by registering the creative that you want to show on the placement. Campaigns can have a variety of creative types, including images, video, native. However, if the creative in your campaign doesn’t match the type of creative required by the placement, you won’t be able to allocate.
Create Creative Example
curl --request POST \
  --url https://your_a2_service/creatives \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "test creative",
  "type": "banner",
  "staatus": "inactive",
  "width": 300,
  "height": 100,
  "banner": {
    "img": "https://example.com/creative.png"
  },
  "cid": "{campaign-id}",
  "owner_id": "{owner-user-id}"
}'

Approvement of a Campaign

Once you’ve created a campaign, you can request to run it as an ad. The requested campaign will be reviewed based on own criteria, and if approved, it will begin running immediately.

Request Publish

Once your campaign has been successfully created, you can request that your ad appear in placement. At this point, you must have at least one activated creative, and it must match the creative format of the placement.
Create Allocation Example
curl --request POST \
  --url https://your_a2_service/allocations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "tagid": "{placement-id}",
  "status": "pending",
  "cid": "{campaign-id}",
  "crid": "{creative-id}",
  "owner_id": "{owner-user-id}"
}'

Approve and Reject

The creatives or links used in the campaign may not meet your standards. At this point, you need to go through a review before you can approve. If the campaign is approved or rejected, you can update the results using the campaign update API. \ You can also set the last_comment to reply the reason for the rejection.

Status Code

codedescription
pendingInitial state
requestedpublish requested
publishedpublished
rejectedRejected
canceledcanceled
finishedfinished
Update Allocation Example
curl --request PATCH \
  --url https://your_a2_service/allocations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "tagid": "{placement-id}",
  "status": "published",
  "cid": "{campaign-id}",
  "crid": "{creative-id}",
  "owner_id": "{owner-user-id}"
}'

Metric of Campaign

Once your campaign is approved, the ad will start showing immediately. Campaign metrics are collected and managed for each ad served. This data can help to be more effective campaign strategy.

Metric Analysis

You can see how your campaigns are performing by metric APIs for any timeframe, including daily, hourly, and more.
Get Campaign Hourly Metric Example
curl --request POST \
  --url https://your_a2_service/metric/campaigns_hourly \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "campaign_id": "{campaign_id}",
  "tagid": "{placement-id}",
  "from_datetime": "2025-03-14 16:47:03.773",
  "to_datetime": "2025-04-13 16:47:03.773"
}'