Twilio 7.1.1

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Twilio --version 7.1.1                
NuGet\Install-Package Twilio -Version 7.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Twilio" Version="7.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Twilio --version 7.1.1                
#r "nuget: Twilio, 7.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Twilio as a Cake Addin
#addin nuget:?package=Twilio&version=7.1.1

// Install Twilio as a Cake Tool
#tool nuget:?package=Twilio&version=7.1.1                

twilio-csharp

Test Quality Gate Status NuGet Learn with TwilioQuest

Twilio REST API and TwiML Libraries for .NET

Twilio provides a HTTP-based API for sending and receiving phone calls and text messages. Learn more on twilio.com.

More documentation for this library can be found here.

Versions

twilio-csharp uses a modified version of Semantic Versioning for all changes. See this document for details.

Migrate from earlier versions

See the migration guide here. Also, if you were using the Twilio.Mvc package, that has been replaced by the Twilio.AspNet.Mvc package which is compatible with this version of the library.

TLS 1.2 Requirements

New accounts and subaccounts are now required to use TLS 1.2 when accessing the REST API. "Upgrade Required" errors indicate that TLS 1.0/1.1 is being used. With .NET, you can enable TLS 1.2 using this setting:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Supported .NET versions

This library supports .NET applications that utilize .NET6+.

Installation

The best and easiest way to add the Twilio libraries to your .NET project is to use the NuGet package manager.

With Visual Studio IDE

From within Visual Studio, you can use the NuGet GUI to search for and install the Twilio NuGet package. Or, as a shortcut, simply type the following command into the Package Manager Console:

Install-Package Twilio

With .NET Core Command Line Tools

If you are building with the .NET Core command line tools, then you can run the following command from within your project directory:

dotnet add package Twilio

Sample usage

The examples below show how to have your application initiate and outbound phone call and send an SMS message using the Twilio .NET helper library:

TwilioClient.Init("ACCOUNT_SID", "AUTH_TOKEN");

var call = CallResource.Create(
    new PhoneNumber("+11234567890"),
    from: new PhoneNumber("+10987654321"),
    url: new Uri("https://my.twiml.here")
);
Console.WriteLine(call.Sid);

var message = MessageResource.Create(
    new PhoneNumber("+11234567890"),
    from: new PhoneNumber("+10987654321"),
    body: "Hello World!"
);
Console.WriteLine(message.Sid);

Specify Region and/or Edge

To take advantage of Twilio's Global Infrastructure, specify the target Region and/or Edge for the client:

TwilioClient.SetRegion("au1");
TwilioClient.SetEdge("sydney");

This will result in the hostname transforming from api.twilio.com to api.sydney.au1.twilio.com.

Enable debug logging

There are two ways to enable debug logging in the default HTTP client. You can create an environment variable called TWILIO_LOG_LEVEL and set it to debug or you can set the LogLevel variable on the client as debug:

TwilioClient.SetLogLevel("debug");

Handle exceptions

For an example on how to handle exceptions in this helper library, please see the Twilio documentation.

Generate TwiML

To control phone calls, your application needs to output TwiML.

// TwiML classes can be created as standalone elements
var gather = new Gather(numDigits: 1, action: new Uri("hello-monkey-handle-key.cshtml"), method: HttpMethod.Post)
    .Say("To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over.");

// Attributes can be set directly on the object
gather.Timeout = 100;
gather.MaxSpeechTime = 200

// Arbitrary attributes can be set by calling set/getOption
var dial = new Dial().SetOption("myAttribute", 200)
                     .SetOption("newAttribute", false);

// Or can be created and attached to a response directly using helper methods
var response = new VoiceResponse()
    .Say("Hello Monkey")
    .Play(new Uri("http://demo.twilio.com/hellomonkey/monkey.mp3"))
    .Append(gather)
    .Append(dial);

// Serialize the TwiML objects to XML string
Console.WriteLine(response);

/*
<?xml version="1.0" encoding="utf-8"?>
<Response>
  <Say>Hello Monkey</Say>
  <Play>http://demo.twilio.com/hellomonkey/monkey.mp3</Play>
  <Gather numDigits="1" action="hello-monkey-handle-key.cshtml" method="POST" timeout="100" maxSpeechTime="200">
    <Say>To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over.</Say>
  </Gather>
  <Dial myAttribute="200" newAttribute="false"></Dial>
</Response>
*/

Use a custom HTTP Client

