Soenneker.Twilio.RestClient 4.0.2755

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Twilio.RestClient --version 4.0.2755
                    
NuGet\Install-Package Soenneker.Twilio.RestClient -Version 4.0.2755
                    
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="Soenneker.Twilio.RestClient" Version="4.0.2755" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Twilio.RestClient" Version="4.0.2755" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Twilio.RestClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Twilio.RestClient --version 4.0.2755
                    
#r "nuget: Soenneker.Twilio.RestClient, 4.0.2755"
                    
#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.
#:package Soenneker.Twilio.RestClient@4.0.2755
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Twilio.RestClient&version=4.0.2755
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Twilio.RestClient&version=4.0.2755
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Twilio.RestClient

Provides a cached, authenticated TwilioRestClient backed by a shared HttpClient.

Installation

dotnet add package Soenneker.Twilio.RestClient

Configuration

{
  "Twilio": {
    "AccountSid": "AC...",
    "AuthToken": "..."
  }
}

Registration

using Soenneker.Twilio.RestClient.Registrars;

services.AddTwilioRestClientUtilAsScoped();

Scoped registration creates a TwilioRestClient wrapper per scope while retaining the shared cached HTTP client when a scope ends. Use AddTwilioRestClientUtilAsSingleton() to share the wrapper too; disposing that singleton removes its cached HTTP client.

Send a message

using Soenneker.Twilio.RestClient.Abstract;
using Twilio.Clients;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

public sealed class MessageSender
{
    private readonly ITwilioRestClientUtil _clients;

    public MessageSender(ITwilioRestClientUtil clients)
    {
        _clients = clients;
    }

    public async ValueTask<string?> Send(string destination, string sender, string body)
    {
        TwilioRestClient client = await _clients.Get();

        MessageResource message = await MessageResource.CreateAsync(
            to: new PhoneNumber(destination),
            from: new PhoneNumber(sender),
            body: body,
            client: client);

        return message.Sid;
    }
}

Pass the returned client explicitly to Twilio SDK resource methods. This avoids relying on the SDK's process-wide static TwilioClient state. Twilio API failures propagate as Twilio SDK exceptions.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.2759 0 10/12/2026
4.0.2758 40 10/12/2026
4.0.2757 36 10/11/2026
4.0.2756 36 10/11/2026
4.0.2755 41 10/11/2026
4.0.2754 42 10/11/2026
4.0.2753 47 10/11/2026
4.0.2752 50 10/9/2026
4.0.2751 102 10/1/2026
4.0.2750 96 9/30/2026
4.0.2749 102 9/29/2026
4.0.2748 89 9/29/2026
4.0.2747 101 9/28/2026
4.0.2746 95 9/26/2026
4.0.2745 95 9/26/2026
4.0.2744 93 9/25/2026
4.0.2743 92 9/25/2026
4.0.2742 90 9/25/2026
4.0.2741 92 9/25/2026
4.0.2740 101 9/24/2026
Loading failed

Update dependency Soenneker.Utils.HttpClientCache to 4.0.2102 (#3314)