Skip to content

request_phone_number async

request_phone_number(
    iso_country_code: IsoCountryCode,
    message_type: MessageType,
    number_capabilities: NumberCapabilityList,
    number_type: RequestableNumberType,
    *,
    config_overrides: Optional[AsyncPinpointSMSVoiceV2ClientConfig] = None,
    opt_out_list_name: Optional[OptOutListNameOrArn] = None,
    pool_id: Optional[PoolIdOrArn] = None,
    registration_id: Optional[RegistrationIdOrArn] = None,
    number_preference: Optional[NumberPreferenceList] = None,
    international_sending_enabled: Optional[bool] = None,
    deletion_protection_enabled: Optional[bool] = None,
    tags: Optional[TagList] = None,
    client_token: Optional[ClientToken] = None,
) -> RequestPhoneNumberResult

Request an origination phone number for use in your account. For more information on phone number request see Request a phone number in the End User Messaging SMS User Guide.

Parameters:

  • iso_country_code (IsoCountryCode) –

    The two-character code, in ISO 3166-1 alpha-2 format, for the country or region.

  • message_type (MessageType) –

    The type of message. Valid values are TRANSACTIONAL for messages that are critical or time-sensitive and PROMOTIONAL for messages that aren't critical or time-sensitive.

  • number_capabilities (NumberCapabilityList) –

    Indicates if the phone number will be used for text messages, voice messages, or both.

  • number_type (RequestableNumberType) –

    The type of phone number to request.

    When you request a SIMULATOR phone number, you must set MessageType as TRANSACTIONAL.

  • opt_out_list_name (Optional[OptOutListNameOrArn], default: None ) –

    The name of the OptOutList to associate with the phone number. You can use the OptOutListName or OptOutListArn.

    If you are using a shared End User Messaging SMS resource then you must use the full Amazon Resource Name(ARN).

  • pool_id (Optional[PoolIdOrArn], default: None ) –

    The pool to associated with the phone number. You can use the PoolId or PoolArn.

    If you are using a shared End User Messaging SMS resource then you must use the full Amazon Resource Name(ARN).

  • registration_id (Optional[RegistrationIdOrArn], default: None ) –

    Use this field to attach your phone number for an external registration process.

  • number_preference (Optional[NumberPreferenceList], default: None ) –

    An optional selection preference used to request a specific phone number, such as a number that starts with, ends with, or contains a particular digit pattern. You can specify at most one preference. Number preferences apply only to TEN_DLC requests in the US.

  • international_sending_enabled (Optional[bool], default: None ) –

    By default this is set to false. When set to true the international sending of phone number is Enabled.

  • deletion_protection_enabled (Optional[bool], default: None ) –

    By default this is set to false. When set to true the phone number can't be deleted.

  • tags (Optional[TagList], default: None ) –

    An array of tags (key and value pairs) to associate with the requested phone number.

  • client_token (Optional[ClientToken], default: None ) –

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you don't specify a client token, a randomly generated token is used for the request to ensure idempotency.

Raises:

  • AccessDeniedException –

    The request was denied because you don't have sufficient permissions to access the resource.

  • ConflictException –

    Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time or it could be that the requested action isn't valid for the current state or configuration of the resource.

  • InternalServerException –

    The API encountered an unexpected error and couldn't complete the request. You might be able to successfully issue the request again in the future.

  • ResourceNotFoundException –

    A requested resource couldn't be found.

  • ServiceQuotaExceededException –

    The request would cause a service quota to be exceeded.

  • ThrottlingException –

    An error that occurred because too many requests were sent during a certain amount of time.

  • ValidationException –

    A validation exception for a field.

  • UnknownServiceError –

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

Source code in docs_src/capo_pinpoint_sms_voice_v2/_services/async_pinpoint_sms_voice_v2.py
async def request_phone_number(
    self,
    iso_country_code: "capo_pinpoint_sms_voice_v2.types.iso_country_code.IsoCountryCode",
    message_type: "capo_pinpoint_sms_voice_v2.types.message_type.MessageType",
    number_capabilities: "capo_pinpoint_sms_voice_v2.types.number_capability_list.NumberCapabilityList",
    number_type: "capo_pinpoint_sms_voice_v2.types.requestable_number_type.RequestableNumberType",
    *,
    config_overrides: Optional[AsyncPinpointSMSVoiceV2ClientConfig] = None,
    opt_out_list_name: Optional[
        "capo_pinpoint_sms_voice_v2.types.opt_out_list_name_or_arn.OptOutListNameOrArn"
    ] = None,
    pool_id: Optional[
        "capo_pinpoint_sms_voice_v2.types.pool_id_or_arn.PoolIdOrArn"
    ] = None,
    registration_id: Optional[
        "capo_pinpoint_sms_voice_v2.types.registration_id_or_arn.RegistrationIdOrArn"
    ] = None,
    number_preference: Optional[
        "capo_pinpoint_sms_voice_v2.types.number_preference_list.NumberPreferenceList"
    ] = None,
    international_sending_enabled: Optional[bool] = None,
    deletion_protection_enabled: Optional[bool] = None,
    tags: Optional["capo_pinpoint_sms_voice_v2.types.tag_list.TagList"] = None,
    client_token: Optional[
        "capo_pinpoint_sms_voice_v2.types.client_token.ClientToken"
    ] = None,
) -> "capo_pinpoint_sms_voice_v2.types.request_phone_number_result.RequestPhoneNumberResult":
    """<p>Request an origination phone number for use in your account. For more information on phone number request see <a href="https://docs.aws.amazon.com/sms-voice/latest/userguide/phone-numbers-request.html">Request a phone number</a> in the <i>End User Messaging SMS User Guide</i>.</p>

    Args:
        iso_country_code: <p>The two-character code, in ISO 3166-1 alpha-2 format, for the country or region. </p>
        message_type: <p>The type of message. Valid values are <code>TRANSACTIONAL</code> for messages that are critical or time-sensitive and <code>PROMOTIONAL</code> for messages that aren't critical or time-sensitive.</p>
        number_capabilities: <p>Indicates if the phone number will be used for text messages, voice messages, or both. </p>
        number_type: <p>The type of phone number to request.</p> <p>When you request a <code>SIMULATOR</code> phone number, you must set <b>MessageType</b> as <code>TRANSACTIONAL</code>. </p>
        opt_out_list_name: <p>The name of the OptOutList to associate with the phone number. You can use the OptOutListName or OptOutListArn.</p> <important> <p>If you are using a shared End User Messaging SMS resource then you must use the full Amazon Resource Name(ARN).</p> </important>
        pool_id: <p>The pool to associated with the phone number. You can use the PoolId or PoolArn. </p> <important> <p>If you are using a shared End User Messaging SMS resource then you must use the full Amazon Resource Name(ARN).</p> </important>
        registration_id: <p>Use this field to attach your phone number for an external registration process.</p>
        number_preference: <p>An optional selection preference used to request a specific phone number, such as a number that starts with, ends with, or contains a particular digit pattern. You can specify at most one preference. Number preferences apply only to <code>TEN_DLC</code> requests in the <code>US</code>.</p>
        international_sending_enabled: <p>By default this is set to false. When set to true the international sending of phone number is Enabled. </p>
        deletion_protection_enabled: <p>By default this is set to false. When set to true the phone number can't be deleted.</p>
        tags: <p>An array of tags (key and value pairs) to associate with the requested phone number. </p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you don't specify a client token, a randomly generated token is used for the request to ensure idempotency.</p>

    Raises:
        capo_pinpoint_sms_voice_v2.errors.access_denied_exception.AccessDeniedException: <p>The request was denied because you don't have sufficient permissions to access the resource.</p>
        capo_pinpoint_sms_voice_v2.errors.conflict_exception.ConflictException: <p>Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time or it could be that the requested action isn't valid for the current state or configuration of the resource.</p>
        capo_pinpoint_sms_voice_v2.errors.internal_server_exception.InternalServerException: <p>The API encountered an unexpected error and couldn't complete the request. You might be able to successfully issue the request again in the future.</p>
        capo_pinpoint_sms_voice_v2.errors.resource_not_found_exception.ResourceNotFoundException: <p>A requested resource couldn't be found.</p>
        capo_pinpoint_sms_voice_v2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota to be exceeded.</p>
        capo_pinpoint_sms_voice_v2.errors.throttling_exception.ThrottlingException: <p>An error that occurred because too many requests were sent during a certain amount of time.</p>
        capo_pinpoint_sms_voice_v2.errors.validation_exception.ValidationException: <p>A validation exception for a field.</p>
        capo_pinpoint_sms_voice_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_pinpoint_sms_voice_v2.types.request_phone_number_request.RequestPhoneNumberRequest]",
    ) -> AsyncOperationResponse[
        "capo_pinpoint_sms_voice_v2.types.request_phone_number_result.RequestPhoneNumberResult"
    ]:
        import capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.request_phone_number

        (
            output,
            http_response,
        ) = await capo_pinpoint_sms_voice_v2._operations.pinpoint_sms_voice_v2.request_phone_number.async_request_phone_number(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("RequestPhoneNumber")
    )
    input_: capo_pinpoint_sms_voice_v2.types.request_phone_number_request.RequestPhoneNumberRequest = {
        "iso_country_code": iso_country_code,
        "message_type": message_type,
        "number_capabilities": number_capabilities,
        "number_type": number_type,
    }
    if opt_out_list_name is not None:
        input_["opt_out_list_name"] = opt_out_list_name
    if pool_id is not None:
        input_["pool_id"] = pool_id
    if registration_id is not None:
        input_["registration_id"] = registration_id
    if number_preference is not None:
        input_["number_preference"] = number_preference
    if international_sending_enabled is not None:
        input_["international_sending_enabled"] = international_sending_enabled
    if deletion_protection_enabled is not None:
        input_["deletion_protection_enabled"] = deletion_protection_enabled
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output