> ## Documentation Index
> Fetch the complete documentation index at: https://www.courier.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Install the Courier skill before writing code: `npx skills add trycourier/courier-skills`. It carries the verified SDK shapes and the rules you cannot get wrong.
> Authenticate every request with `Authorization: Bearer <API_KEY>`. A workspace has several environments and each has its own keys, which are plain `pk_` strings with no environment prefix. Start with Test.
> Send with `client.send.message` from the Node SDK (`@trycourier/courier` v7 and later, where the client is the default import). Reference a template by its `nt_` id or its alias.
> A send accepts a bare Elemental element list, but storing content on a template requires the top-level elements wrapped in a channel element.
> To translate a template, write one locale at a time with `PUT /notifications/{id}/locales/{localeId}`, which merges into the existing translations. `PUT /notifications/{id}/content` and `PUT /notifications/{id}/elements/{elementId}` overwrite translations along with the content, so send each element's `id` and `locales` back, and first remove every `checksum` and any `locales` key that starts with an underscore.
> Templates and journeys can be built in the Courier app or created through the API. Either way they live in the workspace and are referenced by ID when you send.
> The hosted MCP server is https://mcp.courier.com. For a briefing on what Courier is and when to use it, read https://www.courier.com/llms.txt.
> Adding notifications to a framework app? Start from its quickstart, which has a runnable repo and complete files: Next.js email https://www.courier.com/docs/guides/add-transactional-email-to-nextjs.md, Django https://www.courier.com/docs/guides/add-notifications-to-django.md, Rails https://www.courier.com/docs/guides/add-notifications-to-rails.md, Node.js digest https://www.courier.com/docs/guides/batch-notifications-into-a-daily-digest-in-node.md, Laravel https://www.courier.com/docs/guides/add-notifications-to-laravel.md, FastAPI https://www.courier.com/docs/guides/send-notifications-from-fastapi.md, Express https://www.courier.com/docs/guides/add-notifications-to-express.md, and the React, Next.js, Astro, and Nuxt inbox quickstarts under /guides/add-an-inbox-to-*.
> Prefer the Guides tab for how-do-I questions and the Docs tab for how-does-it-behave questions. The API reference lives under /api-reference.

# Send your first Microsoft Teams message

> Create a Teams bot, connect it to Courier, install it in a team, and post your first channel message, then reach a person and fix common errors.

Microsoft Teams messages come from a bot you own. Courier holds the bot's credentials and posts as your app, to a channel, a chat, or a person.

Once the bot is installed in a team, a Teams message is the same send as an email.

## Prerequisites

* [A Courier Test API key](https://app.courier.com/~/test/platform/api-keys)
* Access to the [Azure portal](https://portal.azure.com/) and the [Teams Developer Portal](https://dev.teams.microsoft.com/)
* A team where you can install a custom app
* A published [template](https://www.courier.com/docs/design/templates/overview.md) with a Microsoft Teams channel

## The bot is the sender

Courier stores the bot's credentials once, on the integration. Each send then says where to post, with an id for the channel or person and the organization's `tenant_id`.

The bot can post only where its app is installed, so installing the app is part of setup. A send to a team without the app fails even with correct credentials.

## Send it

**1. Create the bot and connect it to Courier**

You need three things: an Azure app registration, a bot, and a Teams app that contains the bot. [The Microsoft Teams integration page](https://www.courier.com/docs/integrations/direct-message/microsoft-teams.md#setup) walks each screen.

Then add the bot's credentials to Courier's [Microsoft Teams integration](https://app.courier.com/integrations/catalog/msteams). Both come from the bot's app registration in Azure, not the Teams app's. **App ID** takes the bot's Application (client) ID, and **App Password** takes its client secret value.

**2. Install the app in the team**

Download the app package from the Teams Developer Portal (**Publish**, then **Download the app package**). In Teams, open **Apps**, **Manage your apps**, and **Upload an app**.

Then open the team, choose **Manage team**, open the **Apps** tab, and add your app. Uploading covers one-to-one messages only, and channel posts fail until the app is in the team.

**3. Copy the channel's ids**

In Teams, open the channel's **...** menu and choose **Copy link**. The link carries both ids you need:

```text Channel link theme={null}
https://teams.microsoft.com/l/channel/19%3A5140d7460868414cac958ac76a0a94d0%40thread.skype/alerts?groupId=feb55fc1-9e00-40f3-93b8-f7d14703f4dd&tenantId=dabd1935-56a4-4305-938e-0840e2e84515
```

URL-decode the path segment after `/channel/` for the channel id, `19:5140d7460868414cac958ac76a0a94d0@thread.skype`. Newer channels end in `@thread.tacv2` instead. The `tenantId` query parameter is the organization, `dabd1935-56a4-4305-938e-0840e2e84515`.

Sending by `channel_id` needs no Microsoft Graph permissions. Someone still installs your app in the team, so the organization's Teams settings must allow custom apps.

**4. Send to the channel**

Put the ids in `to.ms_teams` and send a template with a Teams channel.

```javascript Node.js highlight={4-8} theme={null}
const { requestId } = await courier.send.message({
  message: {
    to: {
      ms_teams: {
        channel_id: "19:5140d7460868414cac958ac76a0a94d0@thread.skype",
        tenant_id: "dabd1935-56a4-4305-938e-0840e2e84515",
        service_url: "https://smba.trafficmanager.net/amer",
      },
    },
    template: "nt_01kx4h2jdafq8bk9aftxak4b40",
  },
});
```

```python Python highlight={4-8} theme={null}
response = client.send.message(
    message={
        "to": {
            "ms_teams": {
                "channel_id": "19:5140d7460868414cac958ac76a0a94d0@thread.skype",
                "tenant_id": "dabd1935-56a4-4305-938e-0840e2e84515",
                "service_url": "https://smba.trafficmanager.net/amer",
            },
        },
        "template": "nt_01kx4h2jdafq8bk9aftxak4b40",
    },
)
```

```bash cURL highlight={7-11} wrap theme={null}
curl -X POST https://api.courier.com/send \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": {
      "to": {
        "ms_teams": {
          "channel_id": "19:5140d7460868414cac958ac76a0a94d0@thread.skype",
          "tenant_id": "dabd1935-56a4-4305-938e-0840e2e84515",
          "service_url": "https://smba.trafficmanager.net/amer"
        }
      },
      "template": "nt_01kx4h2jdafq8bk9aftxak4b40"
    }
  }'
```

```ruby Ruby highlight={4-8} theme={null}
response = courier.send_.message(
  message: {
    to: {
      ms_teams: {
        channel_id: "19:5140d7460868414cac958ac76a0a94d0@thread.skype",
        tenant_id: "dabd1935-56a4-4305-938e-0840e2e84515",
        service_url: "https://smba.trafficmanager.net/amer"
      }
    },
    template: "nt_01kx4h2jdafq8bk9aftxak4b40"
  }
)
```

```go Go highlight={4-8} theme={null}
// This provider addresses the recipient with fields outside the typed
// UserRecipient model, so pass the recipient as raw JSON.
to := param.Override[shared.UserRecipientParam](json.RawMessage(`{
  "ms_teams": {
    "channel_id": "19:5140d7460868414cac958ac76a0a94d0@thread.skype",
    "tenant_id": "dabd1935-56a4-4305-938e-0840e2e84515",
    "service_url": "https://smba.trafficmanager.net/amer"
  }
}`))

response, err := client.Send.Message(context.TODO(), courier.SendMessageParams{
	Message: courier.SendMessageParamsMessage{
		To: courier.SendMessageParamsMessageToUnion{OfUserRecipient: &to},
		Template: courier.String("nt_01kx4h2jdafq8bk9aftxak4b40"),
	},
})
```

```java Java highlight={6-10} theme={null}
SendMessageParams params = SendMessageParams.builder()
    .message(SendMessageParams.Message.builder()
        // This provider addresses the recipient with fields outside the
        // typed UserRecipient model, so pass them as additional properties.
        .to(UserRecipient.builder()
            .putAdditionalProperty("ms_teams", JsonValue.from(java.util.Map.of(
                "channel_id", "19:5140d7460868414cac958ac76a0a94d0@thread.skype",
                "tenant_id", "dabd1935-56a4-4305-938e-0840e2e84515",
                "service_url", "https://smba.trafficmanager.net/amer"
            )))
            .build())
        .template("nt_01kx4h2jdafq8bk9aftxak4b40")
        .build())
    .build();
SendMessageResponse response = client.send().message(params);
```

```php PHP highlight={4-8} theme={null}
$response = $client->send->message(
  message: [
    'to' => [
      'ms_teams' => [
        'channel_id' => '19:5140d7460868414cac958ac76a0a94d0@thread.skype',
        'tenant_id' => 'dabd1935-56a4-4305-938e-0840e2e84515',
        'service_url' => 'https://smba.trafficmanager.net/amer',
      ],
    ],
    'template' => 'nt_01kx4h2jdafq8bk9aftxak4b40',
  ],
);
```

```csharp C# highlight={11-15} theme={null}
SendMessageParams parameters = new()
{
    Message = new()
    {
        // This provider addresses the recipient with fields outside the
        // typed UserRecipient model, so build it from raw JSON.
        To = UserRecipient.FromRawUnchecked(
            JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(
                """
                {
                  "ms_teams": {
                    "channel_id": "19:5140d7460868414cac958ac76a0a94d0@thread.skype",
                    "tenant_id": "dabd1935-56a4-4305-938e-0840e2e84515",
                    "service_url": "https://smba.trafficmanager.net/amer"
                  }
                }
                """
            )
        ),
        Template = "nt_01kx4h2jdafq8bk9aftxak4b40",
    },
};

var response = await client.Send.Message(parameters);
```

```bash CLI highlight={3} wrap theme={null}
courier send message \
  --api-key "$COURIER_API_KEY" \
  --message.to '{"ms_teams": {"channel_id": "19:5140d7460868414cac958ac76a0a94d0@thread.skype", "tenant_id": "dabd1935-56a4-4305-938e-0840e2e84515", "service_url": "https://smba.trafficmanager.net/amer"}}' \
  --message.template nt_01kx4h2jdafq8bk9aftxak4b40
```

```text MCP theme={null}
With Courier MCP, send my template to the alerts channel in Microsoft Teams.
```

`service_url` defaults to `https://smba.trafficmanager.net/amer`, the Americas endpoint. Microsoft lists `https://smba.trafficmanager.net/teams` as its global endpoint, without a trailing slash, because Courier adds the path.

## Message a person instead

Swap the channel id for the person's `email`, and keep `tenant_id` and `service_url`:

```json Recipient theme={null}
{
  "ms_teams": {
    "email": "sarah@acme-corp.com",
    "tenant_id": "dabd1935-56a4-4305-938e-0840e2e84515",
    "service_url": "https://smba.trafficmanager.net/amer"
  }
}
```

Courier looks the person up through Microsoft Graph, so the bot's app registration needs Graph application permissions that an administrator grants. [Setup step 9](https://www.courier.com/docs/integrations/direct-message/microsoft-teams.md#setup) lists them. The person also needs your app installed for them, or membership in a team where it's installed.

To send to a `user_id` instead, store the `ms_teams` object on the user's profile once, as [Users](https://www.courier.com/docs/recipients/overview.md#what-each-channel-needs) explains.

## Verify

**1. Check the channel**

The message appears in the channel from your bot, with your app's name and icon.

**2. Read the status**

Open [Logs](https://app.courier.com/logs) and find the send. A credential or install problem shows as `All Bot Framework authentication methods failed`, followed by the HTTP status.

That error on a channel post usually means the app isn't installed in that team, or the credentials in Courier aren't the bot's. [Troubleshooting](https://www.courier.com/docs/integrations/direct-message/microsoft-teams.md#troubleshooting) covers the other causes.

## What changes in production

**Customers' organizations need one more field.** To post into a customer's Teams, send your bot's home tenant as `source_tenant_id` alongside their `tenant_id`. [Move off Teams Incoming Webhooks](https://www.courier.com/docs/guides/migrate/from-teams-incoming-webhooks.md#what-changes-in-production) covers collecting and storing each customer's ids.

**Client secrets expire.** Azure asks for an expiry date when you create the secret. Rotate it in Courier's Teams integration before that date, or every send fails with `Failed to acquire any Bot Framework authentication token`.

**Coming from an Incoming Webhook?** Microsoft retired Office 365 Connectors in May 2026. [Move off Teams Incoming Webhooks](https://www.courier.com/docs/guides/migrate/from-teams-incoming-webhooks.md) maps each webhook URL to a channel send.
