Skip to content

opt_in_phone_number

opt_in_phone_number(
    phone_number: PhoneNumber, *, config_overrides: Optional[SNSClientConfig] = None
) -> OptInPhoneNumberResponse

Use this request to opt in a phone number that is opted out, which enables you to resume sending SMS messages to the number.

You can opt in a phone number only once every 30 days.

Parameters:

  • phone_number (PhoneNumber) –

    The phone number to opt in. Use E.164 format.

Raises:

Source code in docs_src/capo_sns/_services/sns.py
def opt_in_phone_number(
    self,
    phone_number: "capo_sns.types.phone_number.PhoneNumber",
    *,
    config_overrides: Optional[SNSClientConfig] = None,
) -> "capo_sns.types.opt_in_phone_number_response.OptInPhoneNumberResponse":
    """<p>Use this request to opt in a phone number that is opted out, which enables you to resume sending SMS messages to the number.</p> <p>You can opt in a phone number only once every 30 days.</p>

    Args:
        phone_number: <p>The phone number to opt in. Use E.164 format.</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.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.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sns.types.opt_in_phone_number_input.OptInPhoneNumberInput]",
    ) -> OperationResponse[
        "capo_sns.types.opt_in_phone_number_response.OptInPhoneNumberResponse"
    ]:
        import capo_sns._operations.amazon_simple_notification_service.opt_in_phone_number

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

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

        return capo_sns.types.opt_in_phone_number_input.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("OptInPhoneNumber", redact_input=_redact_input),
    )
    input_: capo_sns.types.opt_in_phone_number_input.OptInPhoneNumberInput = {
        "phone_number": phone_number
    }

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