/powerbi-master:rest-api-automationfrom powerbi-master
Automates Power BI REST API operations including authentication, embed-token generation, dataset refresh, admin APIs, and export-to-file. Provides OAuth/MSAL token recipes, PowerShell automation scripts, and JavaScript SDK examples.
Ships in powerbi-master. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The Power BI REST API provides programmatic access for embedding, administration, dataset management, and automation. The base URL is https://api.powerbi.com/v1.0/myorg/ for user context or https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/ for workspace context.
Get access token:
curl -X POST "https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id={clientId}&client_secret={secret}&scope=https://analysis.windows.net/powerbi/api/.default"
PowerShell:
$body = @{
grant_type = "client_credentials"
client_id = $clientId
client_secret = $clientSecret
scope = "https://analysis.windows.net/powerbi/api/.default"
}
$token = (Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" `
-Method Post -Body $body).access_token
Uses a real user account with username/password grant. Requires Pro/PPU license. Subject to MFA and Conditional Access issues. Avoid for production.
| Group | Base Path | Purpose |
|---|---|---|
| Datasets | /datasets | Manage semantic models, refresh, parameters |
| Reports | /reports | Get, clone, export, rebind reports |
| Dashboards | /dashboards | Get dashboards and tiles |
| Groups (Workspaces) | /groups | Workspace CRUD, membership |
| Imports | /imports | Upload PBIX/XLSX files |
| Pipelines | /pipelines | Deployment pipeline automation |
| Admin | /admin | Tenant-wide operations (scanner, activity) |
| EmbedToken | /GenerateToken | Create embed tokens |
| Gateways | /gateways | Gateway and data source management |
| Dataflows | /dataflows | Dataflow management |
| Apps | /apps | App management |
| Capacities | /capacities | Capacity management |
| Goals | /goals | Scorecards and goals |
POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/datasets/{datasetId}/refreshes
Authorization: Bearer {token}
Content-Type: application/json
{
"notifyOption": "MailOnFailure",
"retryCount": 2,
"type": "Full",
"commitMode": "transactional",
"applyRefreshPolicy": true
}
Enhanced refresh (selective tables/partitions):
{
"type": "Full",
"commitMode": "transactional",
"objects": [
{ "table": "Sales", "partition": "Sales_Current" },
{ "table": "Products" }
]
}
GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/datasets/{datasetId}/refreshes?$top=10
POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/imports?datasetDisplayName=SalesReport&nameConflict=CreateOrOverwrite
Authorization: Bearer {token}
Content-Type: multipart/form-data
[PBIX file as form data]
Python:
import requests
url = f"https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/imports"
params = {"datasetDisplayName": "SalesReport", "nameConflict": "CreateOrOverwrite"}
headers = {"Authorization": f"Bearer {token}"}
with open("SalesReport.pbix", "rb") as f:
response = requests.post(url, params=params, headers=headers,
files={"file": ("SalesReport.pbix", f, "application/octet-stream")})
# Initiate export
POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/reports/{reportId}/ExportTo
{
"format": "PDF",
"powerBIReportConfiguration": {
"pages": [
{ "pageName": "ReportSection1" }
],
"defaultBookmark": { "name": "BookmarkName" }
}
}
# Poll for completion
GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/reports/{reportId}/exports/{exportId}
# Download when status is "Succeeded"
GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/reports/{reportId}/exports/{exportId}/file
Supported formats: PDF, PPTX, PNG, XLSX, CSV, XML, MHTML, IMAGE, ACCESSIBLEPDF
POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/datasets/{datasetId}/Default.UpdateParameters
{
"updateDetails": [
{ "name": "ServerName", "newValue": "prod-server.database.windows.net" },
{ "name": "DatabaseName", "newValue": "ProdDB" }
]
}
POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/datasets/{datasetId}/Default.TakeOver
PATCH https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId}
{
"credentialDetails": {
"credentialType": "OAuth2",
"credentials": "{\"credentialData\":[{\"name\":\"accessToken\",\"value\":\"...\"}]}",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "None",
"privacyLevel": "Organizational"
}
}
Create and push data to datasets via API for real-time dashboards:
# Create push dataset
POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/datasets
{
"name": "RealTimeMetrics",
"defaultMode": "Push",
"tables": [
{
"name": "Metrics",
"columns": [
{ "name": "Timestamp", "dataType": "DateTime" },
{ "name": "Sensor", "dataType": "String" },
{ "name": "Value", "dataType": "Double" },
{ "name": "Status", "dataType": "String" }
]
}
]
}
# Push rows
POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/datasets/{datasetId}/tables/Metrics/rows
{
"rows": [
{ "Timestamp": "2026-04-03T10:30:00Z", "Sensor": "Temp-01", "Value": 23.5, "Status": "Normal" },
{ "Timestamp": "2026-04-03T10:30:00Z", "Sensor": "Temp-02", "Value": 45.2, "Status": "Warning" }
]
}
# Clear table
DELETE https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/datasets/{datasetId}/tables/Metrics/rows
POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/reports/{reportId}/GenerateToken
{
"accessLevel": "View",
"identities": [
{
"username": "[email protected]",
"roles": ["RegionManager"],
"datasets": ["{datasetId}"]
}
]
}
POST https://api.powerbi.com/v1.0/myorg/GenerateToken
{
"datasets": [
{ "id": "{datasetId}" }
],
"reports": [
{ "id": "{reportId}", "allowEdit": false }
],
"targetWorkspaces": [
{ "id": "{workspaceId}" }
],
"identities": [
{
"username": "[email protected]",
"roles": ["ViewerRole"],
"datasets": ["{datasetId}"]
}
]
}
<div id="reportContainer" style="height:600px;"></div>
<script src="https://cdn.jsdelivr.net/npm/powerbi-client/dist/powerbi.min.js"></script>
<script>
const embedConfig = {
type: 'report',
id: reportId,
embedUrl: embedUrl,
accessToken: embedToken,
tokenType: models.TokenType.Embed, // Use Embed for app-owns-data
settings: {
panes: {
filters: { visible: false },
pageNavigation: { visible: true }
},
bars: { statusBar: { visible: false } }
}
};
const container = document.getElementById('reportContainer');
const report = powerbi.embed(container, embedConfig);
// Token refresh handler
report.on('tokenExpired', async () => {
const newToken = await fetchNewToken(); // Call your backend
await report.setAccessToken(newToken);
});
// Event handlers
report.on('loaded', () => console.log('Report loaded'));
report.on('rendered', () => console.log('Report rendered'));
report.on('error', (event) => console.error(event.detail));
</script>
# Initiate scan
POST https://api.powerbi.com/v1.0/myorg/admin/workspaces/getInfo
{
"workspaces": ["{workspaceId1}", "{workspaceId2}"],
"datasetExpressions": true,
"datasetSchema": true,
"datasourceDetails": true,
"getArtifactUsers": true
}
# Get scan results
GET https://api.powerbi.com/v1.0/myorg/admin/workspaces/scanResult/{scanId}
GET https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime='2026-04-01T00:00:00Z'&endDateTime='2026-04-02T00:00:00Z'&$filter=Activity eq 'ViewReport'
GET https://api.powerbi.com/v1.0/myorg/admin/datasets?$top=100
references/api-endpoints-complete.md -- Complete API endpoint reference with all parameters, response schemas, and error codesWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
10 skills in this plugin
/dax-masteryDAX (Data Analysis Expressions) mastery for Power BI semantic models.
PROACTIVELY activate for: (1) writing DAX measures or calculated columns, (2) CALCULATE, FILTER, ALL, REMOVEFILTERS context-modification functions, (3) understanding filter context vs row context vs context transition, (4) time intelligence (SAMEPERIODLASTYEAR, DATEADD, YTD/MTD, TOTALYTD, DATESBETWEEN), (5) iterators (SUMX, AVERAGEX, FILTER), (6) variables (VAR/RETURN) and DAX optimization, (7) calculation groups, field parameters, and visual calculations, (8) WINDOW/INDEX/OFFSET/ORDERBY/PARTITIONBY/MATCHBY (window functions), (9) DAX user-defined functions (UDF), (10) DAX patterns for ratios, running totals, ranking.
Provides: measure templates, time-intelligence patterns, optimization techniques (variables, FILTER vs CALCULATETABLE), context-transition explainers, and reference for window functions and calculation groups.
/deployment-adminPower BI deployment, CI/CD, governance, and administration.
PROACTIVELY activate for: (1) Power BI deployment pipelines (Service deployment pipelines, fabric-cicd, custom workflows), (2) CI/CD for Power BI via GitHub Actions or Azure DevOps, (3) workspace management and roles, (4) row-level security (RLS) and object-level security (OLS), (5) capacity management (Premium, PPU, Fabric SKUs F2-F2048), (6) tenant settings and governance, (7) Power BI Report Server deployments, (8) service principal setup for automation, (9) data-gateway management.
Provides: deployment-pipeline templates, GitHub Actions and Azure DevOps YAML, RLS/OLS implementation patterns, capacity sizing guidance, and service-principal auth recipes.
/fabric-integrationMicrosoft Fabric integration with Power BI semantic models.
PROACTIVELY activate for: (1) Microsoft Fabric platform tasks, (2) Direct Lake mode and OneLake connectivity, (3) Fabric lakehouse, warehouse, KQL Database, Eventstream, Data Activator, (4) Dataflow Gen2 ETL, (5) Fabric notebooks (PySpark, Spark SQL, semantic-link), (6) Fabric workspace and capacity (F-SKU) management, (7) delta tables and V-Order optimization, (8) medallion architecture (bronze/silver/gold), (9) Semantic Link / sempy / semantic-link-labs Python workflows, (10) Direct Lake fallback rules and mixed mode.
Provides: Direct Lake setup, Fabric capacity sizing, lakehouse-to-semantic-model patterns, sempy/semantic-link-labs recipes, and end-to-end medallion architecture templates.
/performance-optimizationPower BI performance optimization for slow reports, models, and queries.
PROACTIVELY activate for: (1) report is slow or visuals take forever to load, (2) DAX Studio and VertiPaq Analyzer profiling, (3) Performance Analyzer in Power BI Desktop, (4) optimizing slow DAX measures, (5) slow visuals diagnosis, (6) aggregations and composite-model tuning, (7) query reduction techniques (visual settings, top N), (8) model size reduction (cardinality, calculated columns, summary tables), (9) VertiPaq compression tuning, (10) Direct Lake performance and fallback rules, (11) large-dataset (10GB+) optimization.
Provides: profiling workflow with DAX Studio, VertiPaq compression checklist, aggregation-table patterns, model-size reduction techniques, and end-to-end performance investigation playbook.
/powerbi-coreCore Power BI data modeling, source connectivity, and platform fundamentals.
PROACTIVELY activate for: (1) Power BI data modeling and star-schema design, (2) relationships (active/inactive, bidirectional, USERELATIONSHIP), (3) data-source selection (DirectQuery vs Import vs Direct Lake vs composite), (4) incremental refresh setup, (5) gateway configuration (on-prem and VNet gateways), (6) streaming datasets and push-data scenarios, (7) Dataflow Gen2 basics, (8) Power BI common gotchas and pitfalls (bidirectional filtering, AutoExist, blank-row), (9) workspace identity and OAuth2 / service-principal auth, (10) semantic model architecture review.
Provides: star-schema templates, mode-selection matrix, incremental refresh recipe, gateway setup steps, and a common-gotchas reference.
/power-query-mPower Query M language for ETL, transformations, and connector authoring.
PROACTIVELY activate for: (1) writing Power Query M code, (2) query folding and Native Query verification, (3) data transformations (merge, append, pivot, unpivot, split column), (4) custom connector development, (5) Power Query parameters and dynamic source patterns, (6) performance optimization (folding, query reduction, partition strategy), (7) Table.TransformColumns, List.Generate, Record.Field functions, (8) error handling in M (try/otherwise, error records), (9) mashup engine internals, (10) ETL pipelines from folder/SharePoint/database sources.
Provides: M language reference, query-folding diagnosis, transformation recipes, dynamic source patterns, error-handling templates, and performance tuning techniques.
npx claudepluginhub josiahsiegel/claude-plugin-marketplace --plugin powerbi-masterOther plugins' skills for the same job