Retrieve and Download Privacy Reports
Once data collection, curation, and approval processes are complete, the Privacy Portal compiles all discovered personal data records into a secure report file. For Access requests, privacy professionals need to retrieve these reports programmatically to securely distribute them to customers or archive them for auditing.
In this tutorial, you will learn how to programmatically check if a report is ready and download the completed privacy report using the Admin API.
1. Verifying Request Completion
Section titled “1. Verifying Request Completion”You must verify that a request’s processingStage is COMPLETE or APPROVED before attempting to download the report file. If you query the report file endpoint for an active or open request that is still in the verification or collection phases, the server will return an error.
To check request status, use the Retrieve and Filter Privacy Requests endpoint to inspect the processingStage field:
{ "id": "req_841203", "status": "APPROVED", "processingStage": "COMPLETE"}2. Retrieving the Report File
Section titled “2. Retrieving the Report File”To download the compiled personal data report, execute a GET request against the report file endpoint.
HTTP Endpoint
Section titled “HTTP Endpoint”GET /api/prm/{tenant}/requests/{requestId}/report/filePath Parameters
Section titled “Path Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
tenant | String | Yes | Your organization’s tenant slug. |
requestId | String | Yes | The ID of the completed request (e.g., req_841203). |
Request Headers
Section titled “Request Headers”Include your programmatically generated key in the X-API-Key header (refer to the Authentication Guide on how to obtain this key):
X-API-Key: <YOUR_API_KEY>Accept: application/octet-stream3. Code Examples
Section titled “3. Code Examples”Select your preferred language to see how to download and stream compiled report zip files programmatically:
import requests
url = "https://bigidprivacy.cloud/api/prm/my-tenant/requests/req_841203/report/file"headers = { "X-API-Key": "YOUR_API_KEY", "Accept": "application/octet-stream"}
print("Retrieving report for request req_841203...")response = requests.get(url, headers=headers, stream=True)
if response.status_code == 200: with open("user_results_bundle.zip", "wb") as f: for chunk in response.iter_content(chunk_size=8192): f.write(chunk) print("Report downloaded successfully and saved as user_results_bundle.zip")elif response.status_code == 403: print("Error: Request is not in a completed stage. Report is not ready.")else: print(f"Failed to download report. HTTP Status: {response.status_code}")const fs = require('fs');const { Readable } = require('stream');
const url = 'https://bigidprivacy.cloud/api/prm/my-tenant/requests/req_841203/report/file';const headers = { 'X-API-Key': 'YOUR_API_KEY', 'Accept': 'application/octet-stream'};
async function downloadPrivacyReport(outputPath) { try { console.log('Retrieving report for request req_841203...'); const response = await fetch(url, { headers });
if (!response.ok) { if (response.status === 403) { console.error('Error: Request is not in a completed stage. Report is not ready.'); } else { console.error(`Failed to download report. HTTP Status: ${response.status}`); } return; }
const fileStream = fs.createWriteStream(outputPath); const nodeStream = Readable.fromWeb(response.body); nodeStream.pipe(fileStream);
fileStream.on('finish', () => { console.log(`Report downloaded successfully and saved to: ${outputPath}`); }); } catch (error) { console.error('Failed to download report:', error); }}
downloadPrivacyReport('user_results_bundle.zip');Handling Common Errors
Section titled “Handling Common Errors”If you attempt to retrieve the report of a request that has not been approved or is still active, the server will block the download.
Response (403 Forbidden):
{ "message": "The privacy report for request req_841203 is not compiled yet.", "status": 403}Response (404 Not Found):
If no files or reports were compiled for this request:
{ "message": "Report file not found for request req_841203", "status": 404}All rights reserved.