Microsoft Teams Bot Framework · error code

Teams error 401 Unauthorized (tenant mismatch): Single-tenant vs multi-tenant mismatch

ConfigurationHTTP 401Authentication & identity

Last verified against Microsoft Learn - Status codes from bot conversational APIs

What Teams returns
AADSTS700016: The application wasn't found in the directory/tenant.

What error 401 Unauthorized (tenant mismatch) means

The bot's code and its Entra app registration disagree about tenancy. An Entra application is created as either single-tenant (tokens must be requested from that tenant's own endpoint) or multi-tenant (tokens come from the shared botframework.com endpoint). The Bot Framework SDKs encode this as the MicrosoftAppType setting - SingleTenant, MultiTenant, or UserAssignedMSI - paired with MicrosoftAppTenantId. When the app type in configuration does not match how the app was actually registered, token requests go to the wrong authority and Entra answers with AADSTS700016: "The application wasn't found in the directory/tenant... You might have misconfigured the identifier value for the application or sent your authentication request to the wrong tenant."

This bites in two directions. A single-tenant registration driven by default multi-tenant SDK settings asks botframework.com for a token, and that shared directory has never heard of the app. A multi-tenant registration configured with a specific tenant ID can acquire tokens yet still fail validation when the Azure Bot resource's own app type disagrees. Since new Azure Bot resources default to single-tenant, older sample code and tutorials written for multi-tenant bots are the classic source of the mismatch - cause 3 in Teams bot not responding.

What it looks like

{
  "error": "unauthorized_client",
  "error_description": "AADSTS700016: Application with identifier '...' was not found in the directory '...'. ...",
  "error_codes": [700016]
}

Why it happens

  • The Azure Bot was created single-tenant (the current default) but the SDK configuration omits MicrosoftAppType and MicrosoftAppTenantId, so the SDK defaults to multi-tenant.
  • MicrosoftAppType says SingleTenant but MicrosoftAppTenantId is empty or carries another tenant's GUID.
  • The app registration was recreated with a different tenancy than the original, and configuration was never updated.
  • Code copied from a multi-tenant sample runs against a single-tenant registration (or vice versa).

How to fix Teams error 401 Unauthorized (tenant mismatch)

  1. 1In the Azure portal, open the Azure Bot resource > Configuration and note the App type and Tenant ID it was registered with.
  2. 2Cross-check the Entra app registration: Overview > Supported account types shows single-tenant ('My organization only') vs multi-tenant.
  3. 3Set MicrosoftAppType and MicrosoftAppTenantId in your bot configuration to exactly match (SingleTenant + the directory's tenant GUID, or MultiTenant with no tenant pin).
  4. 4For single-tenant, verify the token request goes to https://login.microsoftonline.com/<your-tenant-id>/oauth2/v2.0/token, not the botframework.com endpoint.
  5. 5Redeploy and confirm with one end-to-end message; if the token succeeds but sends still 401, re-check that the Azure Bot resource's app ID matches the registration you fixed.

How to stop it recurring

Decide tenancy once, at creation, and record it beside the app ID and secret as the third corner of the credential triangle. Always set MicrosoftAppType explicitly - relying on SDK defaults is how multi-tenant assumptions sneak into single-tenant bots. When you must migrate tenancy, treat it as a re-registration with its own smoke test, not a config toggle. A startup token check pinned to the configured authority catches the mismatch on deploy rather than in production, exactly as it does for an expired secret.

Official reference: Microsoft Learn - Status codes from bot conversational APIs. See all Teams error codes or the Teams limits and quotas.

Related codes

Error 401 Unauthorized (tenant mismatch) - quick answers

What does Teams error 401 Unauthorized (tenant mismatch) mean?

The bot's code and its Entra app registration disagree about tenancy. An Entra application is created as either single-tenant (tokens must be requested from that tenant's own endpoint) or multi-tenant (tokens come from the shared botframework.com endpoint). The Bot Framework SDKs encode this as the MicrosoftAppType setting - SingleTenant , MultiTenant , or UserAssignedMSI - paired with MicrosoftAppTenantId .

How do I fix Teams error 401 Unauthorized (tenant mismatch)?

1. In the Azure portal, open the Azure Bot resource > Configuration and note the App type and Tenant ID it was registered with. 2. Cross-check the Entra app registration: Overview > Supported account types shows single-tenant ('My organization only') vs multi-tenant. 3. Set MicrosoftAppType and MicrosoftAppTenantId in your bot configuration to exactly match (SingleTenant + the directory's tenant GUID, or MultiTenant with no tenant pin). 4. For single-tenant, verify the…

Stop debugging Teams by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.