> 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.1/design/architecture/low-level-design/services/health-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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
