Skip to content

stop_contact async

stop_contact(
    contact_id: ContactId,
    instance_id: InstanceId,
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    disconnect_reason: Optional[DisconnectReason] = None,
) -> StopContactResponse

Ends the specified contact. Use this API to stop queued callbacks. It does not work for voice contacts that use the following initiation methods:

  • DISCONNECT

  • TRANSFER

  • QUEUE_TRANSFER

  • EXTERNAL_OUTBOUND

  • MONITOR

Chat and task contacts can be terminated in any state, regardless of initiation method.

Parameters:

  • contact_id (ContactId) –

    The ID of the contact.

  • instance_id (InstanceId) –

    The identifier of the Connect Customer instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.

  • disconnect_reason (Optional[DisconnectReason], default: None ) –

    The reason a contact can be disconnected. Only Connect Customer outbound campaigns can provide this field. For a list and description of all the possible disconnect reasons by channel (including outbound campaign voice contacts) see DisconnectReason under ContactTraceRecord in the Connect Customer Administrator Guide.

Raises:

Source code in docs_src/capo_connect/_services/async_connect.py
async def stop_contact(
    self,
    contact_id: "capo_connect.types.contact_id.ContactId",
    instance_id: "capo_connect.types.instance_id.InstanceId",
    *,
    config_overrides: Optional[AsyncConnectClientConfig] = None,
    disconnect_reason: Optional[
        "capo_connect.types.disconnect_reason.DisconnectReason"
    ] = None,
) -> "capo_connect.types.stop_contact_response.StopContactResponse":
    """<p>Ends the specified contact. Use this API to stop queued callbacks. It does not work for voice contacts that use the following initiation methods:</p> <ul> <li> <p>DISCONNECT</p> </li> <li> <p>TRANSFER</p> </li> <li> <p>QUEUE_TRANSFER</p> </li> <li> <p>EXTERNAL_OUTBOUND</p> </li> <li> <p>MONITOR</p> </li> </ul> <p>Chat and task contacts can be terminated in any state, regardless of initiation method.</p>

    Args:
        contact_id: <p>The ID of the contact.</p>
        instance_id: <p>The identifier of the Connect Customer instance. You can <a href="https://docs.aws.amazon.com/connect/latest/adminguide/find-instance-arn.html">find the instance ID</a> in the Amazon Resource Name (ARN) of the instance.</p>
        disconnect_reason: <p>The reason a contact can be disconnected. Only Connect Customer outbound campaigns can provide this field. For a list and description of all the possible disconnect reasons by channel (including outbound campaign voice contacts) see DisconnectReason under <a href="https://docs.aws.amazon.com/connect/latest/adminguide/ctr-data-model.html#ctr-ContactTraceRecord">ContactTraceRecord</a> in the <i>Connect Customer Administrator Guide</i>. </p>

    Raises:
        capo_connect.errors.contact_not_found_exception.ContactNotFoundException: <p>The contact with the specified ID does not exist.</p>
        capo_connect.errors.internal_service_exception.InternalServiceException: <p>Request processing failed because of an error or failure with the service.</p>
        capo_connect.errors.invalid_active_region_exception.InvalidActiveRegionException: <p>This exception occurs when an API request is made to a non-active region in an Amazon Connect instance configured with Amazon Connect Global Resiliency. For example, if the active region is US West (Oregon) and a request is made to US East (N. Virginia), the exception will be returned.</p>
        capo_connect.errors.invalid_parameter_exception.InvalidParameterException: <p>One or more of the specified parameters are not valid.</p>
        capo_connect.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
        capo_connect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found.</p>
        capo_connect.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_connect.types.stop_contact_request.StopContactRequest]",
    ) -> AsyncOperationResponse[
        "capo_connect.types.stop_contact_response.StopContactResponse"
    ]:
        import capo_connect._operations.amazon_connect_service.stop_contact

        (
            output,
            http_response,
        ) = await capo_connect._operations.amazon_connect_service.stop_contact.async_stop_contact(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StopContact")
    )
    input_: capo_connect.types.stop_contact_request.StopContactRequest = {
        "contact_id": contact_id,
        "instance_id": instance_id,
    }
    if disconnect_reason is not None:
        input_["disconnect_reason"] = disconnect_reason

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