# API to Create Reports for Structured Datasource

***

## 1. Authentication

#### Obtain '`x-access-token'`

Authenticate with the system to obtain an `x-access-token`. This token must be included in all client requests for server validation.

It can be obtained from this end-point.

### Request URL

| Method | URL                                                |
| ------ | -------------------------------------------------- |
| `POST` | `auth/realms/master/protocol/openid-connect/token` |

### Headers

| Key            | Values                              |
| -------------- | ----------------------------------- |
| `Content-Type` | `application/x-www-form-urlencoded` |

### Body (each key value in '`x-www-form-urlencoded`' form)

| Key          | Values       |
| ------------ | ------------ |
| `grant_type` | `password`   |
| `client_id`  | `admin-cli`  |
| `username`   | `<username>` |
| `password`   | `<password>` |

***

## 2. Get Datasource ID

### Request URL

| Method | URL               |
| ------ | ----------------- |
| `GET`  | `api/datasources` |

### Headers

| Key              | Values   |
| ---------------- | -------- |
| `x-access-token` | `string` |

\
This will fetch a list of all available data sources in the system. Copy the ID of the datasource for which the report is to be fetched.

## 3. Create new reports

### Request URL

| Method | URL            |
| ------ | -------------- |
| `POST` | `/api/reports` |

### Headers

| Key              | Values   |
| ---------------- | -------- |
| `x-access-token` | `string` |

### Request

| Key                     | Values                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `reportFormat`          | <p><code>enum \[CSV, JSON]</code></p><p><br></p><p><code>CSV -> Generate Report in CSV format</code></p><p><br></p><p><code>JSON -> Generate Report in JSON format</code> </p>                                                                                                                                                                                                                                                                                            |
| `reportType`            | <p><code>enum \[TABLE\_LIST, FILE\_LIST, ENTITY-LIST, DSR\_REQUEST\_LIST]</code></p><p><br></p><p><code>TABLE\_LIST -> For structured datasource, TABLE\_LIST option is to be used to generate table view reports.</code></p><p><br></p><p><code>FILE LIST -> To generate file view report.</code></p><p><br></p><p><code>ENTITY-LIST -> To generate entity view reports.</code></p><p><br></p><p><code>DSR\_REQUEST\_LIST -> To generate a DSR ticket report.</code></p> |
| `parameters`            | <p><code>list\[objects]</code></p><p><br></p><p><code>\[{</code></p><p>    <code>“key”: \<string>,</code></p><p>    <code>“value”: \<string></code></p><p><code>},...]</code></p><p><br></p><p><code>Individual objects (Parameters -> objects) are defined below.</code></p>                                                                                                                                                                                             |
| `Parameters -> objects` | <p><br></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `key`                   | <p><code>enum \[DATASOURCE\_ID, CURSOR]</code></p><p><br></p><p><code>DATASOURCE\_ID -> ID of the structured data source whose report needs to be generated.</code></p><p><br></p><p><code>CURSOR -> This is internal field used to pagination, since only full report generation is supported you need to pass this as empty (i.e “”)</code></p>                                                                                                                         |
| `values`                | `string`                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

### Sample Request Body

```
{
  "reportFormat": "CSV",
  "reportType": "TABLE_LIST",
  "parameters": [
    {
      "key": "DATASOURCE_ID",
      "values": "640594b9b09f97ee2e49adeb"
    },
    {
      "key": "CURSOR",
      "values": ""
    }
  ]
}


```

### Sample Response Body

```csv
Instance Name,Database Name,Table Name,Schema,Column Name,Attribute Type,Attribute Instance Count,Attribute Sensitivity,Maybe Sensitive - Yes/No,Maybe PII Reason,Data Type,Review Status,Datasource Name
35.192.10.4:3306,lightbeam,basic_info,default,address,address,Count unavailable since Table cluster is not created,medium,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,lightbeam,basic_info,default,email,EMAIL_ADDRESS,Count unavailable since Table cluster is not created,medium,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,lightbeam,basic_info,default,gender,GENDER,Count unavailable since Table cluster is not created,low,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,arpit_test_db,credit_card_2_2_1,default,Borrower1SSN,US_SSN,Count unavailable since Table cluster is not created,high,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,arpit_test_db,credit_card_2_2_1,default,BorrowerSSN,US_SSN,Count unavailable since Table cluster is not created,high,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,arpit_test_db,credit_card_2_2_1,default,TIN,US_ITIN,Count unavailable since Table cluster is not created,high,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,lightbeam,email,default,email,EMAIL_ADDRESS,Count unavailable since Table cluster is not created,medium,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,lightbeam,entities,default,ssn,US_SSN,100000,high,No,N/A,varchar,Reviewed,mysql
```

### Include Row Count in Report for SQL datasources&#x20;

For SQL datasources we can include Non Null Row Count for a specific column in TABLE\_LIST report.

While Upgrade change structDataIncludeNonNullRowCounts value to true to include Row Count columns in report.

{% code expandable="true" %}

```yaml
structDataIncludeNonNullRowCounts:
  enabled: true
```

{% endcode %}

After enabling this flag report should have Row Count and Row Count Fetch Time columns.

#### Sample Response (Including Row Count)

The report output now includes an new column named Row Count , which represents the total number of non null rows returned for the column in the result set.

<pre class="language-csv"><code class="lang-csv">Instance Name,Database Name,Table Name,Schema,Column Name,<a data-footnote-ref href="#user-content-fn-1">Row Count,Row Count Fetch Time</a>,Attribute Type,Attribute Instance Count,Attribute Sensitivity,Maybe Sensitive - Yes/No,Maybe PII Reason,Data Type,Review Status,Datasource Name
35.192.10.4:3306,lightbeam,basic_info,default,address,5000,2026-01-14 10:52:25 UTC,address,Count unavailable since Table cluster is not created,medium,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,lightbeam,basic_info,default,email,5000,2026-01-14 10:52:25 UTC,EMAIL_ADDRESS,Count unavailable since Table cluster is not created,medium,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,lightbeam,basic_info,default,gender,5000,2026-01-14 10:52:25 UTC,GENDER,Count unavailable since Table cluster is not created,low,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,arpit_test_db,credit_card_2_2_1,default,Borrower1SSN,16,2026-01-14 10:52:25 UTC,US_SSN,Count unavailable since Table cluster is not created,high,No,N/A,text,Unreviewed,mysql
35.192.10.4:3306,arpit_test_db,credit_card_2_2_1,default,BorrowerSSN,16,2026-01-14 10:52:25 UTC,US_SSN,Count unavailable since Table cluster is not created,high,No,N/A,text,Unreviewed,mysql
</code></pre>

### Response Codes

<table><thead><tr><th>Status</th><th>Response</th><th>Description</th><th data-hidden>Description</th></tr></thead><tbody><tr><td><code>200</code></td><td><code>File will be downloaded.</code></td><td>Indicates a successful operation.</td><td><code>File will be downloaded — indicates successful operation.</code></td></tr><tr><td><code>422</code></td><td><code>{"error":"Validation error."}</code></td><td>A validation error occurred.</td><td><br></td></tr><tr><td><code>401</code></td><td><code>{"error":"Unauthorized."}</code></td><td>The user is not authorized.</td><td></td></tr><tr><td><code>500</code></td><td><code>{"error":"Something went wrong. Please try again later."}</code></td><td>A server-side error occurred.</td><td></td></tr></tbody></table>

***

## Postman Collection

{% file src="/files/qw4wQgJtw8GNz8k8RFRf" %}
Postman collection for Lightbeam APIs
{% endfile %}

{% file src="/files/eftn3BsmBDApNH2JQVIR" %}
Postman Environment for Lightbeam APIs
{% endfile %}

***

## About LightBeam

LightBeam automates Privacy, Security, and AI Governance, so businesses can accelerate their growth in new markets. Leveraging generative AI, LightBeam has rapidly gained customers’ trust by pioneering a unique *privacy-centric* and *automation-first* approach to security. Unlike siloed solutions, LightBeam ties together sensitive data cataloging, control, and compliance across structured and unstructured data applications providing 360-visibility, redaction, self-service DSRs, and automated ROPA reporting ensuring ultimate protection against ransomware and accidental exposures while meeting data privacy obligations efficiently. \
\
LightBeam is on a mission to create a secure privacy-first world helping customers automate compliance against a patchwork of existing and emerging regulations.

For any questions or suggestions, please get in touch with us at: <support@lightbeam.ai>.

[^1]: Here row count and Row count fetch time are new columns


---

# Agent Instructions: 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:

```
GET https://docs.lightbeam.ai/lxqobxw6ak7CTnsQjikH/tools-and-resources/api-documentation/api-to-create-reports-for-structured-datasource.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
