
Add Dataverse
Wire agents or scripts to Microsoft Dataverse using OData v9.2 and Azure CLI bearer tokens instead of guessing Power Platform auth headers.
Overview
Add-dataverse is an agent skill for the Build phase that documents Dataverse OData Web API setup with Azure CLI tokens and standard OData headers.
Install
npx skills add https://github.com/microsoft/power-platform-skills --skill add-dataverseWhat is this skill?
- Azure CLI authentication via az account get-access-token against the environment resource URL
- OData v9.2 base path and required OData-Version / OData-MaxVersion headers
- Environment URL discovery from make.powerapps.com Developer resources Web API endpoint
- PowerShell-ready $headers block with Prefer return=representation
- Prerequisite az login / az account show verification before API calls
- OData Web API version 9.2 path documented
- 5 core API headers table in skill readme
Adoption & trust: 98 installs on skills.sh; 349 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need to call Dataverse from code or an agent but are unsure which URL, token audience, and OData headers Microsoft expects.
Who is it for?
Builders on Microsoft 365 / Power Platform stacks who automate Dataverse from CLI or agent tooling with Azure AD already in place.
Skip if: Teams without Dataverse licensing, non-Microsoft stacks, or users who only need canvas app design without Web API access.
When should I use this skill?
Integrating with Dataverse OData Web API and you need Azure CLI token and header setup from the skill reference.
What do I get? / Deliverables
You have a repeatable PowerShell or script pattern: authenticated $headers, $baseUrl, and v9.2 endpoint ready for entity operations.
- Authenticated $headers and $baseUrl for v9.2 calls
- Reusable token acquisition snippet for agents or scripts
Recommended Skills
Journey fit
Dataverse connectivity is build-phase integration work once you are implementing CRM/back-office features on Power Platform. Integrations subphase captures external SaaS APIs (OData) with Azure identity—not frontend canvas apps alone.
How it compares
OData + Azure CLI auth reference—not a full low-code Power Apps generator or replace for official Power Platform connectors docs.
Common Questions / FAQ
Who is add-dataverse for?
Solo developers and indie SaaS builders integrating with Dataverse environments who prefer scriptable Azure CLI tokens over interactive connector wizards.
When should I use add-dataverse?
In build integrations when you are first connecting agents, PowerShell, or services to your org’s Dataverse Web API endpoint and need correct headers and token acquisition.
Is add-dataverse safe to install?
Check the Security Audits panel on this Prism page; the skill uses network and Azure credentials—limit tokens to least-privilege Dataverse roles and never commit secrets.
SKILL.md
READMESKILL.md - Add Dataverse
# API Authentication Reference Uses Dataverse OData Web API with Azure CLI authentication (`az account get-access-token`). ## Prerequisites Ensure Azure CLI is authenticated before proceeding: ```powershell # Verify Azure CLI is logged in az account show # If not logged in, run: az login ``` ## Get Environment URL Find your Dataverse environment URL in make.powerapps.com: > **Settings** → **Developer resources** → **Web API endpoint** It looks like `https://<org-name>.crm.dynamics.com/api/data/v9.2/`. Use the base URL: `https://<org-name>.crm.dynamics.com`. ## Get Access Token ```powershell $envUrl = "https://<org>.crm.dynamics.com" # Replace with your org URL $token = (az account get-access-token --resource $envUrl --query accessToken -o tsv) ``` ## Set Up API Headers ```powershell $headers = @{ "Authorization" = "Bearer $token" "Content-Type" = "application/json" "OData-MaxVersion" = "4.0" "OData-Version" = "4.0" "Prefer" = "return=representation" } $baseUrl = "$envUrl/api/data/v9.2" ``` ## API Headers Reference | Header | Value | Purpose | | -------------------------- | ----------------------- | ------------------------------- | | `Authorization` | `Bearer <token>` | Authentication token | | `Content-Type` | `application/json` | Request body format | | `OData-MaxVersion` | `4.0` | Maximum OData version supported | | `OData-Version` | `4.0` | OData version to use | | `MSCRM.SolutionUniqueName` | Solution name | Add created items to a solution | | `Prefer` | `return=representation` | Return created record with ID | ## Get Default Publisher Prefix The publisher prefix is used for naming custom tables and columns. Fetch it dynamically: ```powershell function Get-DefaultPublisherPrefix { param( [Parameter(Mandatory=$true)] [string]$BaseUrl, [Parameter(Mandatory=$true)] [hashtable]$Headers ) $defaultPublisher = Invoke-RestMethod -Uri "$BaseUrl/publishers?`$filter=friendlyname eq 'CDS Default Publisher'&`$select=customizationprefix,friendlyname" -Headers $Headers if ($defaultPublisher.value.Count -eq 0) { throw "Could not find CDS Default Publisher in the environment" } $prefix = $defaultPublisher.value[0].customizationprefix Write-Host "Customization Prefix: $prefix" -ForegroundColor Cyan return $prefix } ``` ## Complete Setup Script ```powershell function Initialize-DataverseApi { param( [Parameter(Mandatory=$true)] [string]$EnvironmentUrl, [string]$SolutionName = $null ) $token = (az account get-access-token --resource $EnvironmentUrl --query accessToken -o tsv) if (-not $token) { throw "Failed to get access token. Make sure you're logged in with 'az login'" } $headers = @{ "Authorization" = "Bearer $token" "Content-Type" = "application/json" "OData-MaxVersion" = "4.0" "OData-Version" = "4.0" "Prefer" = "return=representation" } if ($SolutionName) { $headers["MSCRM.SolutionUniqueName"] = $SolutionName } $baseUrl = "$EnvironmentUrl/api/data/v9.2" $publisherPrefix = Get-DefaultPublisherPrefix -BaseUrl $baseUrl -Headers $headers return @{ Headers = $headers BaseUrl = $baseUrl PublisherPrefix = $publisherPrefix } } ``` ## Token Refresh Access tokens expire after ~1 hour. For long-running scripts: ```powershell function Get-FreshToken { param([string]$EnvironmentUrl) return (az account get-access-token --resource $EnvironmentUrl --query accessToken -o tsv) } function Invoke-DataverseApi { param( [string]$Uri, [string]$Method = "Get", [hashtable]$Headers, [string]$Body = $null, [string]$Envi