Skip to content

initiate_point_in_time_recovery async

initiate_point_in_time_recovery(
    user_pool_id: UserPoolIdType,
    restore_timestamp: DateType,
    *,
    config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
) -> InitiatePointInTimeRecoveryResponse

Initiates a point-in-time recovery of a user pool to a time in the past that you specify. This operation is the first step of a recovery and doesn't change your user pool data. Amazon Cognito pauses write operations in the user pool and generates a recovery preview, which might not be available immediately. The preview shows the number of entities that the recovery creates, updates, and deletes. To check the status of the recovery and review the preview, make a request. When the status is PREVIEW_GENERATED, apply the recovery with a request or discard it with a request. The time that it takes to generate the recovery preview doesn't depend on the size of your user pool.

Point-in-time recovery is a disaster recovery feature. Use it to recover from accidental or unauthorized changes that affect your user data, for example the deletion or corruption of many users. Don't use point-in-time recovery to remove users that were created recently or to revert changes to individual users. To delete or update individual users, use operations like and .

While a recovery is in progress, Amazon Cognito blocks operations that write to the user pool, for example user sign-up, user creation, and attribute updates. Sign-in and read operations continue to work, with the following exceptions:

  • Users who must set a new password, set up MFA, or respond to a TOTP MFA challenge can't complete sign-in. Sign-in with the NEW_PASSWORD_REQUIRED, MFA_SETUP, and SOFTWARE_TOKEN_MFA challenges fails until the recovery ends.

  • Federated users can sign in only if they have previously signed in to the user pool and their attributes from the external identity provider haven't changed.

  • You can't create or start user import jobs. Start your import jobs after the recovery ends.

If you don't start or cancel the recovery within 24 hours after you initiate it, the recovery preview expires. Amazon Cognito then resumes write operations and doesn't change your user pool data. The 24-hour period includes the time that Amazon Cognito takes to generate the recovery preview.

A point-in-time recovery restores user data, including user profiles and attributes, group memberships, passwords, MFA settings, and passkeys. It doesn't restore user pool configuration, for example app clients, the attribute schema, encryption settings, or multi-Region replication settings. Users who changed their password after the recovery point keep their current password.

The following requirements and limits apply to point-in-time recovery:

  • Your user pool must be on the Essentials or Plus feature plan. With the Essentials feature plan, you can recover your user pool to a point in time up to 1 day in the past. With the Plus feature plan, you can recover up to 14 days in the past. Your user pool must have been on the required feature plan at the recovery point. For example, to recover to a point in time 14 days ago, your user pool must have been on the Plus feature plan for the past 14 days.

  • The recovery point must be at least 15 minutes in the past and can't be earlier than the creation time of the user pool.

  • A user pool can have only one active recovery at a time.

  • An Amazon Web Services account can have up to five active recoveries at a time across all of its user pools. An organization in Amazon Web Services Organizations can have up to ten active recoveries at a time across all of its accounts.

  • You can complete one recovery of a user pool in a 24-hour period.

  • You can create up to three recovery previews of a user pool, ten recovery previews in an Amazon Web Services account, and 15 recovery previews in an organization in Amazon Web Services Organizations in a 24-hour period. You can create up to ten recovery previews of a user pool in a 30-day period.

  • You can't initiate a recovery while a user import job is in progress in your user pool. Wait for the import job to complete, or stop it with a request, and then initiate the recovery.

  • In a user pool with multi-Region replication, you can initiate a recovery only in the primary Amazon Web Services Region, and only after replication is complete.

  • If your user pool uses a customer managed key in KMS for encryption, the key must remain enabled and accessible to Amazon Cognito for the duration of the recovery.

  • Some user pools don't support point-in-time recovery, for example some older user pools and user pools that contain user data with characters or formats that point-in-time recovery doesn't support. If your user pool doesn't support it, Amazon Cognito returns an error when you initiate a recovery. To get help with this limitation, contact Amazon Web Services Support.

Amazon Cognito evaluates Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you must use IAM credentials to authorize requests, and you must grant yourself the corresponding IAM permission in a policy.

Learn more

Parameters:

  • user_pool_id (UserPoolIdType) –

    The ID of the user pool that you want to recover.

  • restore_timestamp (DateType) –

    The point in time that you want to recover your user pool to. Amazon Cognito reverts changes to user data that occurred after this time. The recovery point must be at least 15 minutes in the past and within the recovery period of your user pool feature plan: up to 1 day in the past with the Essentials feature plan, or up to 14 days in the past with the Plus feature plan.

Raises:

  • ConcurrentModificationException –

    This exception is thrown if two or more modifications are happening concurrently.

  • FeatureUnavailableInTierException –

    This exception is thrown when a feature that you attempted to use or configure isn't included in your user pool's current feature plan. This can occur when:

    • You configure a feature that your feature plan doesn't support.

    • You make a request that uses a feature that requires a higher feature plan.

    To resolve this issue, upgrade your user pool to a feature plan that includes the feature.

  • InternalErrorException –

    This exception is thrown when Amazon Cognito encounters an internal error.

  • InvalidParameterException –

    This exception is thrown when the Amazon Cognito service encounters an invalid parameter.

  • LimitExceededException –

    This exception is thrown when a user exceeds the limit for a requested Amazon Web Services resource.

  • NotAuthorizedException –

    This exception is thrown when a user isn't authorized.

  • OperationNotEnabledException –

    This exception is thrown when an operation is not available in the current region or for the current user pool configuration. This can occur when attempting to perform operations that are not supported in secondary replica regions.

  • ResourceNotFoundException –

    This exception is thrown when the Amazon Cognito service can't find the requested resource.

  • TooManyRequestsException –

    This exception is thrown when the user has made too many requests for a given operation.

  • UnknownServiceError –

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

Source code in docs_src/capo_cognito_identity_provider/_services/async_cognito_identity_provider.py
async def initiate_point_in_time_recovery(
    self,
    user_pool_id: "capo_cognito_identity_provider.types.user_pool_id_type.UserPoolIdType",
    restore_timestamp: "capo_cognito_identity_provider.types.date_type.DateType",
    *,
    config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
) -> "capo_cognito_identity_provider.types.initiate_point_in_time_recovery_response.InitiatePointInTimeRecoveryResponse":
    """<p>Initiates a point-in-time recovery of a user pool to a time in the past that you specify. This operation is the first step of a recovery and doesn't change your user pool data. Amazon Cognito pauses write operations in the user pool and generates a recovery preview, which might not be available immediately. The preview shows the number of entities that the recovery creates, updates, and deletes. To check the status of the recovery and review the preview, make a request. When the status is <code>PREVIEW_GENERATED</code>, apply the recovery with a request or discard it with a request. The time that it takes to generate the recovery preview doesn't depend on the size of your user pool.</p> <important> <p>Point-in-time recovery is a disaster recovery feature. Use it to recover from accidental or unauthorized changes that affect your user data, for example the deletion or corruption of many users. Don't use point-in-time recovery to remove users that were created recently or to revert changes to individual users. To delete or update individual users, use operations like and .</p> </important> <p>While a recovery is in progress, Amazon Cognito blocks operations that write to the user pool, for example user sign-up, user creation, and attribute updates. Sign-in and read operations continue to work, with the following exceptions:</p> <ul> <li> <p>Users who must set a new password, set up MFA, or respond to a TOTP MFA challenge can't complete sign-in. Sign-in with the <code>NEW_PASSWORD_REQUIRED</code>, <code>MFA_SETUP</code>, and <code>SOFTWARE_TOKEN_MFA</code> challenges fails until the recovery ends.</p> </li> <li> <p>Federated users can sign in only if they have previously signed in to the user pool and their attributes from the external identity provider haven't changed.</p> </li> <li> <p>You can't create or start user import jobs. Start your import jobs after the recovery ends.</p> </li> </ul> <p>If you don't start or cancel the recovery within 24 hours after you initiate it, the recovery preview expires. Amazon Cognito then resumes write operations and doesn't change your user pool data. The 24-hour period includes the time that Amazon Cognito takes to generate the recovery preview.</p> <p>A point-in-time recovery restores user data, including user profiles and attributes, group memberships, passwords, MFA settings, and passkeys. It doesn't restore user pool configuration, for example app clients, the attribute schema, encryption settings, or multi-Region replication settings. Users who changed their password after the recovery point keep their current password.</p> <p>The following requirements and limits apply to point-in-time recovery:</p> <ul> <li> <p>Your user pool must be on the Essentials or Plus <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-sign-in-feature-plans.html">feature plan</a>. With the Essentials feature plan, you can recover your user pool to a point in time up to 1 day in the past. With the Plus feature plan, you can recover up to 14 days in the past. Your user pool must have been on the required feature plan at the recovery point. For example, to recover to a point in time 14 days ago, your user pool must have been on the Plus feature plan for the past 14 days.</p> </li> <li> <p>The recovery point must be at least 15 minutes in the past and can't be earlier than the creation time of the user pool.</p> </li> <li> <p>A user pool can have only one active recovery at a time.</p> </li> <li> <p>An Amazon Web Services account can have up to five active recoveries at a time across all of its user pools. An organization in Amazon Web Services Organizations can have up to ten active recoveries at a time across all of its accounts.</p> </li> <li> <p>You can complete one recovery of a user pool in a 24-hour period.</p> </li> <li> <p>You can create up to three recovery previews of a user pool, ten recovery previews in an Amazon Web Services account, and 15 recovery previews in an organization in Amazon Web Services Organizations in a 24-hour period. You can create up to ten recovery previews of a user pool in a 30-day period.</p> </li> <li> <p>You can't initiate a recovery while a user import job is in progress in your user pool. Wait for the import job to complete, or stop it with a request, and then initiate the recovery.</p> </li> <li> <p>In a user pool with multi-Region replication, you can initiate a recovery only in the primary Amazon Web Services Region, and only after replication is complete.</p> </li> <li> <p>If your user pool uses a customer managed key in KMS for encryption, the key must remain enabled and accessible to Amazon Cognito for the duration of the recovery.</p> </li> <li> <p>Some user pools don't support point-in-time recovery, for example some older user pools and user pools that contain user data with characters or formats that point-in-time recovery doesn't support. If your user pool doesn't support it, Amazon Cognito returns an error when you initiate a recovery. To get help with this limitation, contact Amazon Web Services Support.</p> </li> </ul> <note> <p>Amazon Cognito evaluates Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you must use IAM credentials to authorize requests, and you must grant yourself the corresponding IAM permission in a policy.</p> <p class="title"> <b>Learn more</b> </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html">Signing Amazon Web Services API Requests</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pools-API-operations.html">Using the Amazon Cognito user pools API and user pool endpoints</a> </p> </li> </ul> </note>

    Args:
        user_pool_id: <p>The ID of the user pool that you want to recover.</p>
        restore_timestamp: <p>The point in time that you want to recover your user pool to. Amazon Cognito reverts changes to user data that occurred after this time. The recovery point must be at least 15 minutes in the past and within the recovery period of your user pool feature plan: up to 1 day in the past with the Essentials feature plan, or up to 14 days in the past with the Plus feature plan.</p>

    Raises:
        capo_cognito_identity_provider.errors.concurrent_modification_exception.ConcurrentModificationException: <p>This exception is thrown if two or more modifications are happening concurrently.</p>
        capo_cognito_identity_provider.errors.feature_unavailable_in_tier_exception.FeatureUnavailableInTierException: <p>This exception is thrown when a feature that you attempted to use or configure isn't included in your user pool's current feature plan. This can occur when:</p> <ul> <li> <p>You configure a feature that your feature plan doesn't support.</p> </li> <li> <p>You make a request that uses a feature that requires a higher feature plan.</p> </li> </ul> <p>To resolve this issue, upgrade your user pool to a feature plan that includes the feature.</p>
        capo_cognito_identity_provider.errors.internal_error_exception.InternalErrorException: <p>This exception is thrown when Amazon Cognito encounters an internal error.</p>
        capo_cognito_identity_provider.errors.invalid_parameter_exception.InvalidParameterException: <p>This exception is thrown when the Amazon Cognito service encounters an invalid parameter.</p>
        capo_cognito_identity_provider.errors.limit_exceeded_exception.LimitExceededException: <p>This exception is thrown when a user exceeds the limit for a requested Amazon Web Services resource.</p>
        capo_cognito_identity_provider.errors.not_authorized_exception.NotAuthorizedException: <p>This exception is thrown when a user isn't authorized.</p>
        capo_cognito_identity_provider.errors.operation_not_enabled_exception.OperationNotEnabledException: <p>This exception is thrown when an operation is not available in the current region or for the current user pool configuration. This can occur when attempting to perform operations that are not supported in secondary replica regions.</p>
        capo_cognito_identity_provider.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when the Amazon Cognito service can't find the requested resource.</p>
        capo_cognito_identity_provider.errors.too_many_requests_exception.TooManyRequestsException: <p>This exception is thrown when the user has made too many requests for a given operation.</p>
        capo_cognito_identity_provider.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cognito_identity_provider.types.initiate_point_in_time_recovery_request.InitiatePointInTimeRecoveryRequest]",
    ) -> AsyncOperationResponse[
        "capo_cognito_identity_provider.types.initiate_point_in_time_recovery_response.InitiatePointInTimeRecoveryResponse"
    ]:
        import capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.initiate_point_in_time_recovery

        (
            output,
            http_response,
        ) = await capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.initiate_point_in_time_recovery.async_initiate_point_in_time_recovery(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("InitiatePointInTimeRecovery")
    )
    input_: capo_cognito_identity_provider.types.initiate_point_in_time_recovery_request.InitiatePointInTimeRecoveryRequest = {
        "user_pool_id": user_pool_id,
        "restore_timestamp": restore_timestamp,
    }

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