How to Send SMS without a Phone Number using C# .NET and an Alphanumeric Sender ID
Tags: dotnet, csharp, twilio, sms
Published: 2022-06-27 19:22:45

---
title: How to Send SMS without a Phone Number using C# .NET and an Alphanumeric Sender ID
published: true
date: 2022-04-05 00:00:00 UTC
tags: dotnet, csharp, twilio, sms
canonical_url: https://www.twilio.com/blog/sms-without-a-phone-number-using-csharp-dotnet-alpha-sender
cover_image: https://swimburger.net/media/zgnhbcf4/send-sms-without-a-phone-number-using-c-and-alphanumeric-sender-id.png?anchor=center&mode=crop&width=1000&height=420
---

**This blog post was written for [Twilio](https://www.twilio.com/) and [originally published at the Twilio blog](https://www.twilio.com/blog/sms-without-a-phone-number-using-csharp-dotnet-alpha-sender).**

You can quickly buy a phone number using [Twilio's Super Network](https://www.twilio.com/super-network) and then use that phone number to send and receive SMS. However, not all applications require two-way messaging. What's more, there are a lot of use cases where one-way messaging is a better fit, for example: notifications, alerts, and verifications. For these kinds of scenarios, you should consider using an [Alphanumeric Sender ID](https://support.twilio.com/hc/en-us/articles/223181348-Alphanumeric-Sender-ID-for-Twilio-Programmable-SMS?_ga=2.235878593.199847990.1647869860-1014739719.1646940485). 

In this tutorial, you will learn how to send SMS messages from an Alphanumeric Sender ID with C#, .NET, and [Twilio Programmable SMS](https://www.twilio.com/sms); but first…

## What is an Alphanumeric Sender ID

An Alphanumeric Sender ID (or Alpha Sender) lets you send SMS messages from a sender ID that consists of a set of alphanumeric characters, instead of from a phone number.

The biggest benefit of using Alpha Sender is that you can use an ID that is more recognizable to your users than a phone number. The example below shows how an Alpha Sender (AUTHMSG) would look instead of the standard number. 

![Two SMS conversations side-by-side. The SMS on the left originate from a phone number and the conversation on the right originates from an Alphanumeric Sender ID "AUTHMSG"](https://twilio-cms-prod.s3.amazonaws.com/images/KlD7ETEkQfGQtQIzEkxIDbO-SbTeqi5H6LtqWZJAKkaQrg.width-500.png)

There are a couple of things you should know about Alpha Sender:

- The ID can contain up to 11 characters, composed of upper and lower case letters (A-Z), numbers (0-9), and spaces.
- A single Alpha Sender can be used across many countries without needing a dedicated phone number for each — but [not all countries support Alpha Sender, and some countries require pre-registration](https://support.twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID).
- Recipients cannot respond to an SMS sent from an Alpha Sender, making it a one-way conversation from the Alpha Sender to the recipient.

For other benefits, limitations, and guidance, read the [support article about Alphanumeric Sender ID for Twilio Programmable SMS](https://support.twilio.com/hc/en-us/articles/223181348-Alphanumeric-Sender-ID-for-Twilio-Programmable-SMS#h_01F4SJZWGMP5RVAJ254VX63A26)

## Prerequisites

You will need these things to follow along with this tutorial:

- An OS that supports .NET (Windows/macOS/Linux)
- [.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
- A code editor or IDE (I recommend [VS Code](https://code.visualstudio.com/Download) with [the C# plugin](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp), [Visual Studio](https://visualstudio.microsoft.com/), or [JetBrains Rider](https://www.jetbrains.com/rider/))
- A free or paid Twilio account (If you [register here](https://www.twilio.com/referral/OhKZOM), you'll receive $10 in Twilio credit when you upgrade to a paid account!)
- A phone number from [a country that supports Alphanumeric Sender IDs](https://support.twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID), to test your application

You can find [the source code for this tutorial on GitHub](https://github.com/Swimburger/SmsWithAlphanumericSender). Use it if you run into any issues, or [submit an issue](https://github.com/Swimburger/SmsWithAlphanumericSender/issues) if you run into problems.

## Configure an Alphanumeric Sender ID in Twilio

The recommended way to send SMS from an Alpha Sender is to use a Messaging Service in Twilio. To create a Messaging Service, log into the [Twilio Console](https://console.twilio.com/) and click Explore Products in the left hand side navigation menu. On the **Explore Products** page, find and click the **Messaging** product. Then, in the left hand side navigation menu, click on **Services** under the **Messaging** submenu. On the **Messaging Services** page, click **Create Messaging Service** which leads you to a multi-step wizard. 

On **Step 1** , enter a meaningful name into the **Messaging Service friendly name** , and click **Create Messaging Service**. 

![Step 1 "Create Messaging Service" of the Messaging Service Setup wizard. This step has a form with one required field: Messaging Service friendly name. There"s a "Create Messaging Service" button which takes you to the next step.](https://twilio-cms-prod.s3.amazonaws.com/images/cUoTbdLJ2j9hDvXGGU3O6x8avquA6kz__4-gsq42fHs15G.width-500.png)

On **Step 2** , select the " **Alpha Sender**" option for the **Sender Type** dropdown, and click **Continue**. Next, enter your desired ID into the **Alpha Sender ID** field. This will be the ID shown to the recipient instead of a phone number.

![A form to add an Alphanumeric Sender ID to the senders of a messaging service. The form contains one required field, the Alpha Sender ID field.](https://twilio-cms-prod.s3.amazonaws.com/images/kV78dXJxWY-DGM5KbwQ6PSqRD3nep0SbEtSf0KBGODNmXU.width-500.png)

Click **Add Alpha Sender** and then click " **Step 3: Set up integration**". 

**Step 3** lets you configure how to handle incoming messages. Alpha Senders can't receive messages so you can ignore this step and go to " **Step 4: Add compliance info**".

In **Step 4** , follow the described steps to add compliance info, if required for your use-case. 

Finally, click **Complete Messaging Service Setup**. 

You will be prompted to test from the console; you can also get to this by navigating the console menus: Messaging > Try it out > Send an SMS.You may see a warning message that no phone numbers are configured for this messaging service, which you can safely ignore.

There will be a cURL command that you can copy/paste to your terminal. If you use the test interface or the cURL command to send an SMS to your phone number, you should receive an SMS from your Alpha Sender ID. Notice that you can't reply.

## Get Your Twilio Configuration

You'll need some configuration elements from Twilio to send text messages from C#. Back in the Twilio Console, click on the Properties link under your Messaging Service in the left navigation menu, then take note of your **Messaging Service SID**. You will need it later.

Then, click on your account link on the top left to navigate back to the [Twilio Console start page](https://console.twilio.com/), and take note of your Twilio **Account SID** and **Auth Token** located at the bottom left of the page.

![Account Info box holding 3 read-only fields: Account SID field, Auth Token field, and Twilio phone number field.](https://twilio-cms-prod.s3.amazonaws.com/images/Ih_CdK3onrB1OkV7owrWiio0nnolVSR_ohXTXbMYkYfT1h.width-500.png)

You need to configure this Twilio configuration as environment variables because the project will need them. Open your preferred shell, and set these environment variables using the following commands. 

If you're using **Bash** or a similar shell:

```bash
export ToPhoneNumber=[RECIPIENT_PHONE_NUMBER]
export TwilioAccountSid=[TWILIO_ACCOUNT_SID]
export TwilioAuthToken=[TWILIO_AUTH_TOKEN]
export TwilioMessagingServiceSid=[TWILIO_MESSAGING_SERVICE_SID]
```

If you're using PowerShell:

```powershell
$Env:ToPhoneNumber = "[RECIPIENT_PHONE_NUMBER]"
$Env:TwilioAccountSid = "[TWILIO_ACCOUNT_SID]"
$Env:TwilioAuthToken = "[TWILIO_AUTH_TOKEN]"
$Env:TwilioMessagingServiceSid = "[TWILIO_MESSAGING_SERVICE_SID]"
```

If you're using CMD:

```bash
set "ToPhoneNumber=[RECIPIENT_PHONE_NUMBER]"
set "TwilioAccountSid=[TWILIO_ACCOUNT_SID]"
set "TwilioAuthToken=[TWILIO_AUTH_TOKEN]"
set "TwilioMessagingServiceSid=[TWILIO_MESSAGING_SERVICE_SID]"
```

In each case:

- Replace `[RECIPIENT_PHONE_NUMBER]` with the phone number you want to text. This phone number has to be from a [country that supports Alphanumeric Sender IDs](https://support.twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID). If you're sending a text to a number in another country, make sure to [enable the country in the Messaging Geographic Permissions](https://www.twilio.com/console/sms/settings/geo-permissions).
- Replace `[TWILIO_ACCOUNT_SID]`, `[TWILIO_AUTH_TOKEN]`, and `[TWILIO_MESSAGING_SERVICE_SID]` with the Account SID, **Auth Token** , and **Messaging Service SID** you took note of earlier.

## Send SMS from Alphanumeric Sender ID with C# and .NET

With that configuration done, it's time to write some C# code! and create a new console project using the .NET CLI, by running the following command:

```bash
dotnet new console -o SendAlphaSms
```

This will create a new console project in a new folder named _SendAlphaSms_. Navigate to the _SendAlphaSms_ folder by running the following command:

```bash
cd SendAlphaSms
```

The best way to start using Twilio in .NET is to add the [Twilio SDK for C# and .NET](https://www.twilio.com/docs/libraries/csharp-dotnet). Add the [Twilio NuGet package](https://www.nuget.org/packages/Twilio) using the .NET CLI:

```bash
dotnet add package Twilio
```

Open the project in your preferred .NET editor and open the _Program.cs_ file. Then, replace the existing code with the following:

```csharp
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

var toPhoneNumber = Environment.GetEnvironmentVariable("ToPhoneNumber");
var twilioAccountSid = Environment.GetEnvironmentVariable("TwilioAccountSid");
var twilioAuthToken = Environment.GetEnvironmentVariable("TwilioAuthToken");
var twilioMessagingServiceSid = Environment.GetEnvironmentVariable("TwilioMessagingServiceSid");

// authenticate with Twilio
TwilioClient.Init(twilioAccountSid, twilioAuthToken);

// send SMS using a Messaging Service
MessageResource.Create(
        to: new PhoneNumber(toPhoneNumber),
        messagingServiceSid: twilioMessagingServiceSid,
        body: "Hello from your Alpha sender 👏"
);
```

The code grabs the configuration from the environment variables, then authenticates with Twilio, and finally sends an SMS using your Messaging Service, which will use your Alpha Sender.

Try it out by running the application using the .NET CLI:

```bash
dotnet run
```

If you entered your phone number, you will now receive a text message from your Alpha Sender! Great job 🎉

## Next steps

Congratulations on learning how to send SMS from an Alpha Sender with .NET and C#! If you run into any problems, you can refer to the [source code for this tutorial on GitHub](https://github.com/Swimburger/SmsWithAlphanumericSender), or you can submit an issue on the GitHub repository. In addition to the above sample code, the source code also contains a sample for sending SMS from an Alpha Sender without a Messaging Service. 

We can't wait to see what you'll build with Twilio and Alphanumeric Sender IDs!