Starting September 8, 2025, every new line item will need to declare whether or not they will serve Eurpoean Union (EU) political ads. Display & Video 360 API and SDF uploads that don't provide declarations will fail. See our deprecations page for more details on how to update your integration to make this declaration.
// Create a line item object.LineItemlineItem=newLineItem();lineItem.setInsertionOrderId(insertion-order-id);lineItem.setDisplayName(display-name);lineItem.setLineItemType("LINE_ITEM_TYPE_DISPLAY_DEFAULT");lineItem.setEntityStatus("ENTITY_STATUS_DRAFT");// Create and set the line item flight.LineItemFlightlineItemFlight=newLineItemFlight();lineItemFlight.setFlightDateType("LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED");lineItem.setFlight(lineItemFlight);// Create and set the line item budget.LineItemBudgetlineItemBudget=newLineItemBudget();lineItemBudget.setBudgetAllocationType("LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED");lineItem.setBudget(lineItemBudget);// Create and set the pacing setting.Pacingpacing=newPacing();pacing.setPacingPeriod("PACING_PERIOD_DAILY");pacing.setPacingType("PACING_TYPE_EVEN");pacing.setDailyMaxMicros(10000L);lineItem.setPacing(pacing);// Create and set the frequency cap.FrequencyCapfrequencyCap=newFrequencyCap();frequencyCap.setTimeUnit("TIME_UNIT_DAYS");frequencyCap.setTimeUnitCount(1);frequencyCap.setMaxImpressions(10);lineItem.setFrequencyCap(frequencyCap);// Create and set the partner revenue model.PartnerRevenueModelpartnerRevenueModel=newPartnerRevenueModel();partnerRevenueModel.setMarkupType("PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM");partnerRevenueModel.setMarkupAmount(10000L);lineItem.setPartnerRevenueModel(partnerRevenueModel);// Set the list of IDs of the creatives associated with the line item.lineItem.setCreativeIds(creative-ids);// Create and set the bidding strategy.BiddingStrategybiddingStrategy=newBiddingStrategy();biddingStrategy.setFixedBid(newFixedBidStrategy().setBidAmountMicros(100000L));lineItem.setBidStrategy(biddingStrategy);// Declare whether or not the line item will serve EU political ads.lineItem.setContainsEuPoliticalAds(eu-political-advertising-status);// Create the line item.LineItemresponse=service.advertisers().lineItems().create(advertiser-id,lineItem).execute();
Python
# Create a line item object.line_item_obj={'insertionOrderId':insertion-order-id,'displayName':display-name,'lineItemType':'LINE_ITEM_TYPE_DISPLAY_DEFAULT','entityStatus':'ENTITY_STATUS_DRAFT','flight':{'flightDateType':'LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED'},'budget':{'budgetAllocationType':'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'},'pacing':{'pacingPeriod':'PACING_PERIOD_DAILY','pacingType':'PACING_TYPE_EVEN','dailyMaxMicros':10000},'frequencyCap':{'timeUnit':'TIME_UNIT_DAYS','timeUnitCount':1,'maxImpressions':10},'partnerRevenueModel':{'markupType':'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM','markupAmount':10000},'creativeIds':creative-ids,'bidStrategy':{'fixedBid':{'bidAmountMicros':100000}},'containsEuPoliticalAds':eu-political-advertising-status}# Create the line item.lineItem=service.advertisers().lineItems().create(advertiserId=advertiser-id,body=line_item_obj).execute()
PHP
// Create a line item object.$lineItem = new Google_Service_DisplayVideo_LineItem();$lineItem->setInsertionOrderId(insertion-order-id);$lineItem->setDisplayName(display-name);$lineItem->setLineItemType('LINE_ITEM_TYPE_DISPLAY_DEFAULT');$lineItem->setEntityStatus('ENTITY_STATUS_DRAFT');// Create and set the line item flight.$flight = new Google_Service_DisplayVideo_LineItemFlight();$flight->setFlightDateType('LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED');$lineItem->setFlight($flight);// Create and set the line item budget.$budget = new Google_Service_DisplayVideo_LineItemBudget();$budget->setBudgetAllocationType( 'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED');$lineItem->setBudget($budget);// Create and set the pacing setting.$pacing = new Google_Service_DisplayVideo_Pacing();$pacing->setPacingPeriod('PACING_PERIOD_DAILY');$pacing->setPacingType('PACING_TYPE_EVEN');$pacing->setDailyMaxMicros(10000);$lineItem->setPacing($pacing);// Create and set the frequency cap.$frequencyCap = new Google_Service_DisplayVideo_FrequencyCap();$frequencyCap->setMaxImpressions(10);$frequencyCap->setTimeUnit('TIME_UNIT_DAYS');$frequencyCap->setTimeUnitCount(1);$lineItem->setFrequencyCap($frequencyCap);// Create and set the partner revenue model.$partnerRevenueModel = new Google_Service_DisplayVideo_PartnerRevenueModel();$partnerRevenueModel->setMarkupType( 'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM');$partnerRevenueModel->setMarkupAmount(10000);$lineItem->setPartnerRevenueModel($partnerRevenueModel);// Set the list of IDs of the creatives associated with the line item.lineItem >setCreativeIds(creative-ids);// Create and set the bidding strategy.$biddingStrategy = new Google_Service_DisplayVideo_BiddingStrategy();$fixedBidStrategy = new Google_Service_DisplayVideo_FixedBidStrategy();$fixedBidStrategy->setBidAmountMicros(100000);$biddingStrategy->setFixedBid($fixedBidStrategy);$lineItem->setBidStrategy($biddingStrategy);// Declare whether or not the line item will serve EU political ads.$lineItem->setContainsEuPoliticalAds(eu-political-advertising-status);// Create the line item.$result = $this->service->advertisers_lineItems->create(advertiser-id, $lineItem);
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[[["\u003cp\u003eAfter setup, send requests to the Display & Video 360 API to manage line items and other resources.\u003c/p\u003e\n"],["\u003cp\u003eCode samples demonstrate how to create and retrieve line items using the API in Java, Python, and PHP.\u003c/p\u003e\n"],["\u003cp\u003eThe reference documentation provides a comprehensive list of available API methods for interacting with Display & Video 360.\u003c/p\u003e\n"]]],["The content details sending requests to the Display & Video 360 API, specifically demonstrating how to create and retrieve a line item. Creating a line item involves defining properties like `insertionOrderId`, `displayName`, `lineItemType`, status, flight details, budget, pacing, frequency cap, partner revenue model, creative IDs, and bidding strategy, then using the create method. Retrieving an item uses the `get` method. Code examples are provided in Java, Python, and PHP.\n"],null,["After you've set everything up, you can send requests to the Display \\& Video 360 API.\n\nThe following code samples demonstrate how to send a few simple requests:\n\n- Create a line item.\n- Retrieve a specific line item.\n\nFor a full list of methods, see the [reference documentation](/display-video/api/reference/rest).\n\nCreate a resource\n\nHere's an example of [create a line item](/display-video/api/reference/rest/current/advertisers.lineItems/create): \n\nJava \n\n```java\n// Create a line item object.\nLineItem lineItem = new LineItem();\nlineItem.setInsertionOrderId(insertion-order-id);\nlineItem.setDisplayName(display-name);\nlineItem.setLineItemType(\"LINE_ITEM_TYPE_DISPLAY_DEFAULT\");\nlineItem.setEntityStatus(\"ENTITY_STATUS_DRAFT\");\n\n// Create and set the line item flight.\nLineItemFlight lineItemFlight = new LineItemFlight();\nlineItemFlight\n .setFlightDateType(\"LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED\");\nlineItem.setFlight(lineItemFlight);\n\n// Create and set the line item budget.\nLineItemBudget lineItemBudget = new LineItemBudget();\nlineItemBudget\n .setBudgetAllocationType(\"LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED\");\nlineItem.setBudget(lineItemBudget);\n\n// Create and set the pacing setting.\nPacing pacing = new Pacing();\npacing.setPacingPeriod(\"PACING_PERIOD_DAILY\");\npacing.setPacingType(\"PACING_TYPE_EVEN\");\npacing.setDailyMaxMicros(10000L);\nlineItem.setPacing(pacing);\n\n// Create and set the frequency cap.\nFrequencyCap frequencyCap = new FrequencyCap();\nfrequencyCap.setTimeUnit(\"TIME_UNIT_DAYS\");\nfrequencyCap.setTimeUnitCount(1);\nfrequencyCap.setMaxImpressions(10);\nlineItem.setFrequencyCap(frequencyCap);\n\n// Create and set the partner revenue model.\nPartnerRevenueModel partnerRevenueModel = new PartnerRevenueModel();\npartnerRevenueModel\n .setMarkupType(\"PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM\");\npartnerRevenueModel.setMarkupAmount(10000L);\nlineItem.setPartnerRevenueModel(partnerRevenueModel);\n\n// Set the list of IDs of the creatives associated with the line item.\nlineItem.setCreativeIds(creative-ids);\n\n// Create and set the bidding strategy.\nBiddingStrategy biddingStrategy = new BiddingStrategy();\nbiddingStrategy\n .setFixedBid(new FixedBidStrategy().setBidAmountMicros(100000L));\nlineItem.setBidStrategy(biddingStrategy);\n\n// Declare whether or not the line item will serve EU political ads.\nlineItem.setContainsEuPoliticalAds(eu-political-advertising-status);\n\n// Create the line item.\nLineItem response =\n service.advertisers().lineItems().create(advertiser-id, lineItem).execute();\n```\n\nPython \n\n```python\n# Create a line item object.\nline_item_obj = {\n 'insertionOrderId' : insertion-order-id,\n 'displayName': display-name,\n 'lineItemType': 'LINE_ITEM_TYPE_DISPLAY_DEFAULT',\n 'entityStatus': 'ENTITY_STATUS_DRAFT',\n 'flight': {\n 'flightDateType': 'LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED'\n },\n 'budget': {\n 'budgetAllocationType': 'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'\n },\n 'pacing': {\n 'pacingPeriod': 'PACING_PERIOD_DAILY',\n 'pacingType': 'PACING_TYPE_EVEN',\n 'dailyMaxMicros': 10000\n },\n 'frequencyCap': {\n 'timeUnit': 'TIME_UNIT_DAYS',\n 'timeUnitCount': 1,\n 'maxImpressions': 10\n },\n 'partnerRevenueModel': {\n 'markupType': 'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM',\n 'markupAmount': 10000\n },\n 'creativeIds': creative-ids,\n 'bidStrategy': {\n 'fixedBid': {\n 'bidAmountMicros': 100000\n }\n },\n 'containsEuPoliticalAds': eu-political-advertising-status\n}\n\n# Create the line item.\nlineItem = service.advertisers().lineItems().create(\n advertiserId=advertiser-id,\n body=line_item_obj\n).execute()\n```\n\nPHP \n\n```php\n// Create a line item object.\n$lineItem = new Google_Service_DisplayVideo_LineItem();\n$lineItem-\u003esetInsertionOrderId(\u003cvar translate=\"no\"\u003einsertion-order-id\u003c/var\u003e);\n$lineItem-\u003esetDisplayName(\u003cvar translate=\"no\"\u003edisplay-name\u003c/var\u003e);\n$lineItem-\u003esetLineItemType('LINE_ITEM_TYPE_DISPLAY_DEFAULT');\n$lineItem-\u003esetEntityStatus('ENTITY_STATUS_DRAFT');\n\n// Create and set the line item flight.\n$flight = new Google_Service_DisplayVideo_LineItemFlight();\n$flight-\u003esetFlightDateType('LINE_ITEM_FLIGHT_DATE_TYPE_INHERITED');\n$lineItem-\u003esetFlight($flight);\n\n// Create and set the line item budget.\n$budget = new Google_Service_DisplayVideo_LineItemBudget();\n$budget-\u003esetBudgetAllocationType(\n 'LINE_ITEM_BUDGET_ALLOCATION_TYPE_FIXED'\n);\n$lineItem-\u003esetBudget($budget);\n\n// Create and set the pacing setting.\n$pacing = new Google_Service_DisplayVideo_Pacing();\n$pacing-\u003esetPacingPeriod('PACING_PERIOD_DAILY');\n$pacing-\u003esetPacingType('PACING_TYPE_EVEN');\n$pacing-\u003esetDailyMaxMicros(10000);\n$lineItem-\u003esetPacing($pacing);\n\n// Create and set the frequency cap.\n$frequencyCap = new Google_Service_DisplayVideo_FrequencyCap();\n$frequencyCap-\u003esetMaxImpressions(10);\n$frequencyCap-\u003esetTimeUnit('TIME_UNIT_DAYS');\n$frequencyCap-\u003esetTimeUnitCount(1);\n$lineItem-\u003esetFrequencyCap($frequencyCap);\n\n// Create and set the partner revenue model.\n$partnerRevenueModel =\n new Google_Service_DisplayVideo_PartnerRevenueModel();\n$partnerRevenueModel-\u003esetMarkupType(\n 'PARTNER_REVENUE_MODEL_MARKUP_TYPE_CPM'\n);\n$partnerRevenueModel-\u003esetMarkupAmount(10000);\n$lineItem-\u003esetPartnerRevenueModel($partnerRevenueModel);\n\n// Set the list of IDs of the creatives associated with the line item.\nlineItem \u003esetCreativeIds(\u003cvar translate=\"no\"\u003ecreative-ids\u003c/var\u003e);\n\n// Create and set the bidding strategy.\n$biddingStrategy = new Google_Service_DisplayVideo_BiddingStrategy();\n$fixedBidStrategy = new Google_Service_DisplayVideo_FixedBidStrategy();\n$fixedBidStrategy-\u003esetBidAmountMicros(100000);\n$biddingStrategy-\u003esetFixedBid($fixedBidStrategy);\n$lineItem-\u003esetBidStrategy($biddingStrategy);\n\n// Declare whether or not the line item will serve EU political ads.\n$lineItem-\u003esetContainsEuPoliticalAds(\u003cvar translate=\"no\"\u003eeu-political-advertising-status\u003c/var\u003e);\n\n// Create the line item.\n$result = $this-\u003eservice-\u003eadvertisers_lineItems-\u003ecreate(\n \u003cvar translate=\"no\"\u003eadvertiser-id\u003c/var\u003e,\n $lineItem\n);\n```\n\nRetrieve a specific resource\n\nHere's an example of [retrieve a specific line item](/display-video/api/reference/rest/current/advertisers.lineItems/get): \n\nJava \n\n```java\n// Get the line item.\nLineItem lineItem =\n service\n .advertisers()\n .lineItems()\n .get(advertiser-id, line-item-id)\n .execute();\n```\n\nPython \n\n```python\n# Get the line item.\nlineItem = service.advertisers().lineItems.get(\n advertiserId=advertiser-id,\n lineItemId=line-item-id\n).execute()\n```\n\nPHP \n\n```php\n// Get the line item.\n$lineItem = $this-\u003eservice-\u003eadvertisers_lineItems-\u003eget(\n \u003cvar translate=\"no\"\u003eadvertiser-id\u003c/var\u003e,\n \u003cvar translate=\"no\"\u003eline-item-id\u003c/var\u003e\n);\n```"]]