Skip to content

create_contact async

create_contact(
    contact_list_name: ContactListName,
    email_address: EmailAddress,
    *,
    config_overrides: Optional[AsyncSESv2ClientConfig] = None,
    topic_preferences: Optional[TopicPreferenceList] = None,
    unsubscribe_all: Optional[UnsubscribeAll] = None,
    attributes_data: Optional[AttributesData] = None,
) -> CreateContactResponse

Creates a contact, which is an end-user who is receiving the email, and adds them to a contact list.

Parameters:

  • contact_list_name (ContactListName) –

    The name of the contact list to which the contact should be added.

  • email_address (EmailAddress) –

    The contact's email address.

  • topic_preferences (Optional[TopicPreferenceList], default: None ) –

    The contact's preferences for being opted-in to or opted-out of topics.

  • unsubscribe_all (Optional[UnsubscribeAll], default: None ) –

    A boolean value status noting if the contact is unsubscribed from all contact list topics.

  • attributes_data (Optional[AttributesData], default: None ) –

    The attribute data attached to a contact.

Raises:

Source code in docs_src/capo_sesv2/_services/async_se_sv2.py
async def create_contact(
    self,
    contact_list_name: "capo_sesv2.types.contact_list_name.ContactListName",
    email_address: "capo_sesv2.types.email_address.EmailAddress",
    *,
    config_overrides: Optional[AsyncSESv2ClientConfig] = None,
    topic_preferences: Optional[
        "capo_sesv2.types.topic_preference_list.TopicPreferenceList"
    ] = None,
    unsubscribe_all: Optional[
        "capo_sesv2.types.unsubscribe_all.UnsubscribeAll"
    ] = None,
    attributes_data: Optional[
        "capo_sesv2.types.attributes_data.AttributesData"
    ] = None,
) -> "capo_sesv2.types.create_contact_response.CreateContactResponse":
    """<p>Creates a contact, which is an end-user who is receiving the email, and adds them to a contact list.</p>

    Args:
        contact_list_name: <p>The name of the contact list to which the contact should be added.</p>
        email_address: <p>The contact's email address.</p>
        topic_preferences: <p>The contact's preferences for being opted-in to or opted-out of topics.</p>
        unsubscribe_all: <p>A boolean value status noting if the contact is unsubscribed from all contact list topics.</p>
        attributes_data: <p>The attribute data attached to a contact.</p>

    Raises:
        capo_sesv2.errors.already_exists_exception.AlreadyExistsException: <p>The resource specified in your request already exists.</p>
        capo_sesv2.errors.bad_request_exception.BadRequestException: <p>The input you provided is invalid.</p>
        capo_sesv2.errors.not_found_exception.NotFoundException: <p>The resource you attempted to access doesn't exist.</p>
        capo_sesv2.errors.too_many_requests_exception.TooManyRequestsException: <p>Too many requests have been made to the operation.</p>
        capo_sesv2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sesv2.types.create_contact_request.CreateContactRequest]",
    ) -> AsyncOperationResponse[
        "capo_sesv2.types.create_contact_response.CreateContactResponse"
    ]:
        import capo_sesv2._operations.simple_email_service_v2.create_contact

        (
            output,
            http_response,
        ) = await capo_sesv2._operations.simple_email_service_v2.create_contact.async_create_contact(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateContact")
    )
    input_: capo_sesv2.types.create_contact_request.CreateContactRequest = {
        "contact_list_name": contact_list_name,
        "email_address": email_address,
    }
    if topic_preferences is not None:
        input_["topic_preferences"] = topic_preferences
    if unsubscribe_all is not None:
        input_["unsubscribe_all"] = unsubscribe_all
    if attributes_data is not None:
        input_["attributes_data"] = attributes_data

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