Twilio 7.1.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
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 (176)

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 The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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 17, 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.1.1 14,281 6/6/2024
7.1.0 42,295 5/24/2024
7.0.5 199,519 4/18/2024
7.0.4 83,110 4/4/2024
7.0.3 24,365 4/1/2024
7.0.2 132,915 3/14/2024
7.0.1 19,911 3/12/2024
7.0.0 73,516 2/27/2024
7.0.0-rc.4 2,912 2/23/2024
7.0.0-rc.3 69 2/23/2024
7.0.0-rc.2 387 2/15/2024
7.0.0-rc.1 43,965 10/5/2023
6.18.0 194,264 2/9/2024
6.16.1 277,538 1/15/2024
6.15.2 393,658 12/5/2023
6.15.1 192,654 11/17/2023
6.15.0 152,061 11/8/2023
6.14.1 333,258 10/5/2023
6.14.0 141,217 9/21/2023
6.13.0 146,755 9/7/2023
6.11.0 327,109 8/10/2023
6.10.1 171,539 7/27/2023
6.10.0 169,470 7/13/2023
6.9.0 170,257 6/28/2023
6.8.0 176,558 6/15/2023
6.7.0 196,349 6/1/2023
6.6.1 164,380 5/18/2023
6.6.0 175,761 5/4/2023
6.5.0 274,642 4/20/2023
6.4.0 227,508 4/5/2023
6.3.0 344,773 3/23/2023
6.2.5 327,357 3/9/2023
6.2.4 840,657 2/22/2023
6.2.3 147,040 2/8/2023
6.2.2 267,598 1/25/2023
6.2.1 342,149 1/11/2023
6.2.0 292,740 12/14/2022
6.1.0 246,645 11/30/2022
6.0.1 458,829 11/16/2022
6.0.0-rc.3 776 11/10/2022
6.0.0-rc.2 1,162 10/31/2022
6.0.0-rc.1 1,384 10/20/2022
5.81.2 302,167 11/10/2022
5.81.1 167,516 10/31/2022
5.81.0 237,388 10/19/2022
5.80.1 377,895 10/5/2022
5.80.0 667,494 9/7/2022
5.79.0 224,639 8/24/2022
5.78.1 255,640 8/10/2022
5.78.0 451,959 7/21/2022
5.77.0 600,938 7/13/2022
5.76.0 413,348 6/29/2022
5.75.3 360,811 6/15/2022
5.75.2 216,407 6/1/2022
5.75.1 431,500 5/18/2022
5.75.0 352,664 5/4/2022
5.74.0 670,244 4/6/2022
5.73.0 634,878 3/23/2022
5.72.1 463,718 3/9/2022
5.72.0 360,047 2/23/2022
5.71.0 4,155,347 2/9/2022
5.70.1 531,915 1/26/2022
5.70.0 435,870 1/12/2022
5.69.0 640,223 12/15/2021
5.68.2 438,541 12/1/2021
5.68.1 672,370 11/17/2021
5.68.0 246,029 11/3/2021
5.67.0 277,044 10/18/2021
5.66.0 199,658 10/6/2021
5.65.3 315,781 9/22/2021
5.65.2 453,139 9/8/2021
5.65.0 554,982 8/11/2021
5.64.1 268,441 7/28/2021
5.64.0 277,551 7/14/2021
5.63.0 240,333 6/30/2021
5.62.0 298,536 6/16/2021
5.61.1 327,363 6/2/2021
5.61.0 178,578 5/19/2021
5.60.0 265,789 5/5/2021
5.59.0 203,016 4/21/2021
5.58.0 306,631 4/7/2021
5.57.0 507,975 3/24/2021
5.56.0 507,665 3/15/2021
5.55.0 340,617 2/24/2021
5.54.0 348,329 2/12/2021
5.53.1 497,924 1/27/2021
5.53.0 188,485 1/13/2021
5.52.1 720,528 12/16/2020
5.52.0 234,966 12/8/2020
5.51.0 146,033 12/2/2020
5.50.0 596,871 11/18/2020
5.49.0 319,920 11/5/2020
5.48.0 598,040 10/14/2020
5.47.2 431,574 9/28/2020
5.47.1 306,746 9/21/2020
5.47.0 62,766 9/16/2020
5.46.2 313,206 9/3/2020
5.46.1 11,741 9/2/2020
5.46.0 480,227 8/19/2020
5.45.2 317,651 8/5/2020
5.45.1 248,978 7/22/2020
5.45.0 848,974 7/8/2020
5.44.0 538,637 6/24/2020
5.43.0 317,206 6/10/2020
5.42.0 319,888 5/27/2020
5.41.1 394,374 5/20/2020
5.41.0 156,414 5/13/2020
5.40.0 291,702 4/29/2020
5.39.1 332,230 4/15/2020
5.39.0 393,460 4/1/2020
5.38.0 358,751 3/18/2020
5.37.6 394,775 3/4/2020
5.37.5 450,322 2/19/2020
5.37.4 333,698 2/5/2020
5.37.3 412,528 1/22/2020
5.37.2 1,209,707 1/8/2020
5.37.1 354,002 12/18/2019
5.37.0 103,947 12/12/2019
5.36.0 216,359 12/4/2019
5.35.1 346,912 11/13/2019
5.35.0 284,250 10/30/2019
5.34.0 141,838 10/16/2019
5.33.1 861,895 10/2/2019
5.33.0 331,851 9/18/2019
5.32.0 185,095 9/4/2019
5.31.4 248,638 8/21/2019
5.31.3 235,341 8/5/2019
5.31.2 99,002 7/24/2019
5.31.1 367,491 7/10/2019
5.31.0 229,241 6/26/2019
5.30.0 279,588 6/12/2019
5.29.1 204,279 5/29/2019
5.29.0 206,266 5/15/2019
5.28.4 168,609 5/1/2019
5.28.3 111,825 4/24/2019
5.28.2 131,309 4/12/2019
5.28.1 4,509 4/12/2019
5.28.0 973,755 3/28/2019
5.27.2 127,064 3/15/2019
5.27.1 722,530 3/7/2019
5.27.0 60,625 3/1/2019
5.26.1 168,552 2/16/2019
5.26.0 296,588 2/4/2019
5.25.1 619,469 1/11/2019
5.25.0 6,810 1/10/2019
5.24.1 288,612 1/2/2019
5.24.0 75,538 12/14/2018
5.23.0 200,563 11/30/2018
5.22.0 122,736 11/16/2018
5.21.0 165,863 10/28/2018
5.20.1 578,569 10/16/2018
5.20.0 18,591 10/15/2018
5.19.0 245,487 10/4/2018
5.18.0 27,752 10/2/2018
5.17.0 287,944 9/20/2018
5.16.4 128,474 9/7/2018
5.16.3 141,059 8/31/2018
5.16.2 94,378 8/23/2018
5.16.0 117,084 8/17/2018
5.15.1 79,976 8/9/2018
5.15.0 146,636 8/3/2018
5.14.1 107,920 7/27/2018
5.14.0 182,261 7/16/2018
5.13.8 45,363 7/11/2018
5.13.7 74,794 7/5/2018
5.13.6 33,875 6/29/2018
5.13.5 32,802 6/21/2018
5.13.4 40,756 6/15/2018
5.13.3 136,890 6/5/2018
5.13.2 71,681 5/25/2018
5.13.1 48,873 5/18/2018
5.13.0 244,280 5/11/2018
5.12.1 40,452 5/7/2018
5.12.0 42,763 4/27/2018
5.11.1 62,738 4/20/2018
5.11.0 29,795 4/13/2018
5.10.0 183,941 3/23/2018
5.9.8 87,927 3/10/2018
5.9.7 395,845 2/24/2018
5.9.6 95,305 2/10/2018
5.9.5 66,306 1/31/2018
5.9.4 65,171 1/22/2018
5.9.3 3,194 1/22/2018
5.9.2 297,431 12/16/2017
5.9.1 78,523 12/1/2017
5.9.0 278,380 11/17/2017
5.8.3 208,498 11/11/2017
5.8.2 119,842 11/3/2017
5.8.1 47,650 10/28/2017
5.8.0 83,368 10/20/2017
5.7.2 61,922 10/13/2017
5.7.1 34,511 10/6/2017
5.7.0 30,322 9/29/2017
5.6.5 87,707 9/16/2017
5.6.4 80,866 9/1/2017
5.6.3 258,056 8/25/2017
5.6.2 18,813 8/18/2017
5.6.1 30,099 8/11/2017
5.6.0 95,324 7/27/2017
5.5.3-alpha2 28,568 7/7/2017
5.5.3-alpha1 2,637 7/1/2017
5.5.2 70,043 7/1/2017
5.5.2-alpha1 3,475 6/16/2017
5.5.1 80,221 6/16/2017
5.5.1-alpha1 3,693 5/24/2017
5.5.0 144,880 5/24/2017
5.4.3-alpha1 2,469 5/22/2017
5.4.2 32,480 5/19/2017
5.4.2-alpha1 2,592 5/8/2017
5.4.1 109,957 5/8/2017
5.4.1-alpha1 4,578 4/27/2017
5.4.0 26,223 4/27/2017
5.4.0-alpha1 2,584 4/27/2017
5.3.1-alpha1 5,705 4/17/2017
5.3.0 53,422 4/17/2017
5.2.2-alpha1 2,563 4/13/2017
5.2.1 12,284 4/13/2017
5.2.1-alpha1 10,797 3/31/2017
5.2.0 41,167 3/31/2017
5.1.2-alpha1 2,945 3/21/2017
5.1.1 46,556 3/21/2017
5.1.1-alpha1 3,104 3/9/2017
5.1.0 68,434 3/9/2017
5.0.3-alpha1 2,757 2/24/2017
5.0.2 32,589 2/24/2017
5.0.2-alpha1 2,558 2/24/2017
5.0.1 8,766 2/24/2017
5.0.1-alpha1 2,729 2/22/2017
5.0.0 45,189 2/22/2017
5.0.0-rca4 21,180 2/14/2017
5.0.0-rca3 2,470 2/9/2017
5.0.0-rca2 6,730 12/8/2016
5.0.0-rca1 3,570 11/9/2016
5.0.0-rc9 2,656 11/3/2016
5.0.0-rc8 4,054 9/19/2016
5.0.0-rc7 2,503 9/15/2016
5.0.0-rc6 3,420 9/1/2016
5.0.0-rc4 4,611 7/8/2016
5.0.0-rc2 20,777 6/2/2016
5.0.0-rc10 2,567 11/4/2016
5.0.0-rc1 2,301 6/1/2016
5.0.0-alpha1 2,323 2/22/2017
4.7.2 3,273,561 5/23/2016
4.7.1 272,568 4/5/2016
4.7.0 107,192 3/16/2016
4.5.0 384,572 2/5/2016
4.4.1 302,458 11/26/2015
4.4.0 23,369 11/12/2015
4.4.0-edge 2,409 11/12/2015
4.3.0 17,543 11/11/2015
4.2.1 59,104 10/30/2015
4.2.0 3,003 10/30/2015
4.1.0 186,097 9/24/2015
4.0.51 156,775 8/24/2015
4.0.5 197,329 8/20/2015
4.0.4 33,737 8/12/2015
4.0.3 217,607 5/21/2015
4.0.2 4,311 5/19/2015
4.0.1 6,121 5/14/2015
4.0.0 36,764 4/28/2015
3.8.45-beta 3,036 3/19/2015
3.8.44-beta 2,345 3/19/2015
3.8.40-beta 2,419 3/6/2015
3.8.30-beta 2,414 3/5/2015
3.8.29-beta 2,370 3/5/2015
3.8.28-beta 2,285 3/5/2015
3.8.26-beta 2,377 3/5/2015
3.8.18-beta 3,640 12/19/2014
3.7.55-alpha 7,691 6/4/2014
3.7.54-alpha 2,426 6/4/2014
3.7.53-alpha 2,450 6/4/2014
3.7.51-alpha 2,432 6/4/2014
3.7.50-alpha 2,502 6/4/2014
3.7.48-alpha 2,518 6/4/2014
3.7.46-alpha 2,411 6/4/2014
3.7.45-alpha 2,461 6/4/2014
3.7.44-alpha 2,474 6/4/2014
3.7.43-alpha 2,495 5/31/2014
3.7.40-alpha 2,440 5/31/2014
3.7.39-alpha 2,433 5/31/2014
3.7.38-alpha 2,423 5/31/2014
3.7.37-alpha 2,418 5/30/2014
3.7.35-alpha 2,416 5/30/2014
3.6.29 51,998 4/7/2015
3.6.28 3,209 4/7/2015
3.6.27 80,017 2/26/2015
3.6.26 35,349 2/19/2015
3.6.25 118,315 12/7/2014
3.6.24 23,191 11/14/2014
3.6.23 8,239 11/5/2014
3.6.22 3,436 11/5/2014
3.6.20 38,386 10/10/2014
3.6.19 2,984 10/10/2014
3.6.18 69,842 9/29/2014
3.6.17 26,140 8/28/2014
3.6.16 174,428 5/29/2014
3.6.15 3,866 5/27/2014
3.6.11 93,384 1/25/2014
3.6.10 24,837 11/20/2013
3.6.9 30,865 11/4/2013
3.6.8 3,078 11/4/2013
3.6.7 3,049 11/4/2013
3.6.6 3,026 11/4/2013
3.6.5 21,904 10/21/2013
3.6.4 7,524 10/7/2013
3.6.3 3,853 10/3/2013
3.6.2 5,247 9/30/2013
3.6.1 39,997 9/18/2013
3.5.17 76,938 7/31/2013
3.5.16 5,061 7/20/2013
3.5.15 7,824 7/13/2013
3.5.14 6,485 6/19/2013
3.5.12 10,484 4/10/2013
3.5.11 3,090 4/9/2013
3.5.10 4,121 4/5/2013
3.5.9 3,411 4/4/2013
3.5.8 4,176 3/18/2013
3.5.6 14,849 12/17/2012
3.5.5 10,312 10/25/2012
3.5.4 3,217 10/24/2012
3.5.3 3,697 10/17/2012
3.5.2 3,119 10/17/2012
3.5.1 5,397 8/31/2012
3.5.0 3,946 8/20/2012
3.4.5 7,878 7/12/2012
3.4.4 3,134 7/12/2012
3.4.3 3,263 7/9/2012
3.4.2 18,441 4/18/2012
3.4.1 46,954 4/18/2012
3.4.0 8,965 3/21/2012
3.3.7 3,891 2/15/2012
3.3.6 3,697 2/15/2012
3.3.5 3,131 2/15/2012
3.3.4 3,256 2/7/2012
3.3.3 3,101 2/6/2012
3.3.2 4,356 11/18/2011
3.3.1 3,243 11/18/2011
3.2.3 3,413 10/19/2011
3.2.2 3,321 10/11/2011
3.2.1 3,382 9/28/2011
3.2.0 3,397 9/21/2011
3.1.4 3,373 8/26/2011
3.1.3 3,316 8/9/2011
3.1.0 5,013 7/26/2011
3.0.1 3,714 7/20/2011
3.0.0 71,694 7/17/2011
2.0.2 36,524 1/31/2011