Twilio 7.3.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Twilio --version 7.3.0                
NuGet\Install-Package Twilio -Version 7.3.0                
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.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Twilio --version 7.3.0                
#r "nuget: Twilio, 7.3.0"                
#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.3.0

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

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 (183)

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 (27)

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, OpenTelemetry, SignalR, Hosted Services, Health Checks, Rate Limiting, Cloud Services (Azure, AWS, GCP).
ariacom/Seal-Report
Database Reporting Tool and Tasks (.Net)
Version Downloads Last updated
7.5.0 17,344 10/3/2024
7.4.0 31,460 9/25/2024
7.3.1 32,953 9/18/2024
7.3.0 59,886 9/5/2024
7.2.3 81,199 8/26/2024
7.2.2 395,578 7/2/2024
7.2.1 33,202 6/27/2024
7.2.0 70,032 6/18/2024
7.1.1 121,327 6/6/2024
7.1.0 212,187 5/24/2024
7.0.5 458,496 4/18/2024
7.0.4 163,658 4/4/2024
7.0.3 42,983 4/1/2024
7.0.2 193,526 3/14/2024
7.0.1 35,625 3/12/2024 7.0.1 is deprecated.
7.0.0 102,723 2/27/2024 7.0.0 is deprecated.
7.0.0-rc.4 5,437 2/23/2024
7.0.0-rc.3 100 2/23/2024
7.0.0-rc.2 592 2/15/2024
7.0.0-rc.1 65,021 10/5/2023
6.18.0 300,161 2/9/2024
6.16.1 412,472 1/15/2024
6.15.2 517,539 12/5/2023
6.15.1 263,652 11/17/2023
6.15.0 202,725 11/8/2023
6.14.1 412,609 10/5/2023
6.14.0 172,713 9/21/2023
6.13.0 170,652 9/7/2023
6.11.0 386,918 8/10/2023
6.10.1 198,004 7/27/2023
6.10.0 200,407 7/13/2023
6.9.0 189,559 6/28/2023
6.8.0 212,559 6/15/2023
6.7.0 227,887 6/1/2023
6.6.1 193,038 5/18/2023
6.6.0 209,394 5/4/2023
6.5.0 311,542 4/20/2023
6.4.0 260,145 4/5/2023
6.3.0 393,275 3/23/2023
6.2.5 390,651 3/9/2023
6.2.4 1,168,245 2/22/2023
6.2.3 160,413 2/8/2023
6.2.2 306,678 1/25/2023
6.2.1 377,280 1/11/2023
6.2.0 332,543 12/14/2022
6.1.0 277,687 11/30/2022
6.0.1 528,630 11/16/2022
6.0.0-rc.3 828 11/10/2022
6.0.0-rc.2 1,215 10/31/2022
6.0.0-rc.1 1,554 10/20/2022
5.81.2 387,495 11/10/2022
5.81.1 183,361 10/31/2022
5.81.0 275,905 10/19/2022
5.80.1 418,004 10/5/2022
5.80.0 755,611 9/7/2022
5.79.0 244,101 8/24/2022
5.78.1 275,672 8/10/2022
5.78.0 500,328 7/21/2022
5.77.0 698,282 7/13/2022
5.76.0 471,463 6/29/2022
5.75.3 406,032 6/15/2022
5.75.2 233,253 6/1/2022
5.75.1 472,375 5/18/2022
5.75.0 382,274 5/4/2022
5.74.0 748,261 4/6/2022
5.73.0 700,661 3/23/2022
5.72.1 494,913 3/9/2022
5.72.0 402,034 2/23/2022
5.71.0 5,013,255 2/9/2022
5.70.1 588,750 1/26/2022
5.70.0 462,103 1/12/2022
5.69.0 703,305 12/15/2021
5.68.2 489,379 12/1/2021
5.68.1 720,502 11/17/2021
5.68.0 253,749 11/3/2021
5.67.0 293,245 10/18/2021
5.66.0 214,809 10/6/2021
5.65.3 340,513 9/22/2021
5.65.2 475,982 9/8/2021
5.65.0 600,980 8/11/2021
5.64.1 288,113 7/28/2021
5.64.0 297,886 7/14/2021
5.63.0 254,656 6/30/2021
5.62.0 315,699 6/16/2021
5.61.1 342,624 6/2/2021
5.61.0 183,327 5/19/2021
5.60.0 285,309 5/5/2021
5.59.0 209,278 4/21/2021
5.58.0 329,808 4/7/2021
5.57.0 537,050 3/24/2021
5.56.0 519,068 3/15/2021
5.55.0 358,879 2/24/2021
5.54.0 358,362 2/12/2021
5.53.1 529,323 1/27/2021
5.53.0 197,248 1/13/2021
5.52.1 769,157 12/16/2020
5.52.0 250,843 12/8/2020
5.51.0 154,943 12/2/2020
5.50.0 618,850 11/18/2020
5.49.0 334,355 11/5/2020
5.48.0 678,990 10/14/2020
5.47.2 470,033 9/28/2020
5.47.1 322,569 9/21/2020
5.47.0 65,334 9/16/2020
5.46.2 324,031 9/3/2020
5.46.1 11,815 9/2/2020
5.46.0 498,975 8/19/2020
5.45.2 328,300 8/5/2020
5.45.1 260,441 7/22/2020
5.45.0 985,121 7/8/2020
5.44.0 555,057 6/24/2020
5.43.0 341,133 6/10/2020
5.42.0 333,518 5/27/2020
5.41.1 432,941 5/20/2020
5.41.0 159,905 5/13/2020
5.40.0 303,256 4/29/2020
5.39.1 344,318 4/15/2020
5.39.0 434,087 4/1/2020
5.38.0 374,212 3/18/2020
5.37.6 409,068 3/4/2020
5.37.5 470,635 2/19/2020
5.37.4 340,994 2/5/2020
5.37.3 423,377 1/22/2020
5.37.2 1,257,758 1/8/2020
5.37.1 366,242 12/18/2019
5.37.0 106,494 12/12/2019
5.36.0 231,623 12/4/2019
5.35.1 373,373 11/13/2019
5.35.0 294,772 10/30/2019
5.34.0 148,004 10/16/2019
5.33.1 901,421 10/2/2019
5.33.0 373,703 9/18/2019
5.32.0 200,566 9/4/2019
5.31.4 257,066 8/21/2019
5.31.3 241,850 8/5/2019
5.31.2 104,131 7/24/2019
5.31.1 386,771 7/10/2019
5.31.0 235,402 6/26/2019
5.30.0 291,644 6/12/2019
5.29.1 213,800 5/29/2019
5.29.0 212,641 5/15/2019
5.28.4 178,052 5/1/2019
5.28.3 114,974 4/24/2019
5.28.2 135,228 4/12/2019
5.28.1 4,625 4/12/2019
5.28.0 1,163,729 3/28/2019
5.27.2 130,467 3/15/2019
5.27.1 732,410 3/7/2019
5.27.0 67,358 3/1/2019
5.26.1 172,026 2/16/2019
5.26.0 308,627 2/4/2019
5.25.1 636,927 1/11/2019
5.25.0 7,659 1/10/2019
5.24.1 298,795 1/2/2019
5.24.0 76,525 12/14/2018
5.23.0 207,352 11/30/2018
5.22.0 124,542 11/16/2018
5.21.0 170,188 10/28/2018
5.20.1 592,946 10/16/2018
5.20.0 18,909 10/15/2018
5.19.0 279,093 10/4/2018
5.18.0 30,166 10/2/2018
5.17.0 302,343 9/20/2018
5.16.4 131,597 9/7/2018
5.16.3 151,674 8/31/2018
5.16.2 99,395 8/23/2018
5.16.0 126,362 8/17/2018
5.15.1 81,494 8/9/2018
5.15.0 154,016 8/3/2018
5.14.1 109,161 7/27/2018
5.14.0 184,607 7/16/2018
5.13.8 46,790 7/11/2018
5.13.7 74,991 7/5/2018
5.13.6 34,381 6/29/2018
5.13.5 34,094 6/21/2018
5.13.4 41,839 6/15/2018
5.13.3 139,527 6/5/2018
5.13.2 72,560 5/25/2018
5.13.1 50,816 5/18/2018
5.13.0 339,120 5/11/2018
5.12.1 40,629 5/7/2018
5.12.0 43,187 4/27/2018
5.11.1 63,497 4/20/2018
5.11.0 30,272 4/13/2018
5.10.0 188,669 3/23/2018
5.9.8 90,452 3/10/2018
5.9.7 407,402 2/24/2018
5.9.6 97,623 2/10/2018
5.9.5 67,655 1/31/2018
5.9.4 66,335 1/22/2018
5.9.3 3,248 1/22/2018
5.9.2 305,982 12/16/2017
5.9.1 79,138 12/1/2017
5.9.0 288,685 11/17/2017
5.8.3 220,236 11/11/2017
5.8.2 123,580 11/3/2017
5.8.1 49,602 10/28/2017
5.8.0 85,412 10/20/2017
5.7.2 62,363 10/13/2017
5.7.1 34,654 10/6/2017
5.7.0 33,455 9/29/2017
5.6.5 90,825 9/16/2017
5.6.4 86,798 9/1/2017
5.6.3 265,067 8/25/2017
5.6.2 19,053 8/18/2017
5.6.1 30,614 8/11/2017
5.6.0 96,887 7/27/2017
5.5.3-alpha2 29,359 7/7/2017
5.5.3-alpha1 2,758 7/1/2017
5.5.2 71,363 7/1/2017
5.5.2-alpha1 3,526 6/16/2017
5.5.1 84,026 6/16/2017
5.5.1-alpha1 3,747 5/24/2017
5.5.0 146,537 5/24/2017
5.4.3-alpha1 2,529 5/22/2017
5.4.2 33,998 5/19/2017
5.4.2-alpha1 2,656 5/8/2017
5.4.1 115,466 5/8/2017
5.4.1-alpha1 4,657 4/27/2017
5.4.0 26,569 4/27/2017
5.4.0-alpha1 2,646 4/27/2017
5.3.1-alpha1 5,773 4/17/2017
5.3.0 57,519 4/17/2017
5.2.2-alpha1 2,622 4/13/2017
5.2.1 12,629 4/13/2017
5.2.1-alpha1 11,210 3/31/2017
5.2.0 42,060 3/31/2017
5.1.2-alpha1 2,993 3/21/2017
5.1.1 46,836 3/21/2017
5.1.1-alpha1 3,161 3/9/2017
5.1.0 71,647 3/9/2017
5.0.3-alpha1 2,808 2/24/2017
5.0.2 33,723 2/24/2017
5.0.2-alpha1 2,612 2/24/2017
5.0.1 8,938 2/24/2017
5.0.1-alpha1 2,782 2/22/2017
5.0.0 46,936 2/22/2017
5.0.0-rca4 24,232 2/14/2017
5.0.0-rca3 2,520 2/9/2017
5.0.0-rca2 6,806 12/8/2016
5.0.0-rca1 3,636 11/9/2016
5.0.0-rc9 2,705 11/3/2016
5.0.0-rc8 4,119 9/19/2016
5.0.0-rc7 2,556 9/15/2016
5.0.0-rc6 3,472 9/1/2016
5.0.0-rc4 4,681 7/8/2016
5.0.0-rc2 20,835 6/2/2016
5.0.0-rc10 2,617 11/4/2016
5.0.0-rc1 2,384 6/1/2016
5.0.0-alpha1 2,382 2/22/2017
4.7.2 3,353,555 5/23/2016
4.7.1 288,787 4/5/2016
4.7.0 109,551 3/16/2016
4.5.0 389,981 2/5/2016
4.4.1 308,528 11/26/2015
4.4.0 23,830 11/12/2015
4.4.0-edge 2,464 11/12/2015
4.3.0 18,267 11/11/2015
4.2.1 60,715 10/30/2015
4.2.0 3,069 10/30/2015
4.1.0 190,690 9/24/2015
4.0.51 159,688 8/24/2015
4.0.5 210,871 8/20/2015
4.0.4 33,810 8/12/2015
4.0.3 225,272 5/21/2015
4.0.2 4,393 5/19/2015
4.0.1 6,419 5/14/2015
4.0.0 38,303 4/28/2015
3.8.45-beta 3,333 3/19/2015
3.8.44-beta 2,392 3/19/2015
3.8.40-beta 2,482 3/6/2015
3.8.30-beta 2,457 3/5/2015
3.8.29-beta 2,412 3/5/2015
3.8.28-beta 2,324 3/5/2015
3.8.26-beta 2,417 3/5/2015
3.8.18-beta 3,696 12/19/2014
3.7.55-alpha 7,744 6/4/2014
3.7.54-alpha 2,467 6/4/2014
3.7.53-alpha 2,493 6/4/2014
3.7.51-alpha 2,475 6/4/2014
3.7.50-alpha 2,545 6/4/2014
3.7.48-alpha 2,560 6/4/2014
3.7.46-alpha 2,455 6/4/2014
3.7.45-alpha 2,501 6/4/2014
3.7.44-alpha 2,518 6/4/2014
3.7.43-alpha 2,534 5/31/2014
3.7.40-alpha 2,487 5/31/2014
3.7.39-alpha 2,479 5/31/2014
3.7.38-alpha 2,479 5/31/2014
3.7.37-alpha 2,464 5/30/2014
3.7.35-alpha 2,474 5/30/2014
3.6.29 54,717 4/7/2015
3.6.28 3,267 4/7/2015
3.6.27 81,820 2/26/2015
3.6.26 36,088 2/19/2015
3.6.25 129,066 12/7/2014
3.6.24 23,538 11/14/2014
3.6.23 8,303 11/5/2014
3.6.22 3,479 11/5/2014
3.6.20 38,815 10/10/2014
3.6.19 3,037 10/10/2014
3.6.18 70,570 9/29/2014
3.6.17 26,697 8/28/2014
3.6.16 191,425 5/29/2014
3.6.15 3,955 5/27/2014
3.6.11 95,070 1/25/2014
3.6.10 25,322 11/20/2013
3.6.9 32,061 11/4/2013
3.6.8 3,129 11/4/2013
3.6.7 3,114 11/4/2013
3.6.6 3,087 11/4/2013
3.6.5 21,958 10/21/2013
3.6.4 7,571 10/7/2013
3.6.3 3,916 10/3/2013
3.6.2 5,548 9/30/2013
3.6.1 40,089 9/18/2013
3.5.17 77,274 7/31/2013
3.5.16 5,128 7/20/2013
3.5.15 7,878 7/13/2013
3.5.14 6,636 6/19/2013
3.5.12 10,692 4/10/2013
3.5.11 3,144 4/9/2013
3.5.10 4,179 4/5/2013
3.5.9 3,508 4/4/2013
3.5.8 4,255 3/18/2013
3.5.6 15,230 12/17/2012
3.5.5 10,966 10/25/2012
3.5.4 3,269 10/24/2012
3.5.3 3,896 10/17/2012
3.5.2 3,176 10/17/2012
3.5.1 5,447 8/31/2012
3.5.0 3,997 8/20/2012
3.4.5 8,203 7/12/2012
3.4.4 3,187 7/12/2012
3.4.3 3,315 7/9/2012
3.4.2 18,516 4/18/2012
3.4.1 50,476 4/18/2012
3.4.0 9,018 3/21/2012
3.3.7 3,948 2/15/2012
3.3.6 3,750 2/15/2012
3.3.5 3,183 2/15/2012
3.3.4 3,307 2/7/2012
3.3.3 3,173 2/6/2012
3.3.2 4,414 11/18/2011
3.3.1 3,294 11/18/2011
3.2.3 3,455 10/19/2011
3.2.2 3,373 10/11/2011
3.2.1 3,447 9/28/2011
3.2.0 3,451 9/21/2011
3.1.4 3,422 8/26/2011
3.1.3 3,363 8/9/2011
3.1.0 5,095 7/26/2011
3.0.1 3,775 7/20/2011
3.0.0 72,581 7/17/2011
2.0.2 45,093 1/31/2011