Table of Contents

Interface IShortCodesClient

Namespace
Vonage.ShortCodes
Assembly
Vonage.dll

Exposes US Short Codes API features for sending event-based alerts and two-factor authentication messages via pre-approved short codes in the United States.

public interface IShortCodesClient

Methods

ManageOptInAsync(OptInManageRequest, Credentials)

Manages the opt-in status for a specific phone number, allowing it to receive messages from your short code.

Task<OptInRecord> ManageOptInAsync(OptInManageRequest request, Credentials creds = null)

Parameters

request OptInManageRequest

The request containing the phone number to manage. See OptInManageRequest.

creds Credentials

Optional credentials to override the default client credentials.

Returns

Task<OptInRecord>

An OptInRecord containing the updated opt-in status for the phone number.

Examples

var request = new OptInManageRequest { Msisdn = "14155551234" };
var record = await client.ShortCodesClient.ManageOptInAsync(request);
Console.WriteLine($"Opt-in status: {record.OptIn}");

QueryOptInsAsync(OptInQueryRequest, Credentials)

Queries the list of phone numbers that have opted in to receive messages from your short code.

Task<OptInSearchResponse> QueryOptInsAsync(OptInQueryRequest request, Credentials creds = null)

Parameters

request OptInQueryRequest

The query parameters for pagination. See OptInQueryRequest.

creds Credentials

Optional credentials to override the default client credentials.

Returns

Task<OptInSearchResponse>

An OptInSearchResponse containing the list of opted-in phone numbers.

Examples

var request = new OptInQueryRequest { Page = "1", PageSize = "10" };
var response = await client.ShortCodesClient.QueryOptInsAsync(request);
foreach (var record in response.OptInList)
{
    Console.WriteLine($"MSISDN: {record.Msisdn}, Opted In: {record.OptIn}");
}

SendAlertAsync(AlertRequest, Credentials)

Sends an event-based alert message to a phone number using your pre-approved short code template.

Task<AlertResponse> SendAlertAsync(AlertRequest request, Credentials creds = null)

Parameters

request AlertRequest

The alert message details including recipient and template. See AlertRequest.

creds Credentials

Optional credentials to override the default client credentials.

Returns

Task<AlertResponse>

An AlertResponse containing the message delivery status.

Examples

var request = new AlertRequest
{
    To = "14155551234",
    Template = "Your order #{order_id} has shipped!"
};
var response = await client.ShortCodesClient.SendAlertAsync(request);

SendTwoFactorAuthAsync(TwoFactorAuthRequest, Credentials)

Sends a two-factor authentication PIN code to a phone number using your pre-approved short code.

Task<TwoFactorAuthResponse> SendTwoFactorAuthAsync(TwoFactorAuthRequest request, Credentials creds = null)

Parameters

request TwoFactorAuthRequest

The two-factor authentication request details. See TwoFactorAuthRequest.

creds Credentials

Optional credentials to override the default client credentials.

Returns

Task<TwoFactorAuthResponse>

A TwoFactorAuthResponse containing the message delivery status.

Examples

var request = new TwoFactorAuthRequest();
var response = await client.ShortCodesClient.SendTwoFactorAuthAsync(request);