{
    "id": "http://prebid.org/pbs_request.json",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "schema for a Prebid Server request",
    "type": "object",
    "required": [
        "account_id",
        "ad_units"
    ],
    "properties": {
        "account_id": {
            "type": "string"
        },
        "tid": {
            "description": "Unique transaction ID",
            "type": "string"
        },
        "timeout_millis": {
            "description": "How long to wait for adapters to return bids",
            "type": "integer"
        },
        "secure": {
            "description": "Flag to indicate if the impression requires secure HTTPS URL creative assets and markup, where 0 = non-secure, 1 = secure. If omitted, the secure state will be interpreted from the request to the prebid server",
            "type": "integer"
        },
        "cache_markup": {
            "description": "Caches markup for two-phase response (get response then separate call to get markup)",
            "type": "integer"
        },
        "sort_bids": {
            "description": "Sorts bids by price & response time and returns ad server targeting keys for each bid in prebid server response",
            "type": "integer"
        },
        "max_key_length": {
            "description": "Used to determine whether ad server targeting key strings should be truncated on prebid server. For DFP max key length should be 20.",
            "type": "integer"
        },
        "app": {
            "type": "object",
            "description": "This object should be included if the ad supported content is a non-browser application (typically in mobile) as opposed to a website. At a minimum, it is useful to provide an App ID or bundle, but this is not strictly required.",
            "properties": {
                "name": {
                    "description": "App name (may be aliased at the publisher\u2019s request).",
                    "type": "string"
                },
                "bundle": {
                    "description": "A platform-specific application identifier intended to be unique to the app and independent of the exchange. On Android, this should be a bundle or package name (e.g., com.foo.mygame). On iOS, it is typically a numeric ID.",
                    "type": "string"
                },
                "domain": {
                    "description": "Domain of the app (e.g., 'mygame.foo.com').",
                    "type": "string"
                },
                "storeurl": {
                    "description": "App store URL for an installed app; for IQG 2.1 compliance.",
                    "type": "string"
                },
                "ver": {
                    "description": "Application version.",
                    "type": "string"
                },
                "privacypolicy": {
                    "description": "Indicates if the app has a privacy policy, where 0 = no, 1 = yes.",
                    "type": "integer"
                },
                "paid": {
                    "description": "0 = app is free, 1 = the app is a paid version.",
                    "type": "integer"
                },
                "keywords": {
                    "description": "Comma separated list of keywords about the app.",
                    "type": "string"
                }
            }
        },
        "device": {
            "type": "object",
            "description": "3.2.18 Object: Device. This object provides information pertaining to the device through which the user is interacting. Device information includes its hardware, platform, location, and carrier data. The device can refer to a mobile handset, a desktop computer, set top box, or other digital device.",
            "properties": {
                "ua": {
                    "description": "Browser user agent string.",
                    "type": "string"
                },
                "geo": {
                    "type": "object",
                    "description": "This object encapsulates various methods for specifying a geographic location. When subordinate to a Device object, it indicates the location of the device which can also be interpreted as the user\u2019s current location. The lat/lon attributes should only be passed if they conform to the accuracy depicted in the type attribute. For example, the centroid of a geographic region such as postal code should not be passed.",
                    "properties": {
                        "lat": {
                            "description": "Latitude from -90.0 to +90.0, where negative is south.",
                            "type": "number"
                        },
                        "lon": {
                            "description": "Longitude from -180.0 to +180.0, where negative is west.",
                            "type": "number"
                        },
                        "type": {
                            "description": "Source of location data; recommended when passing lat/lon. Refer to List 5.20.",
                            "type": "integer"
                        },
                        "accuracy": {
                            "description": "Estimated location accuracy in meters; recommended when lat/lon are specified and derived from a device\u2019s location services (i.e., type = 1). Note that this is the accuracy as reported from the device. Consult OS specific documentation (e.g., Android, iOS) for exact interpretation.",
                            "type": "integer"
                        },
                        "lastfix": {
                            "description": "Number of seconds since this geolocation fix was established. Note that devices may cache location data across multiple fetches. Ideally, this value should be from the time the actual fix was taken.",
                            "type": "integer"
                        },
                        "ipservice": {
                            "description": "Service or provider used to determine geolocation from IP address if applicable (i.e., type = 2). Refer to List 5.23.",
                            "type": "integer"
                        },
                        "country": {
                            "description": "Country code using ISO-3166-1-alpha-3.",
                            "type": "string"
                        },
                        "region": {
                            "description": "Region code using ISO-3166-2; 2-letter state code if USA.",
                            "type": "string"
                        },
                        "metro": {
                            "description": "Google metro code; similar to but not exactly Nielsen DMAs. See Appendix A for a link to the codes.",
                            "type": "string"
                        },
                        "city": {
                            "description": "City using United Nations Code for Trade & Transport Locations. See Appendix A for a link to the codes.",
                            "type": "string"
                        },
                        "zip": {
                            "description": "Zip or postal code.",
                            "type": "string"
                        },
                        "utcoffset": {
                            "description": "Local time as the number +/- of minutes from UTC.",
                            "type": "string"
                        }
                    }
                },
                "dnt": {
                    "description": "Standard \u201cDo Not Track\u201d flag as set in the header by the browser, where 0 = tracking is unrestricted, 1 = do not track.",
                    "type": "integer"
                },
                "lmt": {
                    "description": "'Limit Ad Tracking' signal commercially endorsed (e.g., iOS, Android), where 0 = tracking is unrestricted, 1 = tracking must be limited per commercial guidelines.",
                    "type": "integer"
                },
                "ip": {
                    "description": "IPv4 address closest to device.",
                    "type": "string"
                },
                "ipv6": {
                    "description": "IPv6 address closest to device.",
                    "type": "string"
                },
                "devicetype": {
                    "description": "The general type of device. Refer to List 5.21.",
                    "type": "integer"
                },
                "make": {
                    "description": "Device make (e.g., 'Apple').",
                    "type": "string"
                },
                "model": {
                    "description": "Device model (e.g., 'iPhone')",
                    "type": "string"
                },
                "os": {
                    "description": "Device operating system (e.g., 'iOS').",
                    "type": "string"
                },
                "osv": {
                    "description": "Device operating system version (e.g., '3.1.2').",
                    "type": "string"
                },
                "hwv": {
                    "description": "Hardware version of the device (e.g., '5S' for iPhone 5S).",
                    "type": "string"
                },
                "h": {
                    "description": "Physical height of the screen in pixels.",
                    "type": "integer"
                },
                "w": {
                    "description": "Physical width of the screen in pixels.",
                    "type": "integer"
                },
                "ppi": {
                    "description": "Screen size as pixels per linear inch.",
                    "type": "integer"
                },
                "pxratio": {
                    "description": "The ratio of physical pixels to device independent pixels.",
                    "type": "number"
                },
                "js": {
                    "description": "Support for JavaScript, where 0 = no, 1 = yes.",
                    "type": "integer"
                },
                "geofetch": {
                    "description": "Indicates if the geolocation API will be available to JavaScript code running in the banner, where 0 = no, 1 = yes.",
                    "type": "integer"
                },
                "language": {
                    "description": "Browser language using ISO-639-1-alpha-2.",
                    "type": "string"
                },
                "carrier": {
                    "description": "Carrier or ISP (e.g., 'VERIZON') using exchange curated string names which should be published to bidders a priori.",
                    "type": "string"
                },
                "mccmnc": {
                    "description": "Mobile carrier as the concatenated MCC-MNC code (e.g., '310-005' identifies Verizon Wireless CDMA in the USA). Refer to https://en.wikipedia.org/wiki/Mobile_country_code for further examples. Note that the dash between the MCC and MNC parts is required to remove parsing ambiguity.",
                    "type": "string"
                },
                "connectiontype": {
                    "description": "Network connection type. Refer to List 5.22.",
                    "type": "integer"
                },
                "ifa": {
                    "description": "ID sanctioned for advertiser use in the clear (i.e., not hashed).",
                    "type": "string"
                },
                "didsha1": {
                    "description": "Hardware device ID (e.g., IMEI); hashed via SHA1.",
                    "type": "string"
                },
                "didmd5": {
                    "description": "Hardware device ID (e.g., IMEI); hashed via MD5.",
                    "type": "string"
                },
                "dpidsha1": {
                    "description": "Platform device ID (e.g., Android ID); hashed via SHA1.",
                    "type": "string"
                },
                "dpidmd5": {
                    "description": "Platform device ID (e.g., Android ID); hashed via MD5.",
                    "type": "string"
                },
                "macsha1": {
                    "description": "MAC address of the device; hashed via SHA1.",
                    "type": "string"
                },
                "macmd5": {
                    "description": "MAC address of the device; hashed via MD5.",
                    "type": "string"
                }
            }
        },
        "user": {
            "type": "object",
            "properties": {
                "id": {
                    "description": "Exchange-specific ID for the user.",
                    "type": "string"
                },
                "buyeruid": {
                    "description": "Buyer-specific ID for the user as mapped by the exchange for the buyer.",
                    "type": "string"
                },
                "yob": {
                    "description": "Year of birth as a 4-digit integer.",
                    "type": "integer"
                },
                "gender": {
                    "description": "Gender, where M=male, F=female, O=known to be other, omitted is unknown",
                    "type": "string"
                }
            }
        },
        "ad_units": {
            "type": "array",
            "minItems": 1,
            "items": {
                "type": "object",
                "required": [
                    "sizes",
                    "code"
                ],
                "oneOf": [
                    {
                        "required": [
                            "bids"
                        ]
                    },
                    {
                        "required": [
                            "config_id"
                        ]
                    }
                ],
                "properties": {
                    "code": {
                        "description": "Unique code of the ad unit on the page",
                        "type": "string"
                    },
                    "sizes": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "h": {
                                    "description": "Height of the ad unit",
                                    "type": "integer"
                                },
                                "w": {
                                    "description": "Width of the ad unit",
                                    "type": "integer"
                                }
                            }
                        }
                    },
                    "media_types": {
                        "type": "array",
                        "description": "Media types accepted by this ad unit",
                        "items": {
                            "type": "string",
                            "enum": [
                                "banner",
                                "video"
                            ]
                        }
                    },
                    "video": {
                        "type": "object",
                        "description": "Video attributes of this ad Unit",
                        "properties": {
                            "mimes": {
                                "type": "array",
                                "description": "Mime types as defined by ORTB - ex: video/mp4",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "minduration": {
                                "type": "integer",
                                "description": "Minimum video ad duration in seconds."
                            },
                            "maxduration": {
                                "type": "integer",
                                "description": "Maximum video ad duration in seconds."
                            },
                            "startdelay": {
                                "type": "integer",
                                "description": "Indicates the start delay in seconds for pre-roll, mid-roll, or post-roll ad placements."
                            },
                            "skippable": {
                                "type": "integer",
                                "description": "Indicates if the player will allow the video to be skipped ( 0 = no, 1 = yes)."
                            },
                            "playback_method": {
                                "type": "integer",
                                "description": "Playback method code as defined by ORTB."
                            },
                            "protocols": {
                                "type": "integer",
                                "description": "protocols as specified in ORTB 2.5 spec: 5.8"
                            }
                        }
                    },
                    "bids": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                            "type": "object",
                            "required": [
                                "bidder",
                                "bid_id"
                            ],
                            "properties": {
                                "bid_id": {
                                    "description": "Unique bid id for this bidder for this slot - for analytics",
                                    "type": "string"
                                },
                                "bidder": {
                                    "description": "Unique code for an adapter to call",
                                    "type": "string"
                                },
                                "params": {
                                    "description": "Optional params to send to the adapter",
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "config_id": {
                        "description": "The config to load for this ad unit",
                        "type": "string"
                    },
                    "slot_code": {
                        "description": "The slot code used by DFP",
                        "type": "string"
                    },
                    "topframe": {
                        "description": "Whether this ad will render in the top IFRAME",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1
                    },
                    "instl": {
                        "description": "1 = the ad is interstitial or full screen, 0 = not interstitial",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 1
                    }
                }
            }
        }
    }
}