An [`sdfdownloadtasks.create`](https://developers.google.com/display-video/api/reference/rest/current/sdfdownloadtasks/create) request creates a
long-running operation. This operation generates the [Structured Data Files
(SDFs)](https://developers.google.com/display-video/api/structured-data-file/format).

Request fields define your SDFs:

- [`partnerId`](https://developers.google.com/display-video/api/reference/rest/current/sdfdownloadtasks/create#body.request_body.FIELDS.partner_id) or [`advertiserId`](https://developers.google.com/display-video/api/reference/rest/current/sdfdownloadtasks/create#body.request_body.FIELDS.advertiser_id): Limits the content of the SDFs to the context of the given partner or advertiser. Only one of the fields can be set.
- [`version`](https://developers.google.com/display-video/api/reference/rest/current/sdfdownloadtasks/create#body.request_body.FIELDS.version): Defines the SDF version to use. Defaults to the partner or advertiser setting if not set.
- [`parentEntityFilter`](https://developers.google.com/display-video/api/reference/rest/current/sdfdownloadtasks/create#body.request_body.FIELDS.parent_entity_filter), [`idFilter`](https://developers.google.com/display-video/api/reference/rest/current/sdfdownloadtasks/create#body.request_body.FIELDS.id_filter) or [`inventorySourceFilter`](https://developers.google.com/display-video/api/reference/rest/current/sdfdownloadtasks/create#body.request_body.FIELDS.inventory_source_filter): Defines the content of the SDFs. Only one of the fields can be set.

Here's how to create a download task generating Insertion Order and Line Item
SDFs for given campaigns:

> [!WARNING]
> **Warning:** A user can only run twenty download tasks at once. Attempts to create more will return an error.

### Java

```java
// Provide the ID of the parent advertiser of the resources to retrieve.
long advertiserId = advertiser-id;

// Provide the Structured Data Files version to download.
String sdfVersion = sdf-version;

// Provide the IDs of the parent campaigns of the resources to retrieve.
List<Long> campaignIds = campaign-ids;

// Create the filter structure.
ParentEntityFilter parentEntityFilter =
    new ParentEntityFilter()
        .setFileType(Arrays.asList("FILE_TYPE_INSERTION_ORDER", "FILE_TYPE_LINE_ITEM"))
        .setFilterType("FILTER_TYPE_CAMPAIGN_ID")
        .setFilterIds(campaignIds);

// Configure and create the SDF download task.
Operation operation =
    service
        .sdfdownloadtasks()
        .create(
            new CreateSdfDownloadTaskRequest()
                .setVersion(sdfVersion)
                .setAdvertiserId(advertiserId)
                .setParentEntityFilter(parentEntityFilter))
        .execute();

// Print the resulting operation name.
System.out.printf("Operation %s was created.", operation.getName());
```

### Python

```python
# 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-ids

# 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.')
```

### PHP

```php
// Provide the ID of the parent advertiser of the resources to retrieve.
$advertiserId = advertiser-id;

// Provide the Structured Data Files version to download.
$sdfVersion = sdf-version;

// Provide the IDs of the parent campaigns of the resources to retrieve.
$campaignIds = campaign-ids;

// Create the filter structure.
$filter = new Google_Service_DisplayVideo_ParentEntityFilter();
$filter->setFileType(array('FILE_TYPE_INSERTION_ORDER','FILE_TYPE_LINE_ITEM'));
$filter->setFilterType('FILTER_TYPE_CAMPAIGN_ID');
$filter->setFilterIds($campaignIds);

// Configure and create the SDF download task.
$createDownloadRequest = new Google_Service_DisplayVideo_CreateSdfDownloadTaskRequest();
$createDownloadRequest->setVersion($sdfVersion);
$createDownloadRequest->setAdvertiserId($advertiserId);
$createDownloadRequest->setParentEntityFilter($filter);

// Call the API, creating the SDF Download Task.
$operation = $this->service->sdfdownloadtasks->create(
    $createDownloadRequest
);

// Print the resulting operation name.
printf('<p>Operation %s was created.</p>', $operation['name']);
```