401 "Authorization has been denied" when bot sends a message in single-tenant configuration.

Kevin Boban 45 Reputation points
2026-04-17T08:16:16.9666667+00:00

Issue: 401 "Authorization has been denied" when bot sends a message via the Send Message API in single-tenant configuration.

Environment

  • Display Name: DG Single Tenant App
  • Client ID: [Moderator note: personal info removed]
  • Tenant ID: [Moderator note: personal info removed]
  • Domain: [Moderator note: personal info removed]

The bot was set up via the bot dev portal.(https://dev.teams.cloud.microsoft/)

Problem When the bot tries to send a message using the Send Message API, we're getting a 401 error with message: "Authorization has been denied for this request.".

In the Azure portal(https://portal.azure.com/), "Supported account types" is set to Single tenant only – salessavvy, following the guidance https://learn.microsoft.com/en-us/answers/questions/5621905/running-into-401-errors-when-bot-is-trying-to-post

If we set "Supported account types" to "Multiple Entra ID tenants", the bot starts working. However, this is not ideal - customers are understandably hesitant to use a multi-tenant configuration due to security concerns.

[Moderator note: personal info removed] is our internal test tenant. We also have a customer blocked on the same issue, so we'd appreciate an urgent resolution. Thanks!

Microsoft Teams | Development
Microsoft Teams | Development

Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs


2 answers

Sort by: Most helpful
  1. Anonymous
    2026-04-17T09:29:49.14+00:00

    Please note that Q&A forum is a public platform, and moderators will modify the question to hide personal information in the description. Kindly ensure that you hide any personal or organizational information the next time you post an error or other details to protect personal data.

    Hello Kevin Boban

    Based on the behavior you described, it’s very likely that the bot was originally created as a multi‑tenant bot and later reused by switching it to single‑tenant. If this is the case, please note that reusing or converting an existing multi‑tenant bot to single‑tenant often results in 401 “Authorization has been denied” errors when sending messages. This same behavior is also reproduced in the thread you shared.

    To make a single‑tenant bot work reliably, Microsoft’s supported approach (and what I’ve seen work in practice) is to create a brand‑new app registration and bot configured as single‑tenant from the start, rather than reusing or converting an existing multi‑tenant bot. After creating a new bot and updating the App ID and client secret in the bot configuration, sending messages should work as expected.

    Please try this approach and let me know your feedback.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


  2. AI answer

    2026-04-17T08:16:36.9633333+00:00

    The 401 in a single-tenant setup is caused by how the bot’s identity and tenant configuration are wired, not by a general Teams or Direct Line issue. In a single-tenant bot, the app registration, bot resource, and the tenant where the bot runs must be aligned, and the adapter must be initialized correctly for that single-tenant identity.

    From the provided context, there are two directly relevant patterns:

    1. Single-tenant bot identity must be configured correctly in the bot code
      For a single-tenant bot, the configuration must explicitly use:
      • MicrosoftAppType = SingleTenant
      • MicrosoftAppId = the bot’s app (client) ID
      • MicrosoftAppPassword = the bot’s app secret
      • MicrosoftAppTenantId = the tenant ID where the app is registered
      This must be set in the bot’s configuration file (for example, appsettings.json for C#, .env for JavaScript, config.py for Python). If any of these values are missing or mismatched (for example, wrong tenant ID or app type), token acquisition will fail and outbound calls (such as Send Message) will return 401.
    2. Service principal must exist for single-tenant bots
      For a single-tenant Azure Bot Service (msaAppType: 'SingleTenant'), the app registration must be linked to a service principal in the tenant. If the service principal is missing, token requests to login.microsoftonline.com/{tenantId} fail with 401. The fix is:
      1. In Azure portal, go to App registrations.
      2. Open the bot’s app registration using the bot’s Client ID.
      3. Check the Managed application in local directory field:
        • If a value is present, the service principal exists.
        • If it shows Create Service Principal, select that to create it.
      4. After creation, restart the bot so it can acquire tokens using the new principal.
    3. Adapter initialization for single-tenant / cross-tenant scenarios
      A similar 401 issue in Teams was resolved when the bot’s adapter (CloudAdapter) was initialized correctly for cross-tenant communication. If the adapter is still configured as if the app were multi-tenant, or if it does not use the correct MicrosoftAppType and tenant ID, the bot will receive 401 when sending messages even though it can receive them. The working pattern is:
      • Ensure the adapter uses the same identity configuration as above (SingleTenant, correct AppId, TenantId, and secret).
      • For cross-tenant Teams usage with a single-tenant bot, the bot still authenticates only against its home tenant; the adapter must not be configured as multi-tenant just to reach other tenants.
    4. Why multi-tenant appears to “fix” it
      When the app registration is changed to “Multiple Entra ID tenants”, the platform can fall back to multi-tenant token validation, which can mask a missing or misconfigured single-tenant identity (service principal or MicrosoftAppType/tenant ID mismatch). This is why it works in multi-tenant mode but fails in single-tenant mode. However, the Bot Framework and Teams support secure single-tenant bots. The correct fix is to:
      • Keep the app registration as single tenant.
      • Ensure the service principal exists.
      • Ensure the bot’s configuration and adapter use SingleTenant with the correct tenant ID and secret.
    5. Checklist to resolve the 401 in single-tenant mode
      1. In Azure portal → App registrations:
        • Confirm the bot app is single tenant.
        • Confirm a Managed application in local directory exists; if not, select Create Service Principal.
      2. In the bot’s configuration file:
        • Set MicrosoftAppType = SingleTenant.
        • Set MicrosoftAppId to d957be44-985d-4286-a773-f34cbae2e7a4.
        • Set MicrosoftAppTenantId to 1134ea03-328d-4b26-9caf-505e7392d4aa.
        • Set MicrosoftAppPassword to the current client secret for that app.
      3. Ensure the adapter (CloudAdapter or equivalent) is initialized using those values.
      4. Restart the bot and retry the Send Message call.

    Once the service principal and identity configuration are correct, the bot can remain single-tenant and still send messages via the Send Message API without 401 errors, including in cross-tenant Teams scenarios.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.