> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/health/v2.0/design/architecture/low-level-design/services/console-services/project-factory-campaign-manager/manage-data-apis/v1-deprecated-data-apis/download-data-api.md).

# Download Data API

## Endpoint <a href="#endpoint-3" id="endpoint-3"></a>

* **Endpoint**: /data/\_download
* **Method**: POST

## **Request Structure** <a href="#request-structure-3" id="request-structure-3"></a>

* RequestInfo: Object containing request information.
* Type: (Optional) Type of the resource being downloaded.
* TenantId: Tenant identifier.
* HierarchyType: Type of hierarchy.
* Id: (Optional) ID of the resource being downloaded.
* Filters: (Optional) Additional filters for the download request.
* campaignId : campaignId

## **Response Structure** <a href="#response-structure-2" id="response-structure-2"></a>

* ResponseInfo: Object containing response information.
* ResourceDetails: Array containing the details object of the downloaded resource.

## **Flow** <a href="#flow-3" id="flow-3"></a>

1. **Client Request**: The client sends a POST request to download data.
2. **Request Validation**: Upon receiving the request, the server validates the request structure and parameters.
3. **Data Download Process**:
   * **Validation**: Validate the download request.
   * **Fetch Data**: Fetch existing data of the specified type from the data host service.
   * **Processing**: Process the retrieved data as necessary.
4. **Response Creation**: After processing the request, the server creates a response containing the details of the latest resource, ensuring that only one result is fetched.
5. **Response Dispatch**: The server sends the generated response back to the client.
6. **Error Handling**: If errors occur during the process, an error response is generated and sent.

#### Flow Diagram <a href="#flow-diagram-3" id="flow-diagram-3"></a>

<div align="left"><figure><img src="https://docs.digit.org/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FTXGfwWeUzCL8CsU9R0tT%2Fblobs%2F7IuwolE1DKPXsWBcyy1G%2Fimage.png&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=ca63c01a&#x26;sv=2" alt=""><figcaption></figcaption></figure></div>

**Handling Empty or Missing Downloaded Responses**

If the downloaded response is empty or not searched with the provided ID, the system automatically starts regenerating a template of the same type. The generation process is triggered by the backend, not through the UI.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.digit.org/health/v2.0/design/architecture/low-level-design/services/console-services/project-factory-campaign-manager/manage-data-apis/v1-deprecated-data-apis/download-data-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
