Skip to content

create_sms_sandbox_phone_number

create_sms_sandbox_phone_number(
    phone_number: PhoneNumberString,
    *,
    config_overrides: Optional[SNSClientConfig] = None,
    language_code: Optional[LanguageCodeString] = None,
) -> CreateSMSSandboxPhoneNumberResult

Adds a destination phone number to an Amazon Web Services account in the SMS sandbox and sends a one-time password (OTP) to that phone number.

When you start using Amazon SNS to send SMS messages, your Amazon Web Services account is in the SMS sandbox. The SMS sandbox provides a safe environment for you to try Amazon SNS features without risking your reputation as an SMS sender. While your Amazon Web Services account is in the SMS sandbox, you can use all of the features of Amazon SNS. However, you can send SMS messages only to verified destination phone numbers. For more information, including how to move out of the sandbox to send messages without restrictions, see SMS sandbox in the Amazon SNS Developer Guide.

Parameters:

  • phone_number (PhoneNumberString) –

    The destination phone number to verify. On verification, Amazon SNS adds this phone number to the list of verified phone numbers that you can send SMS messages to.

  • language_code (Optional[LanguageCodeString], default: None ) –

    The language to use for sending the OTP. The default value is en-US.

Raises:

  • AuthorizationErrorException –

    Indicates that the user has been denied access to the requested resource.

  • InternalErrorException –

    Indicates an internal service error.

  • InvalidParameterException –

    Indicates that a request parameter does not comply with the associated constraints.

  • OptedOutException –

    Indicates that the specified phone number opted out of receiving SMS messages from your Amazon Web Services account. You can't send SMS messages to phone numbers that opt out.

  • ThrottledException –

    Indicates that the rate at which requests have been submitted for this action exceeds the limit for your Amazon Web Services account.

  • UserErrorException –

    Indicates that a request parameter does not comply with the associated constraints.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sns/_services/sns.py
def create_sms_sandbox_phone_number(
    self,
    phone_number: "capo_sns.types.phone_number_string.PhoneNumberString",
    *,
    config_overrides: Optional[SNSClientConfig] = None,
    language_code: Optional[
        "capo_sns.types.language_code_string.LanguageCodeString"
    ] = None,
) -> "capo_sns.types.create_sms_sandbox_phone_number_result.CreateSMSSandboxPhoneNumberResult":
    """<p>Adds a destination phone number to an Amazon Web Services account in the SMS sandbox and sends a one-time password (OTP) to that phone number.</p> <p>When you start using Amazon SNS to send SMS messages, your Amazon Web Services account is in the <i>SMS sandbox</i>. The SMS sandbox provides a safe environment for you to try Amazon SNS features without risking your reputation as an SMS sender. While your Amazon Web Services account is in the SMS sandbox, you can use all of the features of Amazon SNS. However, you can send SMS messages only to verified destination phone numbers. For more information, including how to move out of the sandbox to send messages without restrictions, see <a href="https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html">SMS sandbox</a> in the <i>Amazon SNS Developer Guide</i>.</p>

    Args:
        phone_number: <p>The destination phone number to verify. On verification, Amazon SNS adds this phone number to the list of verified phone numbers that you can send SMS messages to.</p>
        language_code: <p>The language to use for sending the OTP. The default value is <code>en-US</code>.</p>

    Raises:
        capo_sns.errors.authorization_error_exception.AuthorizationErrorException: <p>Indicates that the user has been denied access to the requested resource.</p>
        capo_sns.errors.internal_error_exception.InternalErrorException: <p>Indicates an internal service error.</p>
        capo_sns.errors.invalid_parameter_exception.InvalidParameterException: <p>Indicates that a request parameter does not comply with the associated constraints.</p>
        capo_sns.errors.opted_out_exception.OptedOutException: <p>Indicates that the specified phone number opted out of receiving SMS messages from your Amazon Web Services account. You can't send SMS messages to phone numbers that opt out.</p>
        capo_sns.errors.throttled_exception.ThrottledException: <p>Indicates that the rate at which requests have been submitted for this action exceeds the limit for your Amazon Web Services account.</p>
        capo_sns.errors.user_error_exception.UserErrorException: <p>Indicates that a request parameter does not comply with the associated constraints.</p>
        capo_sns.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sns.types.create_sms_sandbox_phone_number_input.CreateSMSSandboxPhoneNumberInput]",
    ) -> OperationResponse[
        "capo_sns.types.create_sms_sandbox_phone_number_result.CreateSMSSandboxPhoneNumberResult"
    ]:
        import capo_sns._operations.amazon_simple_notification_service.create_sms_sandbox_phone_number

        output, http_response = (
            capo_sns._operations.amazon_simple_notification_service.create_sms_sandbox_phone_number.create_sms_sandbox_phone_number(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_sns.types.create_sms_sandbox_phone_number_input.CreateSMSSandboxPhoneNumberInput",
    ) -> dict[str, Any]:
        import capo_sns.types.create_sms_sandbox_phone_number_input

        return (
            capo_sns.types.create_sms_sandbox_phone_number_input.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateSMSSandboxPhoneNumber", redact_input=_redact_input),
    )
    input_: capo_sns.types.create_sms_sandbox_phone_number_input.CreateSMSSandboxPhoneNumberInput = {
        "phone_number": phone_number
    }
    if language_code is not None:
        input_["language_code"] = language_code

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output