> For the complete documentation index, see [llms.txt](https://docs.relevant-digital.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.relevant-digital.com/technical/integration/advanced-implementation-patterns/remove-sizes-from-the-prebid-auction.md).

# Remove sizes from the Prebid auction

## **Overview**

This article outlines a method by which a publisher can remove a size from the prebid auction whilst maintaining that size in the call to the adserver.

This example involves the use of the '[onAuctionInitDone](https://help.relevant-digital.com/knowledge/relevantdigital.loadprebid)' callback. A callback function invoked after all the placements are setup but before the pbjs auction.

Using the onBeforeAdRequest exposes the auction.usedUnitDatas object from which we can retrieve the adUnit information that will become the pbjs.adUnit object.

### **Code**

```
relevantDigital.addAuctionCallbacks({
    onAuctionInitDone: function({ auction }) {
        auction.usedUnitDatas.forEach(({ pbAdUnit }) => {
            const { sizes } = (pbAdUnit.mediaTypes || {}).banner || {};
            const sizesToRemove = [[1,1]]
            if (sizes) {
                const newSizes = sizes.filter(size => {
                  return !sizesToRemove.some(([w, h]) => size[0] === w && size[1] === h);
              });
          
              if (newSizes.length > 0) {
                  pbAdUnit.mediaTypes.banner.sizes = newSizes;
                  if (pbAdUnit.sizes) {
                      pbAdUnit.sizes = newSizes;
                  }
              }
            }
        });
    },
  });
```

## **Walk-through**

Opposed to demonstrating the usecase in relevantDigital.loadPrebid(), the code is using [relevantDigital.addAuctionCallbacks](https://help.relevant-digital.com/knowledge/relevantdigital.addauctioncallbacks) instead. The addAuctionCallbacks function is useful for implementing callback functions in scenarios where it may not be possible to edit relevantDigital.loadPrebid().

onAuctionInitDone is a function invoked after the placement is setup and before the pbjs auction. It yields an auction object that contains a 'usedUnitDatas' array of objects that will participate in the auction. For each of these 'usedUnits' we would then like to retrieve the 'pbAdUnit' object.

The 'pbAdUnit' object exposes all the information on what the [prebid AdUnit](https://docs.prebid.org/dev-docs/adunit-reference.html) setup will be before it is pushed to pbjs.

From each 'pbAdUnit' we can retrieve the sizes from the mediaTypes.banner and then we can define an array of 'sizesToRemove'.

If the sizes array is defined then a 'newSizes' array can be produced, filtering out the 'sizesToRemove' from 'sizes'.

'newSizes' array can then be pushed back to the pbAdUnit.mediaTypes.banner.sizes or pbAdUnit.sizes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.relevant-digital.com/technical/integration/advanced-implementation-patterns/remove-sizes-from-the-prebid-auction.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