To use a custom HTTP client with this helper library, please see the advanced example of how to do so.

Docker Image

The Dockerfile present in this repository and its respective twilio/twilio-csharp Docker image are used by Twilio for testing purposes.

You could use the docker image for building and running tests:

docker build -t twiliobuild .

Bash:

docker run -it --rm -v $(pwd):/twilio twiliobuild
make test

Powershell:

docker run -it --rm -v ${PWD}:/twilio twiliobuild
make test

Get support

If you need help installing or using the library, please check the Twilio Support Help Center first, and file a support ticket if you don't find an answer to your question.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (178)

Showing the top 5 NuGet packages that depend on Twilio:

Package Downloads
Twilio.AspNet.Core

Twilio helper library for ASP.NET Core

iRely.Common

iRely.Common

Twilio.AspNet.Mvc

Twilio helper library for ASP.NET MVC on .NET Framework.

Microsoft.Azure.WebJobs.Extensions.Twilio

This package contains binding extensions for Twilio.

DTF.Services

Abstractions and implementations of DTF services for integration

GitHub repositories (25)

Showing the top 5 popular GitHub repositories that depend on Twilio:

Repository Stars
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
Ombi-app/Ombi
Want a Movie or TV Show on Plex/Emby/Jellyfin? Use Ombi!
ONLYOFFICE/CommunityServer
Free open source office suite with business productivity tools: document and project management, CRM, mail aggregator.
phongnguyend/Practical.CleanArchitecture
Full-stack .Net 8 Clean Architecture (Microservices, Modular Monolith, Monolith), Blazor, Angular 18, React 18, Vue 3, BFF with YARP, Domain-Driven Design, CQRS, SOLID, Asp.Net Core Identity Custom Storage, OpenID Connect, Entity Framework Core, Selenium, SignalR, Hosted Services, Health Checks, Rate Limiting, Cloud Services (Azure, AWS, Google)...
ariacom/Seal-Report
Database Reporting Tool and Tasks (.Net)
Version Downloads Last updated
7.2.2 57,388 7/2/2024
7.2.1 15,133 6/27/2024
7.2.0 36,217 6/18/2024
7.1.1 65,917 6/6/2024
7.1.0 102,888 5/24/2024
7.0.5 296,990 4/18/2024
7.0.4 111,575 4/4/2024
7.0.3 31,509 4/1/2024
7.0.2 154,570 3/14/2024
7.0.1 23,763 3/12/2024
7.0.0 83,697 2/27/2024
7.0.0-rc.4 4,066 2/23/2024
7.0.0-rc.3 71 2/23/2024
7.0.0-rc.2 428 2/15/2024
7.0.0-rc.1 50,462 10/5/2023
6.18.0 229,551 2/9/2024
6.16.1 320,363 1/15/2024
6.15.2 433,886 12/5/2023
6.15.1 218,008 11/17/2023
6.15.0 171,221 11/8/2023
6.14.1 360,711 10/5/2023
6.14.0 152,159 9/21/2023
6.13.0 154,764 9/7/2023
6.11.0 347,950 8/10/2023
6.10.1 180,025 7/27/2023
6.10.0 179,776 7/13/2023
6.9.0 177,663 6/28/2023
6.8.0 187,672 6/15/2023
6.7.0 206,791 6/1/2023
6.6.1 174,076 5/18/2023
6.6.0 185,723 5/4/2023
6.5.0 288,035 4/20/2023
6.4.0 238,102 4/5/2023
6.3.0 363,914 3/23/2023
6.2.5 352,886 3/9/2023
6.2.4 942,360 2/22/2023
6.2.3 152,059 2/8/2023
6.2.2 279,743 1/25/2023
6.2.1 354,389 1/11/2023
6.2.0 306,029 12/14/2022
6.1.0 256,177 11/30/2022
6.0.1 482,144 11/16/2022
6.0.0-rc.3 793 11/10/2022
6.0.0-rc.2 1,167 10/31/2022
6.0.0-rc.1 1,419 10/20/2022
5.81.2 324,513 11/10/2022
5.81.1 173,517 10/31/2022
5.81.0 250,406 10/19/2022
5.80.1 390,937 10/5/2022
5.80.0 698,980 9/7/2022
5.79.0 230,522 8/24/2022
5.78.1 263,516 8/10/2022
5.78.0 467,817 7/21/2022
5.77.0 633,947 7/13/2022
5.76.0 437,939 6/29/2022
5.75.3 374,115 6/15/2022
5.75.2 221,823 6/1/2022
5.75.1 448,646 5/18/2022
5.75.0 364,255 5/4/2022
5.74.0 695,959 4/6/2022
5.73.0 657,869 3/23/2022
5.72.1 476,237 3/9/2022
5.72.0 372,705 2/23/2022
5.71.0 4,450,984 2/9/2022
5.70.1 549,848 1/26/2022
5.70.0 445,051 1/12/2022
5.69.0 662,794 12/15/2021
5.68.2 458,005 12/1/2021
5.68.1 686,720 11/17/2021
5.68.0 248,544 11/3/2021
5.67.0 282,456 10/18/2021
5.66.0 204,920 10/6/2021
5.65.3 322,531 9/22/2021
5.65.2 462,278 9/8/2021
5.65.0 568,525 8/11/2021
5.64.1 275,005 7/28/2021
5.64.0 284,024 7/14/2021
5.63.0 244,903 6/30/2021
5.62.0 304,421 6/16/2021
5.61.1 331,943 6/2/2021
5.61.0 179,808 5/19/2021
5.60.0 270,264 5/5/2021
5.59.0 205,208 4/21/2021
5.58.0 314,118 4/7/2021
5.57.0 517,833 3/24/2021
5.56.0 511,194 3/15/2021
5.55.0 346,363 2/24/2021
5.54.0 351,657 2/12/2021
5.53.1 507,619 1/27/2021
5.53.0 191,438 1/13/2021
5.52.1 734,166 12/16/2020
5.52.0 240,564 12/8/2020
5.51.0 148,621 12/2/2020
5.50.0 604,189 11/18/2020
5.49.0 324,436 11/5/2020
5.48.0 622,502 10/14/2020
5.47.2 444,405 9/28/2020
5.47.1 311,987 9/21/2020
5.47.0 63,503 9/16/2020
5.46.2 317,634 9/3/2020
5.46.1 11,761 9/2/2020
5.46.0 485,713 8/19/2020
5.45.2 321,032 8/5/2020
5.45.1 252,563 7/22/2020
5.45.0 875,368 7/8/2020
5.44.0 543,732 6/24/2020
5.43.0 324,585 6/10/2020
5.42.0 323,533 5/27/2020
5.41.1 406,591 5/20/2020
5.41.0 157,720 5/13/2020
5.40.0 295,015 4/29/2020
5.39.1 335,636 4/15/2020
5.39.0 405,005 4/1/2020
5.38.0 363,862 3/18/2020
5.37.6 399,994 3/4/2020
5.37.5 458,995 2/19/2020
5.37.4 336,032 2/5/2020
5.37.3 416,772 1/22/2020
5.37.2 1,225,725 1/8/2020
5.37.1 359,810 12/18/2019
5.37.0 104,727 12/12/2019
5.36.0 222,987 12/4/2019
5.35.1 355,532 11/13/2019
5.35.0 287,670 10/30/2019
5.34.0 143,935 10/16/2019
5.33.1 873,469 10/2/2019
5.33.0 346,305 9/18/2019
5.32.0 189,246 9/4/2019
5.31.4 251,543 8/21/2019
5.31.3 237,326 8/5/2019
5.31.2 101,105 7/24/2019
5.31.1 375,265 7/10/2019
5.31.0 231,262 6/26/2019
5.30.0 283,541 6/12/2019
5.29.1 207,076 5/29/2019
5.29.0 208,041 5/15/2019
5.28.4 171,037 5/1/2019
5.28.3 113,122 4/24/2019
5.28.2 132,721 4/12/2019
5.28.1 4,553 4/12/2019
5.28.0 1,032,638 3/28/2019
5.27.2 128,009 3/15/2019
5.27.1 725,219 3/7/2019
5.27.0 61,387 3/1/2019
5.26.1 169,959 2/16/2019
5.26.0 300,990 2/4/2019
5.25.1 627,165 1/11/2019
5.25.0 6,986 1/10/2019
5.24.1 292,001 1/2/2019
5.24.0 75,829 12/14/2018
5.23.0 201,579 11/30/2018
5.22.0 123,306 11/16/2018
5.21.0 167,426 10/28/2018
5.20.1 583,064 10/16/2018
5.20.0 18,664 10/15/2018
5.19.0 255,955 10/4/2018
5.18.0 28,860 10/2/2018
5.17.0 292,754 9/20/2018
5.16.4 129,460 9/7/2018
5.16.3 144,871 8/31/2018
5.16.2 96,499 8/23/2018
5.16.0 120,693 8/17/2018
5.15.1 80,333 8/9/2018
5.15.0 148,894 8/3/2018
5.14.1 108,270 7/27/2018
5.14.0 182,798 7/16/2018
5.13.8 45,878 7/11/2018
5.13.7 74,862 7/5/2018
5.13.6 34,000 6/29/2018
5.13.5 33,207 6/21/2018
5.13.4 41,100 6/15/2018
5.13.3 137,747 6/5/2018
5.13.2 72,024 5/25/2018
5.13.1 49,536 5/18/2018
5.13.0 279,205 5/11/2018
5.12.1 40,507 5/7/2018
5.12.0 42,815 4/27/2018
5.11.1 62,907 4/20/2018
5.11.0 29,896 4/13/2018
5.10.0 186,800 3/23/2018
5.9.8 88,697 3/10/2018
5.9.7 399,088 2/24/2018
5.9.6 96,113 2/10/2018
5.9.5 66,692 1/31/2018
5.9.4 65,445 1/22/2018
5.9.3 3,207 1/22/2018
5.9.2 299,639 12/16/2017
5.9.1 78,777 12/1/2017
5.9.0 281,554 11/17/2017
5.8.3 212,633 11/11/2017
5.8.2 121,298 11/3/2017
5.8.1 47,998 10/28/2017
5.8.0 84,040 10/20/2017
5.7.2 62,036 10/13/2017
5.7.1 34,550 10/6/2017
5.7.0 31,002 9/29/2017
5.6.5 88,606 9/16/2017
5.6.4 82,663 9/1/2017
5.6.3 261,322 8/25/2017
5.6.2 18,868 8/18/2017
5.6.1 30,350 8/11/2017
5.6.0 95,733 7/27/2017
5.5.3-alpha2 28,837 7/7/2017
5.5.3-alpha1 2,657 7/1/2017
5.5.2 70,680 7/1/2017
5.5.2-alpha1 3,484 6/16/2017
5.5.1 81,342 6/16/2017
5.5.1-alpha1 3,704 5/24/2017
5.5.0 145,402 5/24/2017
5.4.3-alpha1 2,492 5/22/2017
5.4.2 33,014 5/19/2017
5.4.2-alpha1 2,614 5/8/2017
5.4.1 111,480 5/8/2017
5.4.1-alpha1 4,589 4/27/2017
5.4.0 26,351 4/27/2017
5.4.0-alpha1 2,595 4/27/2017
5.3.1-alpha1 5,726 4/17/2017
5.3.0 54,939 4/17/2017
5.2.2-alpha1 2,581 4/13/2017
5.2.1 12,435 4/13/2017
5.2.1-alpha1 10,805 3/31/2017
5.2.0 41,438 3/31/2017
5.1.2-alpha1 2,957 3/21/2017
5.1.1 46,617 3/21/2017
5.1.1-alpha1 3,115 3/9/2017
5.1.0 69,561 3/9/2017
5.0.3-alpha1 2,767 2/24/2017
5.0.2 32,958 2/24/2017
5.0.2-alpha1 2,569 2/24/2017
5.0.1 8,810 2/24/2017
5.0.1-alpha1 2,742 2/22/2017
5.0.0 45,654 2/22/2017
5.0.0-rca4 22,182 2/14/2017
5.0.0-rca3 2,477 2/9/2017
5.0.0-rca2 6,741 12/8/2016
5.0.0-rca1 3,582 11/9/2016
5.0.0-rc9 2,667 11/3/2016
5.0.0-rc8 4,069 9/19/2016
5.0.0-rc7 2,515 9/15/2016
5.0.0-rc6 3,429 9/1/2016
5.0.0-rc4 4,641 7/8/2016
5.0.0-rc2 20,797 6/2/2016
5.0.0-rc10 2,580 11/4/2016
5.0.0-rc1 2,314 6/1/2016
5.0.0-alpha1 2,333 2/22/2017
4.7.2 3,294,773 5/23/2016
4.7.1 277,389 4/5/2016
4.7.0 107,785 3/16/2016
4.5.0 386,405 2/5/2016
4.4.1 304,363 11/26/2015
4.4.0 23,556 11/12/2015
4.4.0-edge 2,421 11/12/2015
4.3.0 17,821 11/11/2015
4.2.1 59,636 10/30/2015
4.2.0 3,024 10/30/2015
4.1.0 187,583 9/24/2015
4.0.51 158,047 8/24/2015
4.0.5 201,305 8/20/2015
4.0.4 33,762 8/12/2015
4.0.3 220,061 5/21/2015
4.0.2 4,330 5/19/2015
4.0.1 6,225 5/14/2015
4.0.0 37,257 4/28/2015
3.8.45-beta 3,120 3/19/2015
3.8.44-beta 2,352 3/19/2015
3.8.40-beta 2,451 3/6/2015
3.8.30-beta 2,422 3/5/2015
3.8.29-beta 2,378 3/5/2015
3.8.28-beta 2,294 3/5/2015
3.8.26-beta 2,386 3/5/2015
3.8.18-beta 3,651 12/19/2014
3.7.55-alpha 7,704 6/4/2014
3.7.54-alpha 2,437 6/4/2014
3.7.53-alpha 2,461 6/4/2014
3.7.51-alpha 2,445 6/4/2014
3.7.50-alpha 2,514 6/4/2014
3.7.48-alpha 2,529 6/4/2014
3.7.46-alpha 2,421 6/4/2014
3.7.45-alpha 2,471 6/4/2014
3.7.44-alpha 2,482 6/4/2014
3.7.43-alpha 2,506 5/31/2014
3.7.40-alpha 2,451 5/31/2014
3.7.39-alpha 2,445 5/31/2014
3.7.38-alpha 2,435 5/31/2014
3.7.37-alpha 2,427 5/30/2014
3.7.35-alpha 2,435 5/30/2014
3.6.29 52,668 4/7/2015
3.6.28 3,221 4/7/2015
3.6.27 80,486 2/26/2015
3.6.26 35,595 2/19/2015
3.6.25 121,840 12/7/2014
3.6.24 23,308 11/14/2014
3.6.23 8,254 11/5/2014
3.6.22 3,444 11/5/2014
3.6.20 38,509 10/10/2014
3.6.19 2,995 10/10/2014
3.6.18 70,164 9/29/2014
3.6.17 26,349 8/28/2014
3.6.16 180,229 5/29/2014
3.6.15 3,892 5/27/2014
3.6.11 93,863 1/25/2014
3.6.10 24,922 11/20/2013
3.6.9 31,297 11/4/2013
3.6.8 3,087 11/4/2013
3.6.7 3,060 11/4/2013
3.6.6 3,036 11/4/2013
3.6.5 21,918 10/21/2013
3.6.4 7,533 10/7/2013
3.6.3 3,864 10/3/2013
3.6.2 5,343 9/30/2013
3.6.1 40,012 9/18/2013
3.5.17 77,033 7/31/2013
3.5.16 5,078 7/20/2013
3.5.15 7,833 7/13/2013
3.5.14 6,536 6/19/2013
3.5.12 10,509 4/10/2013
3.5.11 3,102 4/9/2013
3.5.10 4,132 4/5/2013
3.5.9 3,427 4/4/2013
3.5.8 4,193 3/18/2013
3.5.6 14,974 12/17/2012
3.5.5 10,433 10/25/2012
3.5.4 3,228 10/24/2012
3.5.3 3,752 10/17/2012
3.5.2 3,133 10/17/2012
3.5.1 5,406 8/31/2012
3.5.0 3,955 8/20/2012
3.4.5 7,981 7/12/2012
3.4.4 3,145 7/12/2012
3.4.3 3,274 7/9/2012
3.4.2 18,475 4/18/2012
3.4.1 47,945 4/18/2012
3.4.0 8,974 3/21/2012
3.3.7 3,903 2/15/2012
3.3.6 3,706 2/15/2012
3.3.5 3,142 2/15/2012
3.3.4 3,268 2/7/2012
3.3.3 3,134 2/6/2012
3.3.2 4,365 11/18/2011
3.3.1 3,255 11/18/2011
3.2.3 3,421 10/19/2011
3.2.2 3,333 10/11/2011
3.2.1 3,405 9/28/2011
3.2.0 3,409 9/21/2011
3.1.4 3,381 8/26/2011
3.1.3 3,324 8/9/2011
3.1.0 5,030 7/26/2011
3.0.1 3,731 7/20/2011
3.0.0 71,997 7/17/2011
2.0.2 38,135 1/31/2011