> For the complete documentation index, see [llms.txt](https://targetmycom.gitbook.io/openrtb_spec/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://targetmycom.gitbook.io/openrtb_spec/openrtb/vk-ad-network-rtb-protocols/in-app-bidding-integration.md).

# In-app bidding integration

### **Integration Architecture**

App bidding is offered through an endpoint that implements the Open Real-Time Bidding (ORTB) protocol to provide bids on individual impression opportunities. The myTarget SDK is required in app bidding to perform the following actions:

* Obtain the `buyeruid` (named `bidderToken` in the myTarget SDK). This token is a required field in the bid request, and is unique both per user and per app; the token is not valid for another user or app.
* Load the bid response, and show an ad if the bidder wins the auction.
* Record impressions and clicks.

#### **Key Steps in the Bidding Flow**

1. **Obtain the bidder token.** VK Ad Network needs this opaque string to respond to a bid request.
2. **Send the bid request and get the bid response.** This is the main interaction with the bidding endpoint. In this step, you send a request for an ORTB bid and then receive either a valid bid response or an error.
3. **Run the auction.** Run an auction and select a winner from among the bid responses.
4. **Retrieve the ad with the bid response.** If VK Ad Network wins the auction, load the ad by passing the ‘id’ field from the bid response to the myTarget SDK on the user's device. Note that the ‘id’ field does not contain the actual ad; it contains information that allows the SDK to retrieve the ad from the myTarget ad server.

#### **Server-to-Server Integration Architecture** In server-to-server integration

&#x20;Is an auction server calls VK Ad Network bidding endpoint and all other demand sources to get bid responses. Then the auction server runs the auction and picks the winning bid.

![](https://paper-attachments.dropbox.com/s_E1D2ED446AB246DA9C102CF83DBCA6BE3EE946D70E705A1DE59DF0CC114C1F27_1592911503876_Screenshot+2020-06-17+at+17.16.51.png)

### Android and iOS client side setup

**Step 1: Making an auction request from Android or iOS client** On the client side, we need to gather the required parameters for the auction request, and send it to the auction server using HTTP request. Here is a method in Android and iOS for making the auction request with bidderToken. The method must not be called from the main thread. The token is generated once per session and remains unchanged until the application is restarted.

* Android \
  `@WorkerThread String token = MyTargetManager.getBidderToken (context);`
* iOS \
  `NSString token = [MTRGManager getBidderToken];`

**Step 2: Loading the ad from bid response on Android/iOS client** Using the response parameters, we can tell which platform won the auction, and load the ad. If the auction was successful and VK Ad Network won the auction, the response parameters will contain a payload string (‘**`bidresponse.seatbid.bid.id`’** param) which we can load the ad from. We can call the `loadFromBid` method on the correct ad format class to load the ad.

* Android `adInstance.loadFromBid (bid_payload);`
* iOS `[adInstance loadFromBid: bid_payload];`

### **ORTB Request/Response and Supported Ad Formats**

VK Ad Network endpoint for server-server integration:

```
https://ad.mail.ru/api/bid
```

See additional requirements for BidRequest&#x20;

{% content-ref url="/pages/YpAZxNt5CEp3mawemNOX" %}
[BidRequest specification requirements](/openrtb_spec/openrtb/vk-ad-network-rtb-protocols/bidrequest-specification-requirements.md)
{% endcontent-ref %}

And special requirements for in-app biddings integration

| parameters             | type                      | descriptions                                                                                       |
| ---------------------- | ------------------------- | -------------------------------------------------------------------------------------------------- |
| **imp.tagid**          | strin&#x67;**; required** | **SlotID** **for** **placement** **in myTarget** **UI** **with integration type ‘in-app bidding’** |
| **.user.ext.buyeruid** | **string; required**      | **Buyeruid value received from myTarget SDK getBidderToken**                                       |
| **.ext.pid**           | integer; **required**     | **Unique partner key (check with the manager)**                                                    |

### TagIDs for integration testing

You can use these TagIDs to test the health of oRTB requests for each format. When you send an oRTB request for these slots with “test”: 1, you are guaranteed to receive a response if your request is valid. Keep in mind requests/impressions from these slots are not charged and are not counted in your account statistics.

| TagID  | Format                    | Platform |
| ------ | ------------------------- | -------- |
| 951593 | Banner 320\*50 (standard) | iOS      |
| 951596 | Fullscreen                | iOS      |
| 951599 | Native                    | iOS      |
| 951602 | Reward                    | iOS      |
| 951605 | Banner 300\*250 (medium)  | iOS      |
| 951608 | Banner 320\*50 (standard) | Android  |
| 951611 | Fullscreen                | Android  |
| 951614 | Native                    | Android  |
| 951617 | Reward                    | Android  |
| 951620 | Banner 300\*250 (medium)  | Android  |

{% content-ref url="/pages/VDCk3NMAE655kCSZPLNW" %}
[in-app bidding integration](/openrtb_spec/openrtb/vk-ad-network-rtb-protocols/example-bidrequest-and-bidresponse/in-app-bidding-integration.md)
{% endcontent-ref %}
