> For the complete documentation index, see [llms.txt](https://manual.blocworx.com/blocworx-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.blocworx.com/blocworx-api/reference/api-reference/getting-reports.md).

# Getting Reports

### Getting Report Data from a Bloc

{% hint style="warning" %}
**Please note:** All [Bloc Data User Restrictions](https://manual.blocworx.com/blocworx-documentation/bloc-editor/bloc-settings/data-restriction-settings) will apply in these requests. If you are not getting data back or cannot access the bloc, please ensure the user associated with the Auth token has access to the bloc and is not restricted.
{% endhint %}

### Get Report Data

<mark style="color:blue;">`GET`</mark> `https://example.mydomain.com/api/get-data-report`

> ⚠️ This endpoint expects a JSON request body even though it uses the GET method.

This endpoint can return:

* JSON report data
* an Excel `.xlsx` file export

***

### Request Body

<table><thead><tr><th width="185.78515625">Name</th><th width="84.23828125">Type</th><th>Description</th></tr></thead><tbody><tr><td>stationID<mark style="color:red;">*</mark></td><td>string</td><td>The bloc ID. This may be a UUID or numeric ID depending on your instance.</td></tr><tr><td>fieldsToReport<mark style="color:red;">*</mark></td><td>string</td><td>Either <code>"all"</code> or a JSON-encoded string of field slugs to include, for example <code>"{\"field_1\":true,\"field_2\":true}"</code></td></tr><tr><td>responseType</td><td>string</td><td>If set to <code>"blob"</code>, returns an Excel <code>.xlsx</code> file instead of JSON</td></tr><tr><td>requestedReportData</td><td>string</td><td><p>JSON-encoded string containing report date options, </p><p>for example</p><p> <code>"{\"reportFromDate\":\"2026-03-19 00:00:00\",\"reportToDate\":\"2026-03-19 23:59:59\"}"</code></p></td></tr><tr><td>dataFilteringData</td><td>string</td><td><p>JSON-encoded string containing filter options</p><p>for example </p><p><code>"{\"stationID\":\"...\",\"filterDataToQuery\":{\"field_1\":[\"Value\"]},\"currentPage\":1,\"reverse\":false}"</code></p></td></tr></tbody></table>

***

### JSON Response Example

```json
{
  "data": [
    {
      "created_at": "2026-03-19 13:41:06",
      "user_id": "exampleuser",
      "field_number_1": "10",
      "field_number_2": "12",
      "radio_name": "4",
      "my_dropdown_from_my_bloc": "4",
      "my_results_box": "Results Box Data",
      "time_stamp": "13:41:06",
      "date_stamp": "2026-03-19"
    }
  ]
}
```

***

### Response Notes

* Response data is a **flat array**
* Default ordering is **oldest first**
* When `fieldsToReport` is `"all"`, derived fields may be included:
  * `time_stamp`
  * `date_stamp`
* When `fieldsToReport` specifies selected fields, only those fields are returned

***

### Excel Response

When `responseType` is set to `"blob"`, the endpoint returns an Excel `.xlsx` file.

Example content type:

```
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
```

> Note: the current implementation may not return a `Content-Disposition` filename header, so some clients may need to save the file manually.

***

### Error Responses

#### 401 Unauthorized

```json
{
  "error": "You are not authorized to access this bloc"
}
```

#### 400 Bad Request

```json
{
  "error": "Error message"
}
```

> Depending on the error, additional debug fields may also be returned by the current implementation.

***

### Example Requests

#### Get all report data as JSON

```bash
curl --request GET 'https://example.mydomain.com/api/get-data-report' \
  --header 'Authorization: Bearer [AUTHTOKEN]' \
  --header 'Content-Type: application/json' \
  --data '{
    "stationID": "a1489634-4009-4cc0-8a65-9965f5a1bea7",
    "fieldsToReport": "all"
  }'
```

#### Get selected fields only

```bash
curl --request GET 'https://example.mydomain.com/api/get-data-report' \
  --header 'Authorization: Bearer [AUTHTOKEN]' \
  --header 'Content-Type: application/json' \
  --data '{
    "stationID": "a1489634-4009-4cc0-8a65-9965f5a1bea7",
    "fieldsToReport": "{\"field_number_1\":true,\"radio_name\":true}"
  }'
```

#### Filter by report date range

```bash
curl --request GET 'https://example.mydomain.com/api/get-data-report' \
  --header 'Authorization: Bearer [AUTHTOKEN]' \
  --header 'Content-Type: application/json' \
  --data '{
    "stationID": "a1489634-4009-4cc0-8a65-9965f5a1bea7",
    "fieldsToReport": "all",
    "requestedReportData": "{\"reportFromDate\":\"2026-03-19 00:00:00\",\"reportToDate\":\"2026-03-19 23:59:59\"}"
  }'
```

#### Filter by field values

```bash
curl --request GET 'https://example.mydomain.com/api/get-data-report' \
  --header 'Authorization: Bearer [AUTHTOKEN]' \
  --header 'Content-Type: application/json' \
  --data '{
    "stationID": "a1489634-4009-4cc0-8a65-9965f5a1bea7",
    "fieldsToReport": "all",
    "dataFilteringData": "{\"stationID\":\"a1489634-4009-4cc0-8a65-9965f5a1bea7\",\"filterDataToQuery\":{\"radio_name\":[\"1\"]},\"currentPage\":1,\"reverse\":false}"
  }'
```

#### Download Excel file

```bash
curl --request GET 'https://example.mydomain.com/api/get-data-report' \
  --header 'Authorization: Bearer [AUTHTOKEN]' \
  --header 'Content-Type: application/json' \
  --output report.xlsx \
  --data '{
    "stationID": "a1489634-4009-4cc0-8a65-9965f5a1bea7",
    "fieldsToReport": "all",
    "responseType": "blob"
  }'
```


---

# 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://manual.blocworx.com/blocworx-api/reference/api-reference/getting-reports.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.
