# Advertiser Management API

The DT Offer Wall Advertiser Management API allows you to update application bids automatically through a GraphQL endpoint. This API is intended for programmatic access only. The API token is only available in the ACP Edge console.

## Authentication and Obtaining an API Token <a href="#h_01k2kx1vb3shyts19cfgextjsv" id="h_01k2kx1vb3shyts19cfgextjsv"></a>

Every request to the DT Offer Wall Advertiser Management API must be authenticated with an API token. This token identifies the advertiser account.

To create an API Token:

1. In the [ACP Edge Console](https://acp-edge.fyber.com/), go to **Account→Security Tokens** and click **Add Token**.\
   The **Create Token** window appears.

<div align="left" data-with-frame="true"><img src="/files/PY7xdxU1bOfQLm0Cypkp" alt=""></div>

2. Select **Management API Token** and click **Create**.

<div align="left" data-with-frame="true"><img src="/files/2kGrQE9OkAL39H8YCoIH" alt="" width="450"></div>

3. To copy and save your newly created token, click **Copy Last Created Token** and save the copied token in a secure location.

{% hint style="warning" %}
You must keep a copy of your token. It is displayed only once when generated, and cannot be retrieved again.
{% endhint %}

## Authentication <a href="#h_01k2kx1vb3r1dnrfmq14nc736e" id="h_01k2kx1vb3r1dnrfmq14nc736e"></a>

To authenticate your GraphQL query, set `x-api-key` HTTP header with the token, for example:

```
x-api-key: 7H3r3i5n05XXXn0NlYm47XXX
```

The API endpoint is:

```
https://acp-edge-api.fyber.com/graphql
```

## Request <a href="#h_01k2kx1vb3fs8n1mb7bkkgf00t" id="h_01k2kx1vb3fs8n1mb7bkkgf00t"></a>

`campaignBulkBidsManage` allows you to update bids in bulk and change a campaign's activation status.

**GraphQL Query**

{% code title="GraphQL Query" %}

```graphql
mutation campaignBulkBidsManage(
  $offerCmsId: ID!,
  $offerEnabled: Boolean,
  $bidsList: [OfferCampaignBulkUpdateBidItemInput!]!
) {
  offerCampaignBulkUpdateBids(
    input: {
      offerCmsId: $offerCmsId, 
      bidsList: $bidsList
    }
  ) {
   errors
 }
}
```

{% endcode %}

**GraphQL Variables**

{% code title="GraphQL Variables" %}

```graphql
{
	"offerCmsId": "12",        
        "offerEnabled":true,
	"bidsList": [
          {
              "applicationId": "5",
              "bid": "1.1",
              "countryCode": "DE",
              "dailyBudget": "2.3"
          }, {
              "bid": "3.14"
          }
     ]
}
```

{% endcode %}

#### Parameters <a href="#h_01k2m6tgwhh9hewged4wyk3j29" id="h_01k2m6tgwhh9hewged4wyk3j29"></a>

* `offerCmsId` (Required): Campaign ID in the legacy CMS format. It appears below the **Product Name** column on the ACP Edge Dashboard. Alternatively, you can retrieve it by including the `cmsId` field to get it back in the response. For more information, see [Query Offer](#h_01k2kx1vb3901ytx38amhqrbcf).

<div align="left" data-with-frame="true"><img src="/files/kMkxo33WQVRQgOw0Y9vO" alt=""></div>

* `offerEnabled` (Optional, boolean): `true` enables an offer; `false`, disables an offer. If not provided, the offer status remains unchanged.
* `bidsList` (Required, array): An array of bid objects that can be updated in bulk. Every element of the array can contain up to four options: two filter matching bids, and the remaining two set desired parameters. All elements are matched against the top `offerCmsId` which means that a single request can only update bids for one campaign.
* `applicationId` (Optional, string): Filters for applications using its CMS ID. It appears below the **Campaign Name** in the ACP Edge Dashboard.

<div align="left" data-with-frame="true"><img src="/files/3P39GddVgNXGFeYYwifF" alt=""></div>

* `SupplyApplicationsList` Query and include the `cmsld` field to get it back in the response.
* `countryCode` (Optional, string): Filtering option. Filters for a specific country using its ISO 3166-1 alpha-2 (two letters) country code. Only bids set for this country are updated. You can see the country's ISO code for any country by calling a `CountriesList` query.
* `bid` (Optional, string): Setter option. Sets the bid value for all matching applications and/or country codes or the top-level offer. This field can be set in two ways:
* As a string representing float value, such as `2.71` by setting a bid to that value.
* As a word `default` sets the bid to the default country value (which can be a default value for an offer).
* `dailyBudget` (Optional, string): Sets the new daily budget for the matching offer or country. This field can be set in two ways:
* As a string representing float value such as `2.71`.
* As a word `default` sets the bid to the default country value (which can be a default value for an offer).

## Validation <a href="#h_01k2kx1vb3rdv8at748wq73cvq" id="h_01k2kx1vb3rdv8at748wq73cvq"></a>

To ensure data integrity, the following rules apply to each `bidsListelement` element, before any destructive action takes place:

* `bid` or `dailyBudget` has to be set specifically for application or can be set both for offer or countries.
* A `bid` cannot be set to `default` if a `countryCode` is not set.
* A `dailyBudget` cannot be set at the `applicationId` level.
* An `applicationId` cannot be set without a `countryCode`.
* A `countryCode` must be targeted by a campaign associated with `offerCmsId`.
* An `applicationId` must be targeted by a campaign associated with `offerCmsId`.
* A `dailyBudget` cannot be set for both the offer campaign and the country code simultaneously (this includes offers that already have a daily budget configured).

## Examples <a href="#h_01k2kx1vb3gy0hhtj0djdffrpy" id="h_01k2kx1vb3gy0hhtj0djdffrpy"></a>

**HTTP**

{% code title="HTTP" %}

```http
POST /graphql HTTP/1.1
Content-Type: application/json
X-Api-Key: 7H3r3i5n05P00n0NlYm47RIX
Host: acp-edge-api.fyber.com
Content-Length: 399

{"query":"mutation campaignBulkBidsManage($offerCmsId: ID!, 
$offerEnabled: Boolean, $bidsList: 
[OfferCampaignBulkUpdateBidItemInput!]!) 
{\n offerCampaignBulkUpdateBids(input: {offerCmsId: 
$offerCmsId, offerEnabled: $offerEnabled, bidsList: $bidsList}) 
{\n errors\n }\n}\n","variables":{"offerCmsId":"12",
"offerEnabled":true,"bidsList":[{"applicationId":"5","bid":"1.1",
"countryCode":"DE"},{"bid":"3.14"}]},"operationName":
"campaignBulkBidsManage"}
```

{% endcode %}

**curl**

<pre data-title="curl"><code><strong>curl --request POST \
</strong>--url https://acp-edge-api.fyber.com/graphql \
--header 'Content-Type: application/json' \
--header 'x-api-key: 7H3r3i5n05P00n0NlYm47RIX' \
--data '{"query":"mutation campaignBulkBidsManage($offerCmsId: ID!, 
$offerEnabled: Boolean, $bidsList: 
[OfferCampaignBulkUpdateBidItemInput!]!) 
{\n offerCampaignBulkUpdateBids(input: {offerCmsId: $offerCmsId, 
offerEnabled: $offerEnabled, bidsList: $bidsList}) 
{\n errors\n }\n}\n","variables":{"offerCmsId":"12",
"offerEnabled":true,"bidsList":[{"applicationId":"5","bid":"1.1",
"countryCode":"DE"},{"bid":"3.14"}]},"operationName":
"campaignBulkBidsManage"}'
</code></pre>

**GO**

{% code title="GO" %}

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {
	url := "https://acp-edge-api.fyber.com/graphql"

	payload:=strings.NewReader(`{"query":"mutation 
campaignBulkBidsManage($offerCmsId: ID!, $offerEnabled: 
Boolean, $bidsList: [OfferCampaignBulkUpdateBidItemInput!]!) 
{\\n  offerCampaignBulkUpdateBids(input: {offerCmsId: 
$offerCmsId, offerEnabled: $offerEnabled, bidsList: $bidsList}) 
{\\n    errors\\n  }\\n}\\n","variables":{"offerCmsId":"12",
"offerEnabled":true,"bidsList":[{"applicationId":"5","bid":"1.1",
"countryCode":"DE"},{"bid":"3.14"}]},"operationName":
"campaignBulkBidsManage"}`)

	req, _ := http.NewRequest("POST", url, payload)
	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("x-api-key", "7H3r3i5n05P00n0NlYm47RIX")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))
}
```

{% endcode %}

**Java**

{% code title="Java" %}

```java
HttpResponse<String> response =
Unirest.post("https://acp-edge-api.fyber.com/graphql")
       .header("Content-Type", "application/json")
       .header("x-api-key", "7H3r3i5n05P00n0NlYm47RIX")
       .body("{\"query\":\"mutation campaignBulkBidsManage
($offerCmsId: ID!, $offerEnabled: Boolean, $bidsList: 
[OfferCampaignBulkUpdateBidItemInput!]!) 
{\\n offerCampaignBulkUpdateBids(input: {offerCmsId: 
$offerCmsId, offerEnabled: $offerEnabled, bidsList: 
$bidsList}) {\\n errors\\n }\\n}\\n\",\"variables\":{\
"offerCmsId\":\"12\",\"offerEnabled\":true,\"bidsList\
":[{\"applicationId\":\"5\",\"bid\":\"1.1\",\"countryCode\
":\"DE\"},{\"bid\":\"3.14\"}]},\
"operationName\":\"campaignBulkBidsManage\"}")
       .asString();
```

{% endcode %}

**node.js**

{% code title="node.js" %}

```js
const http = require("http");

const options = {
  "method": "POST",
  "hostname": "acp-edge-api.fyber.com",
  "path": "/graphql",
  "headers": {
	"Content-Type": "application/json",
	"x-api-key": "7H3r3i5n05P00n0NlYm47RIX"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
	chunks.push(chunk);
  });

  res.on("end", function () {
	const body = Buffer.concat(chunks);
	console.log(body.toString());
  });
});

req.write("{\"query\":\"mutation campaignBulkBidsManage($offerCmsId: 
ID!, $offerEnabled: Boolean, $bidsList: 
[OfferCampaignBulkUpdateBidItemInput!]!) 
{\\n offerCampaignBulkUpdateBids(input: {offerCmsId: 
$offerCmsId, offerEnabled: $offerEnabled, bidsList: $bidsList}) {
\\n errors\\n }\\n}\\n\",\"variables\":{\"offerCmsId\":\"12\",\
"offerEnabled\":true,\"bidsList\":[{\"applicationId\":\"5\",
\"bid\":\"1.1\",\"countryCode\":\"DE\"},{\"bid\":\"3.14\"}]},
\"operationName\":\"campaignBulkBidsManage\"}");
req.end();
```

{% endcode %}

**Ruby**

{% code title="Ruby" %}

```ruby
require 'uri'
require 'net/http'

url = URI('https://acp-edge-api.fyber.com/graphql')

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request['Content-Type'] = 'application/json'
request['x-api-key'] = ‘7H3r3i5n05P00n0NlYm47RIX’
request.body = '{"query":"mutation campaignBulkBidsManage($offerCmsId: 
ID!, $offerEnabled: Boolean, $bidsList: 
[OfferCampaignBulkUpdateBidItemInput!]!) 
{\n offerCampaignBulkUpdateBids(input: {offerCmsId: $offerCmsId, 
offerEnabled: $offerEnabled, bidsList: $bidsList}) {\n errors\n 
}\n}\n","variables":{"offerCmsId":"12","offerEnabled":true,"bidsList"
:[{"applicationId":"5","bid":"1.1","countryCode":"DE"},{"bid":"3.14"}]},
"operationName":\"campaignBulkBidsManage"}'

response = http.request(request)
puts response.read_body

```

{% endcode %}

### Query Offer <a href="#h_01k2kx1vb3901ytx38amhqrbcf" id="h_01k2kx1vb3901ytx38amhqrbcf"></a>

You can run queries to retrieve attributes from an offer and other related records, as shown in the following example:

**GraphQL Query**

{% code title="GraphQL Query" %}

```graphql

query ($offerId: ID!, $offerCmsId: ID!) {
  offerCampaign(id: $offerId, cmsId: $offerCmsId) {
    id
    cmsId
    name
    enabled
    bid
    title
    startDate
    endDate
    countryGroupBudgets
    ...locationTargetingFields
    ...countryGroupFields
  }
}

fragment locationTargetingFields on OfferCampaign {
  locationTargeting {
    countryCodes
    global
  }
}

fragment countryGroupFields on OfferCampaign {
  countryGroups {
    id
    countryCodes
    bid
    capping {
      dailyBudget
    }
    ...applicationBidFields
  }
}

fragment applicationBidFields on CountryGroup {
  applicationBids {
    id
    bid
  }
}
```

{% endcode %}

{% hint style="info" %}
Fragments are included only for brevity. You can also use the full GraphQL query with all associations nested.
{% endhint %}

**GraphQL Variables**

{% code title="GraphQL Variables" %}

```graphql
{
  "offerId": "1",
  "offerCmsId": "1234"
}
```

{% endcode %}

#### Parameters <a href="#id-01k2m8m09znsw6503ys6zyc9at" id="id-01k2m8m09znsw6503ys6zyc9at"></a>

* `cmsId` (Optional, required if `id` not used): The offer ID in the legacy CMS format, which appears on the ACP Edge Dashboard next to the offer name.
* `id` (Optional, required if `cmsId` is not used): The offer ID, which you can extract from the edit/view offer URL. For example, in `https://acp-edge.fyber.com/editOffer/1234`, the ID is `1234`.

{% hint style="info" %}
You must provide either `cmsId` or `id`, but not both. If both are included, the API returns an error.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalturbine.com/dt-offer-wall/advertisers/advertiser-management-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
