- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
CheckIfPhoneNumberIsOptedOutCommand
Accepts a phone number and indicates whether the phone holder has opted out of receiving SMS messages from your Amazon Web Services account. You cannot send SMS messages to a number that is opted out.
To resume sending messages, you can opt in the number by using the OptInPhoneNumber
action.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { SNSClient, CheckIfPhoneNumberIsOptedOutCommand } from "@aws-sdk/client-sns"; // ES Modules import
// const { SNSClient, CheckIfPhoneNumberIsOptedOutCommand } = require("@aws-sdk/client-sns"); // CommonJS import
const client = new SNSClient(config);
const input = { // CheckIfPhoneNumberIsOptedOutInput
phoneNumber: "STRING_VALUE", // required
};
const command = new CheckIfPhoneNumberIsOptedOutCommand(input);
const response = await client.send(command);
// { // CheckIfPhoneNumberIsOptedOutResponse
// isOptedOut: true || false,
// };
CheckIfPhoneNumberIsOptedOutCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
phoneNumber Required | string | undefined | The phone number for which you want to check the opt out status. |
CheckIfPhoneNumberIsOptedOutCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
isOptedOut | boolean | undefined | Indicates whether the phone number is opted out:
|
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AuthorizationErrorException | client | Indicates that the user has been denied access to the requested resource. |
InternalErrorException | server | Indicates an internal service error. |
InvalidParameterException | client | Indicates that a request parameter does not comply with the associated constraints. |
ThrottledException | client | Indicates that the rate at which requests have been submitted for this action exceeds the limit for your Amazon Web Services account. |
SNSServiceException | Base exception class for all service exceptions from SNS service. |