> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.orbitdev.org/llms.txt
> Use this file to discover all available pages before exploring further.

# How Orbit Selects Ads: Auction Mechanics Explained

> Understand how select_ad picks the winning ad in Orbit Audience Engine. Learn about eligibility filters, ranking, row locks, rendering, and future relevance.

The `select_ad` database function powers ad selection in Orbit Audience Engine. It runs entirely inside the database and returns no result unless the user is on an ad-supported plan and has allowed personalized or non-personalized advertising.

## Eligibility filters

Before ranking, `select_ad` applies these filters in order:

1. **Plan and consent**: user must be on an ad-supported plan with appropriate consent (personalized for segment targeting, non-personalized for contextual)
2. **Campaign approval and schedule**: campaign and creatives must be approved, and the current date must fall within the campaign schedule
3. **Budget and balance**: remaining daily and total budgets must be positive, and the organization balance must be sufficient
4. **Country, device, and placement**: must match the campaign targeting rules
5. **Frequency caps**: user must not have exceeded daily or weekly impression limits
6. **Segment qualification** (for segment-targeted campaigns): user must have a qualifying non-sensitive interest score

## Ranking

Eligible creatives rank by:

```text theme={"dark"}
bid_micros × quality_score
```

Higher values win the auction. The winning campaign receives a row lock during selection to prevent race conditions in budget and balance updates.

## Rendering

Impressions render using `SponsoredCard` (or its placement variants). Every rendered ad must display the label "Sponsored".

## Charge timing

* **CPM**: charged at impression creation
* **CPC**: charged on an eligible unique click via the Advertising API
* **CPA**: charged on an eligible idempotent conversion via the Advertising API

## MVP internal auction and future relevance

The current release uses an internal auction based on bid and quality score. Predicted relevance can be introduced later without exposing user profiles or changing the advertiser contract.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.