> For the complete documentation index, see [llms.txt](https://docs.powerembedded.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.powerembedded.com.br/en/technical-documentation/api/api-automations.md).

# API automations

### Getting the API Key

The first step is to obtain the API key in the Settings menu of the administration portal.

It is also possible to generate authentication keys based on permissions, with the administrator being able to generate keys that will allow access only to a subset of endpoints.

### Managing Users via the API

The API documentation can be accessed [here](https://api.powerembedded.com.br/index.html). Using the GET /api/user route, you can list users in the system.

```bash
curl -X 'GET' \
  'https://api.powerembedded.com.br/api/user' \
  -H 'accept: application/json' \
  -H 'X-API-Key: HNhlHXAG1g21NyIsIkFwaUtleSI6Ik'
```

Example server response, where the "reports" property contains an array with all the IDs of the reports my user has access to, and "groups" points to an array with all the groups my user belongs to.

```json
{
  "pageIndex": 1,
  "totalPages": 2,
  "hasNextPage": true,
  "hasPreviousPage": false,
  "data": [
    {
      "id": "dd668e6d-4f83-4715-a155-b55213677dd8",
      "email": "user@company.com",
      "name": "Example User",
      "role": 3,
      "reports": [
        "c3aa3e62-7c43-4c0f-ab1d-3f9e0fbbad0e",
        "57e23242-ad69-455b-8955-1a0b4e35e6ed",
        "359a3241-08e2-45d1-b046-78c3c9c7ea8f",
        "7c8a79ec-23d0-4edc-8299-89461e134c34",
        "48dc89e1-240d-4b25-bba2-e8cb2d3d16d4",
        "9339a616-9d09-49dd-a848-3289161b2c2a"
      ],
      "companies": [],
      "groups": [
        "5d47cdd0-bd05-4e27-a87a-45b45da4360e",
        "833e6b83-f157-47ef-9f1f-7545d705c5a1"
      ],
      "reportLandingPage": null,
      "department": "BI ",
      "expirationDate": null,
      "windowsAdUser": null,
      "canEditReport": true,
      "canCreateReport": false,
      "canOverwriteReport": false
    }
  ]
}
```

To filter the user list by name and email, simply use the query parameters "name" and "email", respectively.

```bash
curl -X 'GET' \
  'https://api.powerembedded.com.br/api/user?name=Example%20User&email=user%40company.com' \
  -H 'accept: application/json' \
  -H 'X-API-Key: HNhlHXAG1g21NyIsIkFwaUtleSI6Ik'
```

To create a new user in the system, use the POST /api/user route. The "role" key defines the [user role](https://docs.powerembedded.com.br/administration-portal/users/user-role-types):

1. Administrator
2. Contributor
3. Viewer
4. Workspace Contributor

```bash
curl -X 'POST' \
  'https://api.powerembedded.com.br/api/user' \
  -H 'accept: */*' \
  -H 'X-API-Key: HNhlHXAG1g21NyIsIkFwaUtleSI6Ik' \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "user@company.com",
  "name": "Example User",
  "role": 1
}'
```

To delete a user from the system, use the DELETE /api/user/{userEmail} route, where "userEmail" is the email of the user to be deleted.

```bash
curl -X 'DELETE' \
  'https://api.powerembedded.com.br/api/user/user%40company.com' \
  -H 'accept: */*' \
  -H 'X-API-Key: HNhlHXAG1g21NyIsIkFwaUtleSI6Ik'
```

### Controlling Report Permissions via the API

You can also grant access permission to one or more reports for a user using the PUT /api/user/link-reports route. Simply pass the report IDs in the "reports" array and the user's email in "userEmail".

```bash
curl -X 'PUT' \
  'https://api.powerembedded.com.br/api/user/link-reports' \
  -H 'accept: */*' \
  -H 'X-API-Key: HNhlHXAG1g21NyIsIkFwaUtleSI6Ik' \
  -H 'Content-Type: application/json' \
  -d '{
  "userEmail": "user@company.com",
  "reports": [
    "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "2fa8bf64-3615-5162-b3fb-1c963f66afa5"
  ]
}'
```

To remove access permission for one or more reports, simply use the PUT /api/user/unlink-reports route.

```bash
curl -X 'PUT' \
  'https://api.powerembedded.com.br/api/user/unlink-reports' \
  -H 'accept: */*' \
  -H 'X-API-Key: HNhlHXAG1g21NyIsIkFwaUtleSI6Ik' \
  -H 'Content-Type: application/json' \
  -d '{
  "userEmail": "user@company.com",
  "reports": [
    "3fa85f64-5717-4562-b3fc-2c963f66afa6"
  ]
}'
```

### Listing Existing Reports in Power Embedded

In addition to listing users, it is also possible to list reports. This way, you can access some metadata, such as report IDs. To do this, simply use the GET /api/report route.

```bash
curl -X 'GET' \
  'https://api.powerembedded.com.br/api/report' \
  -H 'accept: application/json' \
  -H 'X-API-Key: HNhlHXAG1g21NyIsIkFwaUtleSI6Ik'
```

Example server response.

```json
{
  "pageIndex": 1,
  "totalPages": 3,
  "hasNextPage": true,
  "hasPreviousPage": false,
  "data": [
    {
      "id": "f8dd3f97-be3a-423b-91d5-923da88f5ec6",
      "name": "Sales Report",
      "description": "Report with sales information",
      "datasetId": "b6bd5b2b-8983-41b1-970e-aa95bec52f39",
      "embedUrl": "https://app.powerbi.com/reportEmbed?reportId=f8dd3f97-be3a-423b-91d5-923da88f5ec6&groupId=d397e342-a1a0-47e4-94ee-acd6f23ddc52&w=2&config=eyJjbHVzdGVyVXJsIjoiaHR0cHM6Ly9XQUJJLUJSQVpJTC1TT1VUSC1yZWRpcmVjdC5hbmFseXNpcy53aW5kb3dzLm5ldCIsImVtYmVkRmVhdHVyZXMiOnsidXNhZ2VNZXRyaWNzVk5leHQiOnRydWV9fQ%3d%3d",
      "workspaceId": "d397e342-a1a0-47e4-94ee-acd6f23ddc52",
      "reportType": 1,
      "folderId": null,
      "workspaceName": "BI",
      "userOwner": null
    }
  ]
}
```

Just like the users endpoint, it is also possible to filter reports using query parameters. In the example below, I use the "reportName" and "workspaceName" parameters.

```bash
curl -X 'GET' \
  'https://api.powerembedded.com.br/api/report?reportName=Lab%20Attendance&workspaceName=BI' \
  -H 'accept: application/json' \
  -H 'X-API-Key: d397e342-a1a0-47e4-94ee-acd6f23ddc52'
```

Server response.

```json
{
  "pageIndex": 1,
  "totalPages": 1,
  "hasNextPage": false,
  "hasPreviousPage": false,
  "data": [
    {
      "id": "cb56555d-546c-40a2-b988-b1903cbbe39c",
      "name": "Lab Attendance",
      "description": null,
      "datasetId": "693527e8-d0d6-4ef0-a570-7213e9ba59bc",
      "embedUrl": "https://app.powerbi.com/reportEmbed?reportId=cb56555d-546c-40a2-b988-b1903cbbe39c&groupId=d397e342-a1a0-47e4-94ee-acd6f23ddc52&w=2&config=eyJjbHVzdGVyVXJsIjoiaHR0cHM6Ly9XQUJJLUJSQVpJTC1TT1VUSC1yZWRpcmVjdC5hbmFseXNpcy53aW5kb3dzLm5ldCIsImVtYmVkRmVhdHVyZXMiOnsidXNhZ2VNZXRyaWNzVk5leHQiOnRydWV9fQ%3d%3d",
      "workspaceId": "d397e342-a1a0-47e4-94ee-acd6f23ddc52",
      "reportType": 1,
      "folderId": null,
      "workspaceName": "BI",
      "userOwner": null
    }
  ]
}
```

### Row-Level Security (RLS) Using the API

To list all roles linked to your datasets, simply use the GET /api/datasets/rls route.

```bash
curl -X 'GET' \
  'https://api.powerembedded.com.br/api/datasets/rls' \
  -H 'accept: application/json' \
  -H 'X-API-Key: d397e342-a1a0-47e4-94ee-acd6f23ddc52'
```

Server response.

```json
{
  "pageIndex": 1,
  "totalPages": 2,
  "hasNextPage": true,
  "hasPreviousPage": false,
  "data": [
    {
      "id": "213cb3bd-ddf6-4e7b-9707-37859200f938",
      "name": "Admin",
      "users": [
        "b3569847-98af-4d3d-837c-b679afed8f64",
        "ca506817-6bff-4564-81ae-7e3d40c27947",
        "22672557-bb9d-49bd-8f97-e6341390cca0"
      ],
      "groups": [],
      "datasetId": "a57cae24-1073-41e3-818b-b7a82b76cc88",
      "userEmails": [
        "rafael.mendonca@powertuning.com.br",
        "alison.pezzott@powertuning.com.br",
        "dirceu.resende@powertuning.com.br"
      ]
    }
  ]
}
```

It is also possible to use query parameters. In the example below, I provided a dataset ID in the "datasetId" parameter.

```bash
curl -X 'GET' \
  'https://api.powerembedded.com.br/api/datasets/rls?datasetId=c07dce01-f9b3-4a5c-be5d-dae7dc39a4fe' \
  -H 'accept: application/json' \
  -H 'X-API-Key: d397e342-a1a0-47e4-94ee-acd6f23ddc52'
```

Server response.

```json
{
  "pageIndex": 1,
  "totalPages": 1,
  "hasNextPage": false,
  "hasPreviousPage": false,
  "data": [
    {
      "id": "58f4a4ae-d85e-4c60-afdc-e0e26f6f96d5",
      "name": "General",
      "users": [],
      "groups": [],
      "datasetId": "c07dce01-f9b3-4a5c-be5d-dae7dc39a4fe",
      "userEmails": []
    },
    {
      "id": "95050ddf-b0c5-4631-9aa8-56eebece752b",
      "name": "Receptionist15",
      "users": [
        "fabff0b5-73f3-44c8-885d-34445a8df76a",
        "2d60d03d-6bcf-435d-acad-0a3900ce0f6c"
      ],
      "groups": [],
      "datasetId": "c07dce01-f9b3-4a5c-be5d-dae7dc39a4fe",
      "userEmails": [
        "user@company.com",
        "other@company.com"
      ]
    }
  ]
}
```

To link an RLS role to a user or group, you can use the PUT /api/datasets/rls/link-users and PUT /api/datasets/rls/link-groups routes, respectively. To unlink, use /unlink-users and /unlink-groups.

Below is an example with PUT /api/datasets/rls/link-users.

```bash
curl -X 'PUT' \
  'https://api.powerembedded.com.br/api/datasets/rls/link-users' \
  -H 'accept: */*' \
  -H 'X-API-Key: d397e342-a1a0-47e4-94ee-acd6f23ddc52' \
  -H 'Content-Type: application/json' \
  -d '{
  "usersEmails": [
    "user@company.com"
  ],
  "datasetId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "role": "Admin"
}'
```

### Querying the Power Embedded Report Access Log via API

You can also use the GET /api/report-audit route to access the report audit log, querying all report accesses made by Power Embedded users.

```bash
curl -X 'GET' \
  'https://api.powerembedded.com.br/api/report-audit' \
  -H 'accept: application/json' \
  -H 'X-API-Key: d397e342-a1a0-47e4-94ee-acd6f23ddc52'
```

Server response.

```json
{
  "pageIndex": 1,
  "totalPages": 184,
  "hasNextPage": true,
  "hasPreviousPage": false,
  "data": [
    {
      "id": "fd00daf2-15b4-42f7-b929-3e1a593558ee",
      "createdAt": "2025-10-10T14:09:58.372834Z",
      "organizationId": "4b532635-a0c6-48ae-bea8-a5197c63f057",
      "userId": "c3bc257a-b32b-4979-922e-832ce61b205b",
      "userEmail": "francisco.neto@powertuning.com.br",
      "reportId": "cb56555d-546c-40a2-b988-b1903cbbe39c",
      "reportName": "Lab Attendance",
      "action": 1,
      "actionName": "TokenRequested"
    }
  ]
}
```

It is also possible to filter by query parameters, such as "userEmail", "reportName", "pageNumber", among others.

### **How to Display Power BI Reports in Your Application**

{% hint style="info" %}
To learn more about displaying reports in external applications, visit the page [Show reports in your system](/en/technical-documentation/api/show-report-on-your-system.md).
{% endhint %}

### **Documentation**

Full API documentation:\
[Swagger UI (powerembedded.com.br)](https://api.powerembedded.com.br/index.html)

API demonstration page for embedding reports:\
[Demo - PowerPortal.IntegrationDemo (powerembedded.com.br)](https://dev.demoapi.powerembedded.com.br/)
