Skip to main content

How to Add a Valid Domain to a Microsoft Teams App Manifest

· 10 min read
Jagdish Kumawat
Founder @ Dewiride

Teams loads a web page for your app, such as the page inside a dialog, only from a domain your app's manifest lists in validDomains. Here's what to put in that list, and how to add it to the manifest and get the new version into Teams.

What validDomains Is​

Every Teams app has a manifest.json, the file that tells Teams what the app is and what it can do. Microsoft's manifest reference describes validDomains as a list of valid domains from which the Microsoft 365 app expects to load any content.

For a bot, the list matters as soon as the bot shows a web page: Invoke and dismiss dialogs says the dialog feature requires that the domains of any URLs you want to load are included in the validDomains array in your app's manifest. A page whose domain isn't on the list never loads.

Syntax​

validDomains is a property at the top level of manifest.json, beside version and bots:

manifest.json (part)
"validDomains": [
"<domain>",
"<another domain>"
]
  • <domain> is a host name alone, such as contoso.example.com: no https://, and no path.
  • A wildcard replaces a whole part of the name, as in *.example.com. Each part before a wildcard must be a wildcard too: *.*.example.com is valid, but foo.*.example.com isn't.
  • Only domains you control. The reference warns: Don't add domains that are outside your control, either directly or through wildcards (*). *.onmicrosoft.com isn't yours, and neither is the whole domain of a tunnel service.
  • Up to 100 domains.

The Example​

The app Dialog Page Demo is a bot that opens a Teams dialog with a web page, wifi.html. The bot serves the page through a dev tunnel, at:

The page's address
https://cdzngt35-3980.inc1.devtunnels.ms/wifi.html

Its package, DialogPageDemo.zip, holds the manifest and two icons, and the manifest has no validDomains yet. You'll add the page's domain, raise the app's version from 1.0.0 to 1.0.1, and upload the new package.

Prerequisites​

  • On a Mac: jq and zip. macOS includes both; check with jq --version. On Linux, install them with your package manager.
  • On Windows: PowerShell 7. Its Set-Content writes UTF-8 without a byte order mark by default, as its reference says.

Step 1: Find the Domain​

Take the page's address and keep only the host name, the part between https:// and the next /:

AddressDomain
https://cdzngt35-3980.inc1.devtunnels.ms/wifi.htmlcdzngt35-3980.inc1.devtunnels.ms

For a dev tunnel, that's the host in the address devtunnel host prints after Connect via browser. List that exact host, never *.devtunnels.ms: that wildcard would trust everyone's tunnels.

Step 2: Unzip the Package and Look at the Manifest​

In the folder where the package is, unzip it into a folder of its own, and print the two values you'll change:

Terminal
mkdir DialogPageDemo
cd DialogPageDemo
unzip ../DialogPageDemo.zip
jq '{version, validDomains}' manifest.json
Output
Archive: ../DialogPageDemo.zip
inflating: manifest.json
inflating: color.png
extracting: outline.png
{
"version": "1.0.0",
"validDomains": null
}

jq '{version, validDomains}' prints only those two properties. null means the manifest has no validDomains at all.

How to Edit the Manifest in a Teams App Package explains these commands in more detail.

Step 3: Add the Domain and Raise the Version​

The manifest reference is clear about the version: Update or additions to your app manifest require the version to be incremented. This way, when the new app manifest is installed, it overwrites the existing one and the user gets the new functionality. So change both values together:

Terminal
jq '.version = "1.0.1" | .validDomains = ["cdzngt35-3980.inc1.devtunnels.ms"]' manifest.json > manifest.edited.json
mv manifest.edited.json manifest.json
jq '{version, validDomains}' manifest.json
Output
{
"version": "1.0.1",
"validDomains": [
"cdzngt35-3980.inc1.devtunnels.ms"
]
}
  • .version = "1.0.1" sets the version.
  • | passes the result on to the next change.
  • .validDomains = [ … ] adds the list, with the domain as its one item. jq adds it at the end of the manifest.
  • > manifest.edited.json, then mv write the result to a new file and put it in place of the old one. Writing straight back to manifest.json would empty it before jq reads it.

The manifest now ends with the new list:

A manifest.json file in a code editor window: the Dialog Page Demo app's manifest with version 1.0.1, its bot in the personal scope, and at the end a validDomains list holding cdzngt35-3980.inc1.devtunnels.ms.

manifest.json
{
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.30/MicrosoftTeams.schema.json",
"manifestVersion": "1.30",
"version": "1.0.1",
"id": "33333333-3333-3333-3333-333333333333",
"developer": {
"name": "Contoso",
"websiteUrl": "https://www.example.com",
"privacyUrl": "https://www.example.com/privacy",
"termsOfUseUrl": "https://www.example.com/terms"
},
"name": {
"short": "Dialog Page Demo",
"full": "Dialog Page Demo"
},
"description": {
"short": "Shows web pages in Teams dialogs.",
"full": "Chat with Dialog Page Demo and select a card button: a Teams dialog opens with a web page in it. A sample agent built with the Microsoft 365 Agents SDK."
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"accentColor": "#00838F",
"bots": [
{
"botId": "33333333-3333-3333-3333-333333333333",
"scopes": [
"personal"
],
"supportsFiles": false,
"isNotificationOnly": false
}
],
"validDomains": [
"cdzngt35-3980.inc1.devtunnels.ms"
]
}

id and botId hold your app's own ID; 33333333-3333-3333-3333-333333333333 stands in for it here.

Step 4: Zip the Package Again​

Put the three files back into a new package, at the top of the .zip, with no folder around them:

Terminal
zip ../DialogPageDemo-1.0.1.zip manifest.json color.png outline.png
Output
adding: manifest.json (deflated 53%)
adding: color.png (deflated 19%)
adding: outline.png (stored 0%)

Step 5: Upload the New Package​

Upload DialogPageDemo-1.0.1.zip in Teams the way you uploaded the first version: Store → the settings icon (Manage your apps) → Upload an app → Upload a custom app, as How to Upload a Custom App in Microsoft Teams shows step by step. Teams showed the app with Add again; after Add, select Open.

The Result​

With the domain on the list, Teams loads the page. The bot's card button opened the dialog, and the page was in it:

A Teams dialog from the app Dialog Page Demo, titled Guest Wi-Fi, showing the page: Network: Contoso-Guest, Password: ask at the front desk. It changes every day., and The guest network reaches the internet only.

The first time a browser opens a dev tunnel's address, Dev Tunnels shows its own warning page before yours: Fixed: "You Are About to Connect to a Developer Tunnel" in a Teams Dialog explains it.

Common Mistakes​

MistakeWhat happensDo this instead
Writing https:// or a path in the listThe list is for host namesWrite the host name alone
Adding *.devtunnels.ms or another service's whole domainYou trust domains you don't control, which the reference forbidsList your own host
Leaving version as it wasThe reference requires a higher version for every change to the manifestRaise it, for example from 1.0.0 to 1.0.1
Changing manifest.json but not uploading the new packageTeams keeps using the package it hasZip and upload again
jq … manifest.json > manifest.jsonThe shell empties the file before jq reads itWrite to manifest.edited.json, then mv

Troubleshooting​

SymptomLikely causeFix
The dialog stays empty, and Teams shows If you're having issues with this app, try the desktop versionThe page's domain isn't in validDomainsAdd it, raise version, upload again
The page still doesn't load after the changeThe tunnel's host changed, or the old package is still installedCompare the host with the page's address, and upload the new package
Exception setting "validDomains": "The property 'validDomains' cannot be found on this object. Verify that the property exists and can be set." in PowerShell$manifest.validDomains = … on a manifest without that propertyAdd it with Add-Member, as in Step 3
Resulting JSON is truncated as serialization has exceeded the set depth of 2.ConvertTo-Json without -DepthAdd -Depth 10 and write the manifest again

Fixed: "If You're Having Issues with This App, Try the Desktop Version" in a Teams Dialog shows the empty dialog and how to tell its causes apart.

FAQ​

Does my bot's messaging endpoint need to be on the list?​

No. The bot's messages reach it through its messaging endpoint, whatever validDomains says. The list is for content Teams loads, such as a dialog's page.

Can I list more than one domain?​

Yes, up to 100. Add each as its own item: ["contoso.example.com", "cdzngt35-3980.inc1.devtunnels.ms"].

Do I need a new entry when my dev tunnel changes?​

Yes, when its host changes. A tunnel you keep, as with devtunnel host <tunnel name>, keeps its host, so the entry stays right.

Conclusion​

Teams loads your app's pages only from the domains in validDomains. Add the page's host name, without https:// or a path, raise the manifest's version, zip the three files again and upload the new package.

Additional Resources​