Name:
interface
Value:
Extend your Amplify Gen 2 app with AWS Blocks — self-contained backend capabilities you compose into your existing backend.

API Reference

associateWebAuthnCredential

Registers a new passkey for an authenticated user

Throws

  • PasskeyError:
    • Thrown when intermediate state is invalid
  • AuthError:
    • Thrown when user is unauthenticated
  • StartWebAuthnRegistrationException
    • Thrown due to a service error retrieving WebAuthn registration options
  • CompleteWebAuthnRegistrationException
    • Thrown due to a service error when verifying WebAuthn registration result

Returns

Promise<void>

confirmResetPassword

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<void>

confirmResetPassword

Confirms the new password and verification code to reset the password.

Parameters

OptionRequiredTypeDescription
inputtrue
The ConfirmResetPasswordInput object.

Throws

  • ConfirmForgotPasswordException Thrown due to an invalid confirmation code or password.
  • AuthValidationErrorCode Thrown due to an empty confirmation code, password or username.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

confirmSignIn

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<>
Output type for Cognito confirmSignIn API.

confirmSignIn

Continues or completes the sign in process when required by the initial call to signIn.

Parameters

OptionRequiredTypeDescription
inputtrue
The ConfirmSignInInput object

Throws

  • VerifySoftwareTokenException: Thrown due to an invalid MFA token.
  • RespondToAuthChallengeException: Thrown due to an invalid auth challenge response.
  • AssociateSoftwareTokenException: Thrown due to a service error during the MFA setup process.
  • AuthValidationErrorCode: Thrown when challengeResponse is not defined.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito confirmSignIn API.

confirmSignUp

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<>
Output type for Cognito confirmSignUp API.

confirmSignUp

Confirms a new user account.

Parameters

OptionRequiredTypeDescription
inputtrue
The ConfirmSignUpInput object.

Throws

  • ConfirmSignUpException Thrown due to an invalid confirmation code.
  • AuthValidationErrorCode Thrown due to an empty confirmation code
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito confirmSignUp API.

confirmUserAttribute

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<void>

confirmUserAttribute

Confirms a user attribute with the confirmation code.

Parameters

OptionRequiredTypeDescription
inputtrue
The ConfirmUserAttributeInput object

Throws

  • AuthValidationErrorCode - Thrown when confirmationCode is not defined.
  • VerifyUserAttributeException - Thrown due to an invalid confirmation code or attribute.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

decodeJWT

Decodes payload of JWT token

Parameters

OptionRequiredTypeDescription
tokentruestring
A string representing a token to be decoded

Throws

  • Error - Throws error when token is invalid or payload malformed.

deleteUser

Parameters

OptionRequiredTypeDescription
ctxtrue

Returns

Promise<void>

deleteUser

Deletes a user from the user pool while authenticated.

Throws

  • DeleteUserException
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

deleteUserAttributes

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<void>

deleteUserAttributes

Deletes user attributes.

Parameters

OptionRequiredTypeDescription
inputtrue
The DeleteUserAttributesInput object

Throws

  • DeleteUserAttributesException - Thrown due to invalid attribute.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

deleteWebAuthnCredential

Delete a registered credential for an authenticated user by credentialId

Parameters

OptionRequiredTypeDescription
inputtrue
The delete input parameters including the credentialId

Throws

  • AuthError:
    • Thrown when user is unauthenticated
  • DeleteWebAuthnCredentialException
    • Thrown due to a service error when deleting a WebAuthn credential

Returns

Promise<void>

fetchAuthSession

Fetch the auth session of the given AmplifyContext — e.g. the per-request context handed to an SSR runWithAmplifyServerContext operation — instead of the global context. This restores the pre-context v6 SSR calling pattern fetchAuthSession(contextSpec) (the deprecated ContextSpec type is an alias of AmplifyContext, so existing SSR code compiles unchanged).

Parameters

OptionRequiredTypeDescription
ctxtrue
The explicit AmplifyContext whose auth providers are used.
optionsfalse
Options configuring the fetch behavior.

Throws

  • AuthError - Throws error when session information cannot be refreshed.

Returns

Promise<>

fetchAuthSession

Fetch the auth session including the tokens and credentials if they are available. By default it will automatically refresh expired auth tokens if a valid refresh token is present. You can force a refresh of non-expired tokens with { forceRefresh: true } input.

Parameters

OptionRequiredTypeDescription
optionsfalse
Options configuring the fetch behavior.

Throws

  • AuthError - Throws error when session information cannot be refreshed.

Returns

Promise<>

fetchDevices

Parameters

OptionRequiredTypeDescription
ctxtrue

Returns

Promise<>
Output type for Cognito fetchDevices API.

fetchDevices

Fetches devices that have been remembered using rememberDevice for the currently authenticated user.

Throws

  • ListDevicesException
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito fetchDevices API.

fetchMFAPreference

Parameters

OptionRequiredTypeDescription
ctxtrue

Returns

Promise<>

fetchMFAPreference

Fetches the preferred MFA setting and enabled MFA settings for the user.

Throws

  • GetUserException : error thrown when the service fails to fetch MFA preference and settings.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>

fetchUserAttributes

Parameters

OptionRequiredTypeDescription
ctxtrue

Returns

Promise<Partial<Record<, string>>>

fetchUserAttributes

Fetches the current user attributes while authenticated.

Throws

  • GetUserException - Cognito service errors thrown when the service is not able to get the user.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<Partial<Record<, string>>>

forgetDevice

Parameters

OptionRequiredTypeDescription
ctxtrue
inputfalseAuthForgetDeviceInput

Returns

Promise<void>

forgetDevice

Forget a remembered device while authenticated.

Parameters

OptionRequiredTypeDescription
inputfalseAuthForgetDeviceInput
The ForgetDeviceInput object.

Throws

  • ForgetDeviceException - Cognito service errors thrown when forgetting device with invalid device key
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

getCurrentUser

Parameters

OptionRequiredTypeDescription
ctxtrue

Returns

Promise<>
Holds the user information along with the sign in details.

getCurrentUser

Gets the current user from the idToken.

Throws

  • InitiateAuthException - Thrown when the service fails to refresh the tokens.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Holds the user information along with the sign in details.

listWebAuthnCredentials

Lists registered credentials for an authenticated user

Parameters

OptionRequiredTypeDescription
inputfalse
The list input parameters including page size and next token.

Throws

  • AuthError:
    • Thrown when user is unauthenticated
  • ListWebAuthnCredentialsException
    • Thrown due to a service error when listing WebAuthn credentials

Returns

Promise<>
Output type for Cognito listWebAuthnCredentials API.

rememberDevice

Parameters

OptionRequiredTypeDescription
ctxtrue

Returns

Promise<void>

rememberDevice

Marks device as remembered while authenticated.

Throws

  • UpdateDeviceStatusException - Cognito service errors thrown when setting device status to remembered using an invalid device key.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

resendSignUpCode

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<>
Output type for Cognito resendSignUpCode API.

resendSignUpCode

Resend the confirmation code while signing up

Parameters

OptionRequiredTypeDescription
inputtrue
The ResendSignUpCodeInput object

Throws

  • service:ResendConfirmationException - Cognito service errors thrown when resending the code.
  • validation:AuthValidationErrorCode - Validation errors thrown either username are not defined.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito resendSignUpCode API.

resetPassword

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<>
Output type for Cognito resetPassword API.

resetPassword

Resets a user's password.

Parameters

OptionRequiredTypeDescription
inputtrue
The ResetPasswordInput object.

Throws

  • ForgotPasswordException Thrown due to an invalid confirmation code or password.
  • AuthValidationErrorCode Thrown due to an empty username.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito resetPassword API.

sendUserAttributeVerificationCode

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<>
Output type for Cognito sendUserAttributeVerificationCode API.

sendUserAttributeVerificationCode

Resends user's confirmation code when updating attributes while authenticated.

Parameters

OptionRequiredTypeDescription
inputtrue
The SendUserAttributeVerificationCodeInput object

Throws

  • GetUserAttributeVerificationException
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito sendUserAttributeVerificationCode API.

setUpTOTP

Parameters

OptionRequiredTypeDescription
ctxtrue

Returns

Promise<AuthTOTPSetupDetails>

setUpTOTP

Sets up TOTP for the user.

Throws

  • AssociateSoftwareTokenException Thrown if a service occurs while setting up TOTP.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<AuthTOTPSetupDetails>

signIn

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<>
Output type for Cognito signIn API.

signIn

Signs a user in

Parameters

OptionRequiredTypeDescription
inputtrue
The SignInInput object

Throws

  • service:InitiateAuthException, RespondToAuthChallengeException - Cognito service errors thrown during the sign-in process.
  • validation:AuthValidationErrorCode - Validation errors thrown when either username or password are not defined.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito signIn API.

signInWithRedirect

Parameters

OptionRequiredTypeDescription
ctxtrue
inputfalseAuthSignInWithRedirectInput

Returns

Promise<void>

signInWithRedirect

Signs in a user with OAuth. Redirects the application to an Identity Provider.

Parameters

OptionRequiredTypeDescription
inputfalseAuthSignInWithRedirectInput
The SignInWithRedirectInput object, if empty it will redirect to Cognito HostedUI

Throws

  • AuthTokenConfigException- Thrown when the user pool config is invalid.
  • OAuthNotConfigureException- Thrown when the oauth config is invalid.

Returns

Promise<void>

signOut

Parameters

OptionRequiredTypeDescription
ctxtrue
inputfalseAuthSignOutInput

Returns

Promise<void>

signOut

Signs a user out

Parameters

OptionRequiredTypeDescription
inputfalseAuthSignOutInput
The SignOutInput object

Throws

  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

signUp

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<>
Output type for Cognito signUp API.

signUp

Creates a user

Parameters

OptionRequiredTypeDescription
inputtrue
The SignUpInput object

Throws

  • service:SignUpException - Cognito service errors thrown during the sign-up process.
  • validation:AuthValidationErrorCode - Validation errors thrown either username or password are not defined.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito signUp API.

updateMFAPreference

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<void>

updateMFAPreference

Updates the MFA preference of the user.

Parameters

OptionRequiredTypeDescription
inputtrue
The UpdateMFAPreferenceInput object.

Throws

  • SetUserMFAPreferenceException - Service error thrown when the MFA preference cannot be updated.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

updatePassword

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrueAuthUpdatePasswordInput

Returns

Promise<void>

updatePassword

Updates user's password while authenticated.

Parameters

OptionRequiredTypeDescription
inputtrueAuthUpdatePasswordInput
The UpdatePasswordInput object.

Throws

  • ChangePasswordException - Cognito service errors thrown when updating a password.
  • AuthValidationErrorCode - Validation errors thrown when oldPassword or newPassword are empty.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

updateUserAttributes

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<>
Output type for Cognito updateUserAttributes API.

updateUserAttributes

Updates user's attributes while authenticated.

Parameters

OptionRequiredTypeDescription
inputtrue
The UpdateUserAttributesInput object

Throws

  • UpdateUserAttributesException
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<>
Output type for Cognito updateUserAttributes API.

verifyTOTPSetup

Parameters

OptionRequiredTypeDescription
ctxtrue
inputtrue

Returns

Promise<void>

verifyTOTPSetup

Verifies an OTP code retrieved from an associated authentication app.

Parameters

OptionRequiredTypeDescription
inputtrue
The VerifyTOTPSetupInput

Throws

  • VerifySoftwareTokenException: Thrown due to an invalid MFA token.
  • AuthValidationErrorCode: Thrown when code is not defined.
  • AuthTokenConfigException- Thrown when the token provider config is invalid.

Returns

Promise<void>

Link Color Legend

Interface
Reference
Other