Create a New Report In Embed View

  • Published
  • Posted in General
  • Updated
  • 3 mins read
  • Tagged as

Power BI embedding is a Platform-as-a-service (PaaS) provided by Microsoft Azure via which an independent service vendors (ISVs) can embed a visual, report or dashboard into an application. This ensures the secure a way of sharing a Power BI report without the consumer owning a Power BI account. However, when embedding the user just have a viewing access to the reports. What if the consumer can suggest some changes or want to make a new report then we cannot just say NO to them. So to overcome this, Microsoft Power BI provides us with an API to create a new report and this can be implemented quite easily.

Embed Token – Reports GenerateTokenForCreateInGroup

To create a new report we will be using Power BI API – GenerateTokenForCreateInGroup. This API generates an embed token to allow report creation on the specified workspace based on the specified dataset.

Requested Parameters

Name Type Description
groupid String The workspace Id

Request body


Name Type Description
accessLevel TokenAccessLevel Required access level for embedToken generation. For this use case it will be Create.
allowSaveAs Boolean Indicates an embedded report can be saved as a new report. Default value is ‘false’. Only applies when generating EmbedToken for report embedding.
datasetid String Dataset Id for report creation
Identities Effective Identity [] List of identities to use for RLS

This API will then return the embed token.

New Report Embed Token Generation

Server-Side Code

// Generate an embed token to create

var generateTokenRequestParameters = new GenerateTokenRequest(


“enter your datasetid”,

allowSaveAs: true


var tokenResponse = client.Reports.GenerateTokenForCreateInGroup(“enter your workspaceid”, generateTokenRequestParameters);

// Populate embed variables (to be passed client-side)

embedToken = tokenResponse.Token;

embedUrl = “” + “enter your workspaceid”;

datasetId = “enter your workspaceid”;

Note: RLS is not supported for this API. Hence, no effective identity have been defined in GenerateTokenRequest.

Client-Side Code

// Read embed token

var embedToken = “<% = this.embedToken %>”;

// Read embed URL

var embedUrl = “<% = this.embedUrl %>”;

// Read dataset Id

var datasetId = “<% = this.datasetId %>”;

// Get models (models contains enums)

var models = window[‘powerbi-client’].models;

// Embed configuration is used to describe what and how to embed

// This object is used when calling powerbi.embed

// It can also includes settings and options such as filters

var embedCreateConfiguration = {

type: ‘report’,

tokenType: models.TokenType.Embed,

accessToken: embedToken,

embedUrl: embedUrl,

datasetId: datasetId,


// Embed the report within the div element

var report = powerbi.createReport(embedDiv, embedCreateConfiguration);

var saveAsParameters = {

name: “newReport”


// SaveAs report


Pragya Verma
Data Analyst
Addend Analytics

Addend Analytics is a Microsoft Gold Partner based in Mumbai, India, and a branch office in the U.S.

Addend has successfully implemented 100+ Microsoft Power BI and Business Central projects for 100+ clients across sectors like Financial Services, Banking, Insurance, Retail, Sales, Manufacturing, Real estate, Logistics, and Healthcare in countries like the US, Europe, Switzerland, and Australia.

Get a free consultation now by emailing us or contacting us.