Skip to content

post_whats_app_message_media async

post_whats_app_message_media(
    origination_phone_number_id: WhatsAppPhoneNumberId,
    *,
    config_overrides: Optional[AsyncSocialMessagingClientConfig] = None,
    source_s3_presigned_url: Optional[S3PresignedUrl] = None,
    source_s3_file: Optional[S3File] = None,
) -> PostWhatsAppMessageMediaOutput

Upload a media file to the WhatsApp service. Only the specified originationPhoneNumberId has the permissions to send the media file when using SendWhatsAppMessage. You must use either sourceS3File or sourceS3PresignedUrl for the source. If both or neither are specified then an InvalidParameterException is returned.

Parameters:

  • origination_phone_number_id (WhatsAppPhoneNumberId) –

    The ID of the phone number to associate with the WhatsApp media file. The phone number identifiers are formatted as phone-number-id-01234567890123456789012345678901. Use GetLinkedWhatsAppBusinessAccount to find a phone number's id.

  • source_s3_presigned_url (Optional[S3PresignedUrl], default: None ) –

    The source presign url of the media file.

  • source_s3_file (Optional[S3File], default: None ) –

    The source S3 url for the media file.

Raises:

Source code in docs_src/capo_socialmessaging/_services/async_social_messaging.py
async def post_whats_app_message_media(
    self,
    origination_phone_number_id: "capo_socialmessaging.types.whats_app_phone_number_id.WhatsAppPhoneNumberId",
    *,
    config_overrides: Optional[AsyncSocialMessagingClientConfig] = None,
    source_s3_presigned_url: Optional[
        "capo_socialmessaging.types.s3_presigned_url.S3PresignedUrl"
    ] = None,
    source_s3_file: Optional["capo_socialmessaging.types.s3_file.S3File"] = None,
) -> "capo_socialmessaging.types.post_whats_app_message_media_output.PostWhatsAppMessageMediaOutput":
    """<p>Upload a media file to the WhatsApp service. Only the specified <code>originationPhoneNumberId</code> has the permissions to send the media file when using <a href="https://docs.aws.amazon.com/social-messaging/latest/APIReference/API_SendWhatsAppMessage.html">SendWhatsAppMessage</a>. You must use either <code>sourceS3File</code> or <code>sourceS3PresignedUrl</code> for the source. If both or neither are specified then an <code>InvalidParameterException</code> is returned.</p>

    Args:
        origination_phone_number_id: <p>The ID of the phone number to associate with the WhatsApp media file. The phone number identifiers are formatted as <code>phone-number-id-01234567890123456789012345678901</code>. Use <a href="https://docs.aws.amazon.com/social-messaging/latest/APIReference/API_GetLinkedWhatsAppBusinessAccount.html">GetLinkedWhatsAppBusinessAccount</a> to find a phone number's id.</p>
        source_s3_presigned_url: <p>The source presign url of the media file.</p>
        source_s3_file: <p>The source S3 url for the media file.</p>

    Raises:
        capo_socialmessaging.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_socialmessaging.errors.validation_exception.ValidationException: <p>The request contains an invalid parameter value. </p>
        capo_socialmessaging.errors.access_denied_by_meta_exception.AccessDeniedByMetaException: <p>You do not have sufficient access to perform this action.</p>
        capo_socialmessaging.errors.dependency_exception.DependencyException: <p>Thrown when performing an action because a dependency would be broken.</p>
        capo_socialmessaging.errors.internal_service_exception.InternalServiceException: <p>The request processing has failed because of an unknown error, exception, or failure.</p>
        capo_socialmessaging.errors.invalid_parameters_exception.InvalidParametersException: <p>One or more parameters provided to the action are not valid.</p>
        capo_socialmessaging.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource was not found.</p>
        capo_socialmessaging.errors.throttled_request_exception.ThrottledRequestException: <p>The request was denied due to request throttling.</p>
        capo_socialmessaging.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_socialmessaging.types.post_whats_app_message_media_input.PostWhatsAppMessageMediaInput]",
    ) -> AsyncOperationResponse[
        "capo_socialmessaging.types.post_whats_app_message_media_output.PostWhatsAppMessageMediaOutput"
    ]:
        import capo_socialmessaging._operations.social_messaging.post_whats_app_message_media

        (
            output,
            http_response,
        ) = await capo_socialmessaging._operations.social_messaging.post_whats_app_message_media.async_post_whats_app_message_media(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_socialmessaging.types.post_whats_app_message_media_input.PostWhatsAppMessageMediaInput",
    ) -> dict[str, Any]:
        import capo_socialmessaging.types.post_whats_app_message_media_input

        return capo_socialmessaging.types.post_whats_app_message_media_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("PostWhatsAppMessageMedia", redact_input=_redact_input),
    )
    input_: capo_socialmessaging.types.post_whats_app_message_media_input.PostWhatsAppMessageMediaInput = {
        "origination_phone_number_id": origination_phone_number_id
    }
    if source_s3_presigned_url is not None:
        input_["source_s3_presigned_url"] = source_s3_presigned_url
    if source_s3_file is not None:
        input_["source_s3_file"] = source_s3_file

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