RTB gates are a specialized set of quality checks built for programmatic advertising pipelines. Unlike general gates that evaluate a single output, every RTB gate receives both the original OpenRTB request (Documentation Index
Fetch the complete documentation index at: https://docs.pecta.ai/llms.txt
Use this file to discover all available pages before exploring further.
ctx.input) and the bidder’s response (ctx.output). This lets gates cross-reference fields like impression IDs, floor prices, and blocked categories across the bid exchange boundary.
These gates are aimed at DSPs building bidding agents, SSPs validating responses before auction, and ad exchanges enforcing protocol compliance at scale. All six gates run in-process inside your Node.js application — no network hop, no added latency beyond the gate logic itself.
Available RTB gates
| Gate | Import | What it checks |
|---|---|---|
tmaxGuard | gates.rtb.tmaxGuard() | Skips downstream gates when the OpenRTB tmax deadline is exhausted |
impidMatch | gates.rtb.impidMatch() | Every bid.impid in the response matches a imp.id in the request |
adomainVerify | gates.rtb.adomainVerify() | Bids do not contain placeholder or malformed advertiser domains |
bidSanity | gates.rtb.bidSanity() | Bid prices are not unrealistically far above the impression floor |
audienceSafety | gates.rtb.audienceSafety() | Child-directed inventory does not serve unsafe creative categories |
bcatCompliance | gates.rtb.bcatCompliance() | Creative categories do not appear in the request’s bcat blocked list |
Full RTB engine setup
Pass the full OpenRTB request asinput and the bid response as output. Set tmaxMs and startedAt on the context so tmaxGuard can calculate remaining deadline budget.
Request and response context
RTB gates differ from general gates in one key way: they need both sides of the bid exchange.ctx.input— the raw OpenRTB 2.5/2.6 bid request objectctx.output— the raw OpenRTB bid response objectctx.tmaxMs— thetmaxvalue from the request (milliseconds)ctx.startedAt— wall-clock timestamp (ms) when the request arrived
bcatCompliance, which reads bcat from the request) will skip gracefully when the relevant field is absent rather than failing hard.
Gate ordering
Always place
tmaxGuard first in your gate list. When the tmax deadline budget is exhausted, tmaxGuard returns skipped: true and the engine’s failFast behavior short-circuits all remaining gates. This prevents wasted evaluation time on a bid that is already too late to use.skipped result is treated as a pass — it does not count against the agent’s reputation score and does not block the bid. The remaining gates in the list are not run once a skip is triggered via the engine’s fail-fast path.