View Power BI Report
Retrieve embed configuration and access token for viewing a Power BI report.
GET /reports/{groupId}/{reportId}/view
Path Parameters
Power BI workspace/group ID (UUID)
Power BI report ID (UUID)
Authentication
Valid session or Sanctum token
Authorization Behavior
Can view any report in the system
Can only view reports assigned to them. Returns 403 if report not assigned.
Token Management
The endpoint automatically manages Power BI embed tokens:
- Token Exists & Valid: Returns cached token from database
- Token Expired/Missing: Requests new token from Power BI API
- Token Refresh: Updates database with new token and expiration
Response
Complete report object with embed configuration
Power BI embed token (JWT)
Token expiration timestamp
User-level Power BI access token
Array of applied filters for this report
JSON-encoded Power BI filter configuration
Users assigned to this report
User who created the report
Example Request
curl -X GET "https://your-domain.com/reports/f089354e-8366-4e18-aea3-4cb4a3a50b48/5b218778-e7a5-4d73-8187-f10824047715/view" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json"
Example Response (Success)
{
"report": {
"id": 1,
"name": "Sales Dashboard",
"group_id": "f089354e-8366-4e18-aea3-4cb4a3a50b48",
"report_id": "5b218778-e7a5-4d73-8187-f10824047715",
"dataset_id": "cfafbeb1-8037-4d0c-896e-a46fb27ff229",
"access_level": "View",
"token": "H4sIAAAAAAAEAB2RxQ7cMAhE/8XnRsY2YJJbP6Wq9tAqUqQoiVZV1H9vXO1tRjMw8PCMfHwHhZu5MvZKl...",
"expiration_date": "2026-03-04 11:30:00",
"embedUrl": "https://app.powerbi.com/reportEmbed?reportId=5b218778-e7a5-4d73-8187-f10824047715&groupId=f089354e-8366-4e18-aea3-4cb4a3a50b48",
"userAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6...",
"user_id": 1,
"filter_array": "[{\"$schema\":\"http://powerbi.com/product/schema#basic\",\"target\":{\"table\":\"Sales\",\"column\":\"Region\"},\"operator\":\"In\",\"values\":[\"North\"]}]",
"created_at": "2026-01-15 14:30:00",
"updated_at": "2026-03-04 10:25:00",
"filters": [
{
"id": 1,
"name": "Region Filter",
"table": "Sales",
"column": "Region",
"operator": "In",
"values": "North",
"parse_values": ["North"]
}
],
"user": [
{
"id": 2,
"name": "Jane Smith",
"email": "[email protected]"
}
],
"created_by": {
"id": 1,
"name": "John Doe",
"email": "[email protected]"
}
}
}
The embedUrl follows this pattern:
https://app.powerbi.com/reportEmbed?reportId={reportId}&groupId={groupId}
Use this URL with the Power BI JavaScript SDK for embedding.
Using the Embed Token
JavaScript Example
const config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: report.token,
embedUrl: report.embedUrl,
id: report.report_id,
permissions: models.Permissions.Read,
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
// Embed report
const reportContainer = document.getElementById('reportContainer');
const embeddedReport = powerbi.embed(reportContainer, config);
Token Expiration
Power BI embed tokens typically expire after 1 hour. The endpoint:
- Checks if
expiration_date is in the future
- Returns cached token if valid
- Requests new token if expired
- Updates database with new token and expiration
Always check expiration_date before using a cached token. Implement token refresh logic in your frontend.
Applying Filters
Filters from the filter_array field can be applied to the embedded report:
const filters = JSON.parse(report.filter_array);
embeddedReport.setFilters(filters)
.then(() => {
console.log('Filters applied successfully');
})
.catch((error) => {
console.error('Error applying filters:', error);
});
Error Responses
403 Forbidden (Not Assigned)
User does not have access to this report:
Power BI API Error
If token generation fails, redirects to report index with error message:
Redirect to: /reports
Flash message: "Failed to generate embed token: [error details]"
404 Not Found
Report does not exist in database:
{
"message": "Report not found"
}
Implementation Notes
Source: app/Http/Controllers/ReportController.php:57-100
Power BI Integration
Uses the PowerBITrait for:
getUserAccessToken() - Gets user-level Power BI access token
getReportAccessToken() - Gets report embed token
Database Updates
Token and expiration are saved to avoid unnecessary Power BI API calls:
$report->token = $token->token;
$report->expiration_date = $token->expiration;
$report->save();
View Rendering
Returns Inertia response for SPA rendering:
Inertia::render('Report/View', [
'report' => $report,
]);