SmsClient Class

A client to interact with the AzureCommunicationService Sms gateway asynchronously.

This client provides operations to send an SMS via a phone number.

Inheritance
builtins.object
SmsClient

Constructor

SmsClient(endpoint: str, credential: AsyncTokenCredential, **kwargs: Any)

Parameters

endpoint
str
Required

The endpoint url for Azure Communication Service resource.

param AsyncTokenCredential credential: The AsyncTokenCredential we use to authenticate against the service.

credential

Methods

close

Close the :class: ~azure.communication.sms.aio.SmsClient session.

from_connection_string

Create SmsClient from a Connection String.

send

Sends SMSs to phone numbers.

close

Close the :class: ~azure.communication.sms.aio.SmsClient session.

async close() -> None

from_connection_string

Create SmsClient from a Connection String.

from_connection_string(conn_str: str, **kwargs: Any) -> SmsClient

Parameters

conn_str
str
Required

A connection string to an Azure Communication Service resource.

conn_str
Required

Returns

Instance of SmsClient.

Return type

<xref:azure.communication.SmsClient>

send

Sends SMSs to phone numbers.

async send(from_: str, to: Union[str, List[str]], message: str, **kwargs: Any) -> [SmsSendResult]

Parameters

from
str
Required

The sender of the SMS.

to
<xref:Union>[str, <xref:List>[str]]
Required

The single recipient or the list of recipients of the SMS.

message
str
Required

The message in the SMS

enable_delivery_report
bool

Enable this flag to receive a delivery report for this message on the Azure Resource EventGrid.

tag
str

Use this field to provide metadata that will then be sent back in the corresponding Delivery Report.

Returns

A list of SmsSendResult.

Return type

[<xref:azure.communication.sms.models.SmsSendResult>]