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.
Stay organized with collections
Save and categorize content based on your preferences.
You can create and update resources, including YouTube resources,
programmatically and in bulk by uploading Structured Data Files using
the Display & Video 360 API. This page discusses how to prepare and upload a Structured
Data File using the API.
Only thirty Structured Data Files per advertiser ID can be uploaded by a Google
Cloud project in a day.
Prepare a Structured Data File for upload
Uploaded Structured Data Files should be modified versions of recently
downloaded Structured Data Files of the same file type and
from the same advertiser. Prepare the downloaded Structured Data File for upload
by making the following updates:
Add entries for any new resources you want to create.
Update any existing entries for resources you want to update.
Remove any entries that are not new or updated in order to reduce file size,
speed up processing time, and remove the likelihood for any unintentional
updates.
Verify the following before uploading the file:
The file is a CSV file.
All entries in the file are for resources under the same parent advertiser.
Upload a file
Upload a Structured Data File using the
advertisers.sdfuploadtasks.upload method. This request
creates an SDF upload task Operation. This long-running
operation processes the uploaded file, creates and updates resources based on
the file contents, and generates result files that list successful and failed
updates.
Here's how to upload a Structured Data File and retrieve the resulting
Operation:
# Import the object used as the media body for the upload request.fromapiclient.httpimportMediaFileUpload# Provide the parent advertiser ID for the resources in the SDF.# The ID value must be a str and not an int.advertiser_id=advertiser-id# Provide the filename and local path to the media file.sdf_filename=sdf-filenamesdf_path=sdf-path# Create the request body.body={'filename':sdf_filename,'advertiserId':advertiser_id}# Create the upload object and use a default MIME type if not identified.media=MediaFileUpload(sdf_path)ifnotmedia.mimetype():media=MediaFileUpload(sdf_filename,'application/octet-stream')# Upload the structured data file.upload_response=service.advertisers().sdfuploadtasks().upload(advertiserId=advertiser_id,body=body,media_body=media).execute()# Print resulting Operation name.print(f'SDF was successfully uploaded. Operation {upload_response["name"]} was ''created to process the uploaded file.')
[[["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-07-01 UTC."],[],[],null,["You can create and update resources, including YouTube resources,\nprogrammatically and in bulk by uploading [Structured Data Files](/display-video/api/structured-data-file/format) using\nthe Display \\& Video 360 API. This page discusses how to prepare and upload a Structured\nData File using the API.\n\nOnly thirty Structured Data Files per advertiser ID can be uploaded by a Google\nCloud project in a day.\n\nPrepare a Structured Data File for upload\n\nUploaded Structured Data Files should be modified versions of recently\n[downloaded Structured Data Files](/display-video/api/sdf-upload/download-guide/overview) of the same file type and\nfrom the same advertiser. Prepare the downloaded Structured Data File for upload\nby making the following updates:\n\n- Add entries for any new resources you want to create.\n- Update any existing entries for resources you want to update.\n- Remove any entries that are not new or updated in order to reduce file size, speed up processing time, and remove the likelihood for any unintentional updates.\n\n| **Tip:** Use a recently-downloaded SDF when preparing an SDF for upload. Resources that have been modified since the SDF was downloaded may not update successfully on file upload.\n\nVerify the following before uploading the file:\n\n- The file is a `CSV` file.\n- All entries in the file are for resources under the same parent advertiser.\n\nUpload a file\n\nUpload a Structured Data File using the\n[`advertisers.sdfuploadtasks.upload`](/display-video/api/sdf-upload/rest/v4/advertisers.sdfuploadtasks/upload) method. This request\ncreates an SDF upload task [`Operation`](/display-video/api/sdf-upload/rest/v4/sdfuploadtasks.operations#Operation). This long-running\noperation processes the uploaded file, creates and updates resources based on\nthe file contents, and generates result files that list successful and failed\nupdates.\n\nHere's how to upload a Structured Data File and retrieve the resulting\n[`Operation`](/display-video/api/sdf-upload/rest/v4/sdfuploadtasks.operations#Operation):\n**Warning:** The [`advertisers.sdfuploadtasks.upload`](/display-video/api/sdf-upload/rest/v4/advertisers.sdfuploadtasks/upload) method can only be successfully called thirty times per day per advertiser by a Google Cloud project in a day. The day is defined by the advertiser's timezone. If a request to the method fails, it does not count against your quota. \n\n```python\n# Import the object used as the media body for the upload request.\nfrom apiclient.http import MediaFileUpload\n\n# Provide the parent advertiser ID for the resources in the SDF.\n# The ID value must be a str and not an int.\nadvertiser_id = advertiser-id\n\n# Provide the filename and local path to the media file.\nsdf_filename = sdf-filename\nsdf_path = sdf-path\n\n# Create the request body.\nbody = {\n 'filename': sdf_filename,\n 'advertiserId': advertiser_id\n}\n\n# Create the upload object and use a default MIME type if not identified.\nmedia = MediaFileUpload(sdf_path)\nif not media.mimetype():\n media = MediaFileUpload(sdf_filename,'application/octet-stream')\n\n# Upload the structured data file.\nupload_response = service.advertisers().sdfuploadtasks().upload(\n advertiserId=advertiser_id,\n body=body,\n media_body=media\n).execute()\n\n# Print resulting Operation name.\nprint(f'SDF was successfully uploaded. Operation {upload_response[\"name\"]} was '\n 'created to process the uploaded file.')\n```"]]