> ## 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`, the default import of the v7 Node SDK. 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.
> 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.
> 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 SMS with MessageMedia through Courier

> Connect MessageMedia with an API key and secret, and receive delivery status by webhook.

export const Doc = ({href, children, name, bare}) => {
  const label = children || name || href;
  if (bare) {
    return <a href={href}>{label}</a>;
  }
  return <a className="cx-endpoint" data-kind="doc" href={href}>
      <span className="cx-endpoint-label">{label}</span>
      <span className="cx-endpoint-method">DOC</span>
    </a>;
};

export const AppLink = ({href, children, name, bare}) => {
  const label = children || name || "Open in Courier";
  if (bare) {
    return <a href={href} target="_blank" rel="noreferrer">{label}</a>;
  }
  return <a className="cx-endpoint" data-kind="app" href={href} target="_blank" rel="noreferrer">
      <span className="cx-endpoint-label">{label}</span>
      <span className="cx-endpoint-method" aria-hidden="true">↗</span>
    </a>;
};

## Prerequisites

* [A MessageMedia account](https://hub.messagemedia.com/)
* Access to API settings in the MessageMedia console

## Setup

In the [MessageMedia console](https://hub.messagemedia.com/api-settings):

<Steps>
  <Step title="Create a new API key">
    Create a new API key.
  </Step>

  <Step title="Copy the API key and secret">
    Save the `api_secret` now. MessageMedia will not show it again.
  </Step>
</Steps>

In Courier, open the <AppLink href="https://app.courier.com/integrations/catalog/messagemedia">MessageMedia Integration</AppLink> page, paste your credentials, and click "Save."

<Frame caption="MessageMedia API Key">
  <img src="https://mintcdn.com/courier-4f1f25dc/xDJPBS8EQ58X_0-v/assets/messagemedia-api-key.webp?fit=max&auto=format&n=xDJPBS8EQ58X_0-v&q=85&s=a6004550a4056061e6e0f316720f2ed0" width="2410" height="924" data-path="assets/messagemedia-api-key.webp" />
</Frame>

Addressing a recipient and sending are the same on every SMS provider, so they are documented once: <Doc href="/docs/integrations/sms/overview#profile-requirements">profile requirements</Doc> and <Doc href="/docs/integrations/sms/overview#send-to-a-recipient">send to a recipient</Doc>.

## Overrides

<Doc href="/docs/send/overrides#how-overrides-work">How overrides work</Doc> covers the two levels and which one wins.

Overrides change the request body, config, and headers Courier sends to MessageMedia. Override `apiKey`, `apiSecret`, `isHmacEnabled`, and `url` via `config`, and any [SendMessages](https://messagemedia.github.io/documentation/#operation/SendMessages) body field via `body`.

<CodeGroup>
  ```javascript Node.js highlight={8-18} theme={null}
  const { requestId } = await courier.send.message({
    message: {
      template: "nt_01kx4h2jdafq8bk9aftxak4b40",
      to: {
        phone_number: "+12345678901",
      },
      providers: {
        messagemedia: {
          override: {
            body: {
              source_number: "+15555555555",
            },
            config: {
              apiKey: "<override API key>",
              apiSecret: "<override API secret>",
            },
          },
        },
      },
    },
  });
  ```

  ```python Python highlight={8-18} theme={null}
  response = client.send.message(
      message={
          "template": "nt_01kx4h2jdafq8bk9aftxak4b40",
          "to": {
              "phone_number": "+12345678901",
          },
          "providers": {
              "messagemedia": {
                  "override": {
                      "body": {
                          "source_number": "+15555555555",
                      },
                      "config": {
                          "apiKey": "<override API key>",
                          "apiSecret": "<override API secret>",
                      },
                  },
              },
          },
      },
  )
  ```

  ```bash cURL highlight={11-21} wrap theme={null}
  curl -X POST https://api.courier.com/send \
    -H "Authorization: Bearer $COURIER_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "message": {
        "template": "nt_01kx4h2jdafq8bk9aftxak4b40",
        "to": {
          "phone_number": "+12345678901"
        },
        "providers": {
          "messagemedia": {
            "override": {
              "body": {
                "source_number": "+15555555555"
              },
              "config": {
                "apiKey": "<override API key>",
                "apiSecret": "<override API secret>"
              }
            }
          }
        }
      }
    }'
  ```

  ```ruby Ruby highlight={8-18} theme={null}
  response = courier.send_.message(
    message: {
      template: "nt_01kx4h2jdafq8bk9aftxak4b40",
      to: {
        phone_number: "+12345678901"
      },
      providers: {
        messagemedia: {
          override: {
            body: {
              source_number: "+15555555555"
            },
            config: {
              apiKey: "<override API key>",
              apiSecret: "<override API secret>"
            }
          }
        }
      }
    }
  )
  ```

  ```go Go highlight={10-20} theme={null}
  response, err := client.Send.Message(context.TODO(), courier.SendMessageParams{
  	Message: courier.SendMessageParamsMessage{
  		To: courier.SendMessageParamsMessageToUnion{
  			OfUserRecipient: &shared.UserRecipientParam{
  				PhoneNumber: courier.String("+12345678901"),
  			},
  		},
  		Template: courier.String("nt_01kx4h2jdafq8bk9aftxak4b40"),
  		Providers: shared.MessageProvidersParam{
  			"messagemedia": shared.MessageProvidersTypeParam{
  				Override: map[string]any{
  					"body": map[string]any{
  						"source_number": "+15555555555",
  					},
  					"config": map[string]any{
  						"apiKey": "<override API key>",
  						"apiSecret": "<override API secret>",
  					},
  				},
  			},
  		},
  	},
  })
  ```

  ```java Java highlight={6-14} theme={null}
  SendMessageParams params = SendMessageParams.builder()
      .message(SendMessageParams.Message.builder()
          .to(UserRecipient.builder().phoneNumber("+12345678901").build())
          .template("nt_01kx4h2jdafq8bk9aftxak4b40")
          .providers(MessageProviders.builder()
              .putAdditionalProperty("messagemedia", JsonValue.from(java.util.Map.of("override", java.util.Map.of(
                      "body", java.util.Map.of(
                          "source_number", "+15555555555"
                      ),
                      "config", java.util.Map.of(
                          "apiKey", "<override API key>",
                          "apiSecret", "<override API secret>"
                      )
                  ))))
              .build())
          .build())
      .build();
  SendMessageResponse response = client.send().message(params);
  ```

  ```php PHP highlight={8-18} theme={null}
  $response = $client->send->message(
    message: [
      'template' => 'nt_01kx4h2jdafq8bk9aftxak4b40',
      'to' => [
        'phone_number' => '+12345678901',
      ],
      'providers' => [
        'messagemedia' => [
          'override' => [
            'body' => [
              'source_number' => '+15555555555',
            ],
            'config' => [
              'apiKey' => '<override API key>',
              'apiSecret' => '<override API secret>',
            ],
          ],
        ],
      ],
    ],
  );
  ```

  ```csharp C# highlight={9-27} theme={null}
  SendMessageParams parameters = new()
  {
      Message = new()
      {
          To = new UserRecipient { PhoneNumber = "+12345678901" },
          Template = "nt_01kx4h2jdafq8bk9aftxak4b40",
          Providers = new Dictionary<string, MessageProvidersType>()
          {
              {
                  "messagemedia",
                  new()
                  {
                      Override = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(
                          """
                          {
                            "body": {
                              "source_number": "+15555555555"
                            },
                            "config": {
                              "apiKey": "<override API key>",
                              "apiSecret": "<override API secret>"
                            }
                          }
                          """
                      ),
                  }
              },
          },
      },
  };

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

  ```bash CLI highlight={5} wrap theme={null}
  courier send message \
    --api-key "$COURIER_API_KEY" \
    --message.to '{"phone_number": "+12345678901"}' \
    --message.template nt_01kx4h2jdafq8bk9aftxak4b40 \
    --message.providers '{"messagemedia": {"override": {"body": {"source_number": "+15555555555"}, "config": {"apiKey": "<override API key>", "apiSecret": "<override API secret>"}}}}'
  ```

  ```text MCP theme={null}
  With Courier MCP, send my template to +12345678901 through MessageMedia with a different API key.
  ```
</CodeGroup>

## Delivery tracking

Courier gives the integration a unique webhook URL. Point [MessageMedia webhooks](https://support.messagemedia.com/hc/en-us/articles/4413634024463-Webhooks) at it to sync delivery updates into Courier's message logs.

Copy the URL from the <AppLink href="https://app.courier.com/integrations">MessageMedia integration</AppLink> in Courier, then follow these steps in the [MessageMedia console](https://hub.messagemedia.com/api-settings):

<Steps>
  <Step title="Create a new webhook">
    Select "New Webhook".
  </Step>

  <Step title="Paste Courier's webhook URL">
    Paste the URL you copied.
  </Step>

  <Step title="Select the delivery report events">
    Under "Event", select "Message is rejected", "Message has failed", and "Message is delivered" in Delivery reports.

    <Frame caption="MessageMedia Webhook Configuration">
      <img src="https://mintcdn.com/courier-4f1f25dc/xDJPBS8EQ58X_0-v/assets/messagemedia-webhook-event.webp?fit=max&auto=format&n=xDJPBS8EQ58X_0-v&q=85&s=49c496518e3494e073dff6f5422ec8a5" width="1672" height="1270" data-path="assets/messagemedia-webhook-event.webp" />
    </Frame>
  </Step>

  <Step title="Map the webhook content">
    Under "Content", map the fields passed to Courier's webhook endpoint.

    <Note>Only `messageId`, `receivedTimestamp`, `status`, and `statusCode` are supported.</Note>

    <Frame caption="Webhook Content Mapping">
      <img src="https://mintcdn.com/courier-4f1f25dc/xDJPBS8EQ58X_0-v/assets/messagemedia-webhook-content.webp?fit=max&auto=format&n=xDJPBS8EQ58X_0-v&q=85&s=61c439bf3baab724e1f9d75fbfce9646" width="1574" height="1076" data-path="assets/messagemedia-webhook-content.webp" />
    </Frame>
  </Step>
</Steps>

Delivery updates now appear in the message logs.

<Frame caption="Delivery Confirmation">
  <img src="https://mintcdn.com/courier-4f1f25dc/xDJPBS8EQ58X_0-v/assets/messagemedia-log.webp?fit=max&auto=format&n=xDJPBS8EQ58X_0-v&q=85&s=d003d59fbd438fd61ea104e5b2a9a323" width="1820" height="1230" data-path="assets/messagemedia-log.webp" />
</Frame>

## Provider details

```text theme={null}
messagemedia
```

Courier recommends routing to the channel. Naming this key in `routing.channels` instead is supported, and sends through just this provider.

<Card title="Send to a specific provider" icon="bullseye-arrow" href="/docs/send/send-to-a-provider" horizontal arrow="true">
  When that is worth doing, and what you give up: failover, channel priority, and providers you add later.
</Card>
