> ## 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 Telnyx through Courier

> Connect Telnyx with an API key and messaging profile, then override body and headers per send.

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 Telnyx account](https://telnyx.com/)
* Your Telnyx API key
* An SMS-capable phone number in Telnyx

## Setup

<Steps>
  <Step title="Create a Telnyx API key">
    In Telnyx, open [API keys](https://portal.telnyx.com/#/app/api-keys) and create a key.
  </Step>

  <Step title="Configure in Courier">
    Open the <AppLink href="https://app.courier.com/integrations/catalog/telnyx">Telnyx Integration</AppLink> in Courier, enter your API key and originating phone number, then click "Save."
  </Step>
</Steps>

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 Courier sends to Telnyx. You can override any field the outgoing call supports:

<CodeGroup>
  ```javascript Node.js highlight={11-23} theme={null}
  const { requestId } = await courier.send.message({
    message: {
      template: "nt_01kx4h2jdafq8bk9aftxak4b40",
      to: {
        phone_number: "+15551734686",
      },
      data: {
        name: "Sarah Bennett",
      },
      providers: {
        telnyx: {
          override: {
            body: {
              text: "Override message text",
              to: "+17777777777",
            },
            config: {
              apiKey: "<your API Key>",
              from: "+15555555555",
              url: "<alternate url>",
            },
          },
        },
      },
    },
  });
  ```

  ```python Python highlight={11-23} theme={null}
  response = client.send.message(
      message={
          "template": "nt_01kx4h2jdafq8bk9aftxak4b40",
          "to": {
              "phone_number": "+15551734686",
          },
          "data": {
              "name": "Sarah Bennett",
          },
          "providers": {
              "telnyx": {
                  "override": {
                      "body": {
                          "text": "Override message text",
                          "to": "+17777777777",
                      },
                      "config": {
                          "apiKey": "<your API Key>",
                          "from": "+15555555555",
                          "url": "<alternate url>",
                      },
                  },
              },
          },
      },
  )
  ```

  ```bash cURL highlight={14-26} 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": "+15551734686"
        },
        "data": {
          "name": "Sarah Bennett"
        },
        "providers": {
          "telnyx": {
            "override": {
              "body": {
                "text": "Override message text",
                "to": "+17777777777"
              },
              "config": {
                "apiKey": "<your API Key>",
                "from": "+15555555555",
                "url": "<alternate url>"
              }
            }
          }
        }
      }
    }'
  ```

  ```ruby Ruby highlight={11-23} theme={null}
  response = courier.send_.message(
    message: {
      template: "nt_01kx4h2jdafq8bk9aftxak4b40",
      to: {
        phone_number: "+15551734686"
      },
      data: {
        name: "Sarah Bennett"
      },
      providers: {
        telnyx: {
          override: {
            body: {
              text: "Override message text",
              to: "+17777777777"
            },
            config: {
              apiKey: "<your API Key>",
              from: "+15555555555",
              url: "<alternate url>"
            }
          }
        }
      }
    }
  )
  ```

  ```go Go highlight={13-25} theme={null}
  response, err := client.Send.Message(context.TODO(), courier.SendMessageParams{
  	Message: courier.SendMessageParamsMessage{
  		To: courier.SendMessageParamsMessageToUnion{
  			OfUserRecipient: &shared.UserRecipientParam{
  				PhoneNumber: courier.String("+15551734686"),
  			},
  		},
  		Template: courier.String("nt_01kx4h2jdafq8bk9aftxak4b40"),
  		Data: map[string]any{
  			"name": "Sarah Bennett",
  		},
  		Providers: shared.MessageProvidersParam{
  			"telnyx": shared.MessageProvidersTypeParam{
  				Override: map[string]any{
  					"body": map[string]any{
  						"text": "Override message text",
  						"to": "+17777777777",
  					},
  					"config": map[string]any{
  						"apiKey": "<your API Key>",
  						"from": "+15555555555",
  						"url": "<alternate url>",
  					},
  				},
  			},
  		},
  	},
  })
  ```

  ```java Java highlight={9-19} theme={null}
  SendMessageParams params = SendMessageParams.builder()
      .message(SendMessageParams.Message.builder()
          .to(UserRecipient.builder().phoneNumber("+15551734686").build())
          .template("nt_01kx4h2jdafq8bk9aftxak4b40")
          .data(JsonValue.from(java.util.Map.of(
              "name", "Sarah Bennett"
          )))
          .providers(MessageProviders.builder()
              .putAdditionalProperty("telnyx", JsonValue.from(java.util.Map.of("override", java.util.Map.of(
                      "body", java.util.Map.of(
                          "text", "Override message text",
                          "to", "+17777777777"
                      ),
                      "config", java.util.Map.of(
                          "apiKey", "<your API Key>",
                          "from", "+15555555555",
                          "url", "<alternate url>"
                      )
                  ))))
              .build())
          .build())
      .build();
  SendMessageResponse response = client.send().message(params);
  ```

  ```php PHP highlight={11-23} theme={null}
  $response = $client->send->message(
    message: [
      'template' => 'nt_01kx4h2jdafq8bk9aftxak4b40',
      'to' => [
        'phone_number' => '+15551734686',
      ],
      'data' => [
        'name' => 'Sarah Bennett',
      ],
      'providers' => [
        'telnyx' => [
          'override' => [
            'body' => [
              'text' => 'Override message text',
              'to' => '+17777777777',
            ],
            'config' => [
              'apiKey' => '<your API Key>',
              'from' => '+15555555555',
              'url' => '<alternate url>',
            ],
          ],
        ],
      ],
    ],
  );
  ```

  ```csharp C# highlight={13-33} theme={null}
  SendMessageParams parameters = new()
  {
      Message = new()
      {
          To = new UserRecipient { PhoneNumber = "+15551734686" },
          Template = "nt_01kx4h2jdafq8bk9aftxak4b40",
          Data = new Dictionary<string, JsonElement>()
          {
              { "name", JsonSerializer.SerializeToElement("Sarah Bennett") },
          },
          Providers = new Dictionary<string, MessageProvidersType>()
          {
              {
                  "telnyx",
                  new()
                  {
                      Override = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(
                          """
                          {
                            "body": {
                              "text": "Override message text",
                              "to": "+17777777777"
                            },
                            "config": {
                              "apiKey": "<your API Key>",
                              "from": "+15555555555",
                              "url": "<alternate url>"
                            }
                          }
                          """
                      ),
                  }
              },
          },
      },
  };

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

  ```bash CLI highlight={6} wrap theme={null}
  courier send message \
    --api-key "$COURIER_API_KEY" \
    --message.to '{"phone_number": "+15551734686"}' \
    --message.template nt_01kx4h2jdafq8bk9aftxak4b40 \
    --message.data '{"name": "Sarah Bennett"}' \
    --message.providers '{"telnyx": {"override": {"body": {"text": "Override message text", "to": "+17777777777"}, "config": {"apiKey": "<your API Key>", "from": "+15555555555", "url": "<alternate url>"}}}}'
  ```

  ```text MCP theme={null}
  With Courier MCP, send my template to +15551734686 through Telnyx with the body overridden.
  ```
</CodeGroup>

Override fields are merged at the top level of the request, so each key you set replaces that key outright rather than merging into it. `override.headers` and `override.config.url` are honored too. The full field list is in the [Telnyx Messaging API docs](https://developers.telnyx.com/api/messaging/send-message).

## Provider details

```text theme={null}
telnyx
```

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>
