def METHOD_NAME(engagement: EngagementWithCredentials, *, client_configuration: QCSClientConfiguration):
    """
    Apply and respond with an engagement when it matches.
    """
    if engagement.endpoint_id == DEFAULT_ENDPOINT_ID:
        json = {"quantumProcessorId": engagement.quantum_processor_ids[0]}
    else:
        json = {"quantumProcessorId": engagement.quantum_processor_ids[0], "endpointId": engagement.endpoint_id}
    respx.post(url=f"{client_configuration.profile.api_url}/v1/engagements", json=json).respond(
        json=engagement.to_dict()
    )