# Create download task

Make an [`sdfdownloadtasks.create`](https://developers.google.com/display-video/api/sdf-upload/rest/v4/sdfdownloadtasks/create) request to create a
download task that generates [Structured Data Files (SDFs)](https://developers.google.com/display-video/api/structured-data-file/format).

Define your SDFs using the following fields of your request:

- [`partnerId`](https://developers.google.com/display-video/api/sdf-upload/rest/v4/sdfdownloadtasks/create#body.request_body.FIELDS.partner_id) or [`advertiserId`](https://developers.google.com/display-video/api/sdf-upload/rest/v4/sdfdownloadtasks/create#body.request_body.FIELDS.advertiser_id): Mutually-exclusive fields that define a parent resource (either a partner or advertiser) for the resources populating the SDFs.
- [`version`](https://developers.google.com/display-video/api/sdf-upload/rest/v4/sdfdownloadtasks/create#body.request_body.FIELDS.version): The SDF version to use, if different from the default set at the partner or advertiser level.
- [`parentEntityFilter`](https://developers.google.com/display-video/api/sdf-upload/rest/v4/sdfdownloadtasks/create#body.request_body.FIELDS.parent_entity_filter), [`idFilter`](https://developers.google.com/display-video/api/sdf-upload/rest/v4/sdfdownloadtasks/create#body.request_body.FIELDS.id_filter) or [`inventorySourceFilter`](https://developers.google.com/display-video/api/sdf-upload/rest/v4/sdfdownloadtasks/create#body.request_body.FIELDS.inventory_source_filter): Mutually-exclusive fields that assign the filter used to specify the file types and resources to include.

Use this code snippet to create a download task for Insertion Order and Line
Item Structured Data Files under the given advertiser and within the scope of
provided campaign IDs:

> [!WARNING]
> **Warning:** A single user is limited to twenty `sdfdownloadtask` operations running at any one time. Attempts to create more will return an error.

```
# Provide the ID of the parent advertiser of the resources to retrieve.
advertiser_id = advertiser-id

# Provide the Structured Data Files version to download.
sdf_version = sdf-version

# Provide the IDs of the parent campaigns of the resources to retrieve.
campaign_ids = [campaign-id, ...]

# Create the request body.
body = {
  'version': sdf_version,
  'advertiserId': advertiser_id,
  'parentEntityFilter': {
    'fileType': ["FILE_TYPE_INSERTION_ORDER","FILE_TYPE_LINE_ITEM"],
    'filterType': "FILTER_TYPE_CAMPAIGN_ID",
    'filterIds': campaign_ids
  }
}

# Create the operation.
operation = service.sdfdownloadtasks().create(body=body).execute()

# Print resulting operation name.
print(f'Operation {operation["name"]} was created.')
```