User APIs
Overview
This page contains all of the APIs for managing users.
Importing Users
User Search
Email Verification
Forgot Password
Create a User
This API is used to create a new User.
Request
Create a User with a randomly generated Id
POST /api/user
Create a User with the provided unique Id
POST /api/user/{userId}
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Parameters
- userId [UUID] Optional defaults to secure random UUID
-
The Id to use for the new User. If not specified a secure random UUID will be generated.
You must specify either the email or the username or both for the User. Either of these values may be used to uniquely identify the User and may be used to authenticate the User. These fields are marked as optional below, but you must specify at least one of them.
Request Body
- applicationId [UUID] Optional Available since 1.30.0
-
An optional Application Id. When this value is provided, it will be used to resolve an application specific email template if you have configured transactional emails such as setup password, email verification and others.
If not provided, only the tenant configuration will be used when resolving email templates.
- disableDomainBlock [Boolean] Optional defaults to
false
Available since 1.30.0 -
A tenant has the option to configure one or more email domains to be blocked in order to restrict email domains during user create or update.
Setting this property equal to
true
will override the tenant configuration. See tenant.registrationConfiguration.blockedDomains in the Tenant API. - sendSetPasswordEmail [Boolean] Optional defaults to
false
-
If
true
, FusionAuth will send the User an email asking them to set their password. The Email Template that is used is the one specified in the setPasswordEmailTemplateId configured in the Tenant.When you set this value to
true
, any provided password field is ignored. FusionAuth will set the initial password to a securely generated random string.If you have also enabled email verification and do not skip verification with the skipVerification parameter, only the setup password email will be sent to the user. Setting up the password using the email sent during this user create operation will verify the User’s email if it is not already verified.
If the SMTP email configuration is not complete, or disabled, this value is ignored.
- skipVerification [Boolean] Optional defaults to
false
-
Indicates to FusionAuth that it should skip email verification even if it is enabled. This is useful for creating admin or internal User accounts.
Setting this to
true
will set the user.verified field totrue
as well. - user.birthDate [String] Optional
-
An
ISO-8601
formatted date of the User’s birthdate such asYYYY-MM-DD
. - user.data [Object] Optional
-
An object that can hold any information about a User that should be persisted. Please review the limits on data field types as you plan for and build your custom data schema.
- user.data.email [String] Optional
-
This field will be used as the email address if no user.email field is found. This field may be modified by advanced registration forms or the API. Setting this value to another account’s email address allows that account to, in some cases, access information about this user.
If user
richard
has a user.data.email with a value ofdinesh@fusionauth.io
, whoever controlsdinesh@fusionauth.io
has elevated access to therichard
account. That user can now reset the password on therichard
account, for example. This functionality may be useful in certain scenarios, such as when accounts must share an email address. Think through the security ramifications before using this feature.This feature was removed in version 1.26.0 and added back in in 1.27.2.
- user.email [String] Optional
-
The User’s email address. An email address is a unique in FusionAuth and stored in lower case.
If email is not provided, then the username will be required.
- user.encryptionScheme [String] Optional defaults to
salted-pbkdf2-hmac-sha256
-
The method for encrypting the User’s password. The following encryptors are provided with FusionAuth:
-
salted-pbkdf2-hmac-sha256-512
Available since 1.34.0 -
phpass-md5
Available since 1.45.0 -
phpass-sha512
Available since 1.45.0
You can also create your own password encryptor. See the Custom Password Hashing section for more information.
- user.expiry [Long] Optional
-
The expiration instant of the User’s account. An expired user is not permitted to login.
- user.factor [String] Optional
-
The factor used by the password encryption scheme. If not provided, the
PasswordEncryptor
provides a default value. Generally this will be used as an iteration count to generate the hash. The actual use of this value is up to thePasswordEncryptor
implementation. - user.firstName [String] Optional
-
The first name of the User.
- user.fullName [String] Optional
-
The User’s full name as a separate field that is not calculated from firstName and lastName.
- user.imageUrl [String] Optional
-
The URL that points to an image file that is the User’s profile image.
- user.lastName [String] Optional
-
The User’s last name.
- user.middleName [String] Optional
-
The User’s middle name.
- user.memberships [Array] Optional
-
The list of memberships for the User.
- user.memberships
[x]
.data [Object] Optional -
An object that can hold any information about the User for this membership that should be persisted.
- user.memberships
[x]
.groupId [UUID] Required -
The Id of the Group of this membership.
- user.memberships
[x]
.id [UUID] Optional defaults to secure random UUID -
The unique Id of this membership. If not specified a secure random UUID will be generated.
- user.mobilePhone [String] Optional
-
The User’s mobile phone number. This is useful is you will be sending push notifications or SMS messages to the User.
- user.parentEmail [String] Optional Available since 1.7.0
-
The email address of the user’s parent or guardian. This field is used to allow a child user to identify their parent so FusionAuth can make a request to the parent to confirm the parent relationship.
Family configuration must be enabled in the tenant Family configuration and the corresponding family email templates must be configured for FusionAuth to notify the parent during user creation.
- user.password [String] Optional
-
The User’s plain text password. This password will be hashed and the provided value will never be stored and cannot be retrieved.
This field is optional only if
sendSetPasswordEmail
is set totrue
. By defaultsendSetPasswordEmail
isfalse
, and then this field will be required. - user.passwordChangeRequired [Boolean] Optional defaults to
false
-
Indicates that the User’s password needs to be changed during their next login attempt.
- user.preferredLanguages [Array<String>] Optional
-
An array of locale strings that give, in order, the User’s preferred languages. These are important for email templates and other localizable text. See Locales.
- user.timezone [String] Optional
-
The User’s preferred timezone. The string must be in an IANA time zone format. For example:
America/Denver
orUS/Mountain
- user.twoFactor.methods
[x]
.authenticator.algorithm [String] Optional -
The algorithm used by the TOTP authenticator. With the current implementation, this will always be
HmacSHA1
. - user.twoFactor.methods
[x]
.authenticator.codeLength [Integer] Optional -
The length of code generated by the TOTP. With the current implementation, this will always be
6
. - user.twoFactor.methods
[x]
.authenticator.timeStep [Integer] Optional -
The time-step size in seconds. With the current implementation, this will always be 30.
- user.twoFactor.methods
[x]
.email [String] Optional -
The value of the email address for this method. Only present if user.twoFactor.methods
[x]
.method isemail
. - user.twoFactor.methods
[x]
.method [String] Optional -
The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
-
authenticator
-
email
-
sms
-
- user.twoFactor.methods
[x]
.mobilePhone [String] Optional -
The value of the mobile phone for this method. Only present if user.twoFactor.methods
[x]
.method issms
. - user.twoFactor.methods
[x]
.secret [String] Optional -
A base64 encoded secret
This field is required when method is
authenticator
. - user.twoFactorDelivery [String] Optional defaults to
None
Deprecated -
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
When using
TextMessage
the User will also need a validmobilePhone
.Removed in version 1.26.0
-
- user.twoFactorEnabled [Boolean] Optional defaults to
false
Deprecated -
Determines if the User has two factor authentication enabled for their account or not.
See the Enable Two Factor and Disable Two Factor APIs as an alternative to performing this action using the User API.
Removed in version 1.26.0
- user.twoFactorSecret [String] Optional Deprecated
-
The Base64 encoded secret used to generate Two Factor verification codes.
You may optionally use value provided in the
secret
field returned by the Two Factor Secret API instead of generating this value yourself.Unless you are using
TextMessage
as your delivery type, ensure you are able to share the secret with the User before enabling Two Factor authentication. Beginning in version 1.17.0, if you do create a User withTextMessage
set as thetwoFactorDelivery
type and you omit this value, the secret will be generated for you. The secret can be generated because it is not necessary to share the secret with the User for this delivery method.When using
None
as thetwoFactorDelivery
this value will be required.Removed in version 1.26.0
- user.username [String] Optional
-
The username of the User. The username is stored and returned as a case sensitive value, however a username is considered unique regardless of the case.
bob
is considered equal toBoB
so either version of this username can be used whenever providing it as input to an API.If username is not provided, then the
email
will be required. - user.usernameStatus [String] Optional
-
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
This state is managed by CleanSpeak, it may be changed by setting it on this request.
-
{
"applicationId": "368994e6-ba8a-49b5-8446-7b99ab1fffdf",
"disableDomainBlock": false,
"user": {
"birthDate": "1976-05-30",
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"encryptionScheme": "salted-sha256",
"factor": 24000,
"expiry": 1571786483322,
"firstName": "John",
"fullName": "John Doe",
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"lastName": "Doe",
"memberships": [
{
"data": {
"externalId": "cc6714c6-286c-411c-a6bc-ee413cda1dbc"
},
"groupId": "2cb5c83f-53ff-4d16-88bd-c5e3802111a5"
}
],
"middleName": "William",
"mobilePhone": "303-555-1234",
"password": "supersecret",
"passwordChangeRequired": false,
"preferredLanguages": [
"en",
"fr"
],
"timezone": "America/Denver",
"twoFactor": {
"methods": [
{
"authenticator": {
"algorithm": "HmacSHA1",
"codeLength": 6,
"timeStep": 30
},
"secret": "aGVsbG8Kd29ybGQKaGVsbG8gaGVsbG8=",
"method": "authenticator"
},
{
"method": "sms",
"mobilePhone": "555-555-5555"
},
{
"method": "email",
"email": "example@fusionauth.io"
}
]
},
"usernameStatus": "ACTIVE",
"username": "johnny123"
}
}
Response
The response for this API contains the User that was just created. The password, salt and other sensitive fields will not be returned on the API response.
Code | Description |
---|---|
200 |
The request was successful. The response will contain a JSON body. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
504 |
One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |
Response Body
- token [String] Available since 1.16.0
-
The access token, this string is an encoded JSON Web Token (JWT).
- tokenExpirationInstant [Long] Available since 1.33.0
-
The instant the token will expire. If the response does not contain a token, this field will also be omitted from the response.
- user.active [Boolean]
-
True if the User is active. False if the User has been deactivated. Deactivated Users will not be able to login.
- user.birthDate [String]
-
The User’s birthdate formatted as
YYYY-MM-DD
- user.breachedPasswordLastCheckedInstant [Long]
-
The instant this user’s password was last checked to determine if it is compromised.
- user.connectorId [UUID] Available since 1.18.0
-
The unique Id of the Connector associated with the System of Record being used to authenticate the user.
- user.cleanSpeakId [UUID]
-
This Id is used by FusionAuth when the User’s username is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- user.data [Object]
-
An object that can hold any information about the User that should be persisted.
- user.data.email [String]
-
This field will be used as the email address if no user.email field is found.
This feature was removed in version 1.26.0 and added back in in 1.27.2.
- user.email [String]
-
The User’s email address.
- user.expiry [Long]
-
The expiration instant of the User’s account. An expired user is not permitted to login.
- user.firstName [String]
-
The first name of the User.
- user.fullName [String]
-
The User’s full name as a separate field that is not calculated from firstName and lastName.
- user.id [UUID]
-
The User’s unique Id.
- user.imageUrl [String]
-
The URL that points to an image file that is the User’s profile image.
- user.insertInstant [Long]
-
The instant when the user was created.
- user.lastLoginInstant [Long]
-
The instant when the User logged in last.
- user.lastName [String]
-
The User’s last name.
- user.lastUpdateInstant [Long]
-
The instant when the User was last updated.
- user.middleName [String]
-
The User’s middle name.
- user.mobilePhone [String]
-
The User’s mobile phone number. This is useful if you will be sending push notifications or SMS messages to the User.
- user.parentEmail [String] Available since 1.7.0
-
The email address of the user’s parent or guardian. If this value was provided during a create or update operation, this value will only remain until the child is claimed by a parent.
- user.passwordChangeRequired [Boolean]
-
Indicates that the User’s password needs to be changed during their next login attempt.
- user.passwordLastUpdateInstant [Long]
-
The instant that the User last changed their password.
- user.preferredLanguages [Array<String>]
-
An array of locale strings that give, in order, the User’s preferred languages. These are important for email templates and other localizable text. See Locales.
- user.registrations [Array]
-
The list of registrations for the User. This will include registrations for inactive applications.
- user.registrations
[x]
.applicationId [UUID] -
The Id of the Application that this registration is for.
- user.registrations
[x]
.authenticationToken [String] -
The Authentication Token for this registration (if one exists).
- user.registrations
[x]
.cleanSpeakId [UUID] -
This Id is used by FusionAuth when the User’s username for this registration is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- user.registrations
[x]
.data [Object] -
An object that can hold any information about the User for this registration that should be persisted.
- user.registrations
[x]
.id [UUID] -
The Id of this registration.
- user.registrations
[x]
.insertInstant [Long] -
The instant that this registration was created.
- user.registrations
[x]
.lastLoginInstant [Long] -
The instant that the User last logged into the Application for this registration.
- user.registrations
[x]
.preferredLanguages [Array<String>] -
An array of locale strings that give, in order, the User’s preferred languages for this registration. These are important for email templates and other localizable text.
- user.registrations
[x]
.roles [Array<String>] -
The list of roles that the User has for this registration.
- user.registrations
[x]
.timezone [String] -
The User’s preferred timezone for this registration. The string will be in an IANA time zone format.
- user.registrations
[x]
.tokens [Map<String,String>] Deprecated -
A map that contains tokens returned from identity providers.
For example, if this user has authenticated using the Facebook Identity Provider, the Facebook access token will be available in this map, keyed by name
Facebook
. For an OpenID Connect Identity provider, or other generic providers, if a token is stored it will be keyed by the Identity Provider unique Id.Removed in 1.28.0
The token returned and stored from the Identity Provider is now stored in the IdP link and is retrievable using the Identity Provider Link API.
- user.registrations
[x]
.username [String] -
The username of the User for this registration only. This is for display purposes and cannot be used to login.
- user.registrations
[x]
.usernameStatus [String] -
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- user.registrations
[x]
.verified [Boolean] -
This value indicates if this User’s registration has been verified.
For additional information, see these tutorials:
- user.tenantId [UUID]
-
The Id of the Tenant that this User belongs to.
- user.timezone [String]
-
The User’s preferred timezone. This can be used as a default to display instants, and it is recommended that you allow Users to change this per-session. The string will be in an IANA time zone format.
- user.twoFactor.methods
[x]
.authenticator.algorithm [String] -
The algorithm used by the TOTP authenticator. With the current implementation, this will always be
HmacSHA1
. - user.twoFactor.methods
[x]
.authenticator.codeLength [Integer] -
The length of code generated by the TOTP. With the current implementation, this will always be
6
. - user.twoFactor.methods
[x]
.authenticator.timeStep [Integer] -
The time-step size in seconds. With the current implementation, this will always be 30.
- user.twoFactor.methods
[x]
.email [String] -
The value of the email address for this method. Only present if user.twoFactor.methods
[x]
.method isemail
. - user.twoFactor.methods
[x]
.id [String] -
The unique Id of the method.
- user.twoFactor.methods
[x]
.lastUsed [Boolean] -
true
if this method was used most recently. - user.twoFactor.methods
[x]
.method [String] -
The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
-
authenticator
-
email
-
sms
-
- user.twoFactor.methods
[x]
.mobilePhone [String] -
The value of the mobile phone for this method. Only present if user.twoFactor.methods
[x]
.method issms
. - user.twoFactor.methods
[x]
.secret [String] -
A base64 encoded secret
- user.twoFactorDelivery [String] Deprecated
-
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
Removed in version 1.26.0
-
- user.twoFactorEnabled [Boolean] Deprecated
-
Determines if the User has two factor authentication enabled for their account or not.
Removed in version 1.26.0
- user.username [String]
-
The username of the User.
- user.usernameStatus [String]
-
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- user.verified [Boolean]
-
Whether or not the User’s email has been verified.
For additional information, see these tutorials:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImMxVU5ON0pIUVc4X21ROHBTaWZKbzBXekdybDlTbTRnIn0.eyJleHAiOjE1ODY4ODQzNzksImlhdCI6MTU4Njg4NDMxOSwiaXNzIjoiZnVzaW9uYXV0aC5pbyIsInN1YiI6IjAwMDAwMDAwLTAwMDAtMDAwMS0wMDAwLTAwMDAwMDAwMDAwMCIsImF1dGhlbnRpY2F0aW9uVHlwZSI6IlVTRVJfQ1JFQVRFIiwiZW1haWwiOiJ0ZXN0MEBmdXNpb25hdXRoLmlvIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInByZWZlcnJlZF91c2VybmFtZSI6InVzZXJuYW1lMCJ9.Z1jV8xDcayZZDBdLRVd2fIyowhstRI4Dgk7_u2XFerc",
"user": {
"active": true,
"breachedPasswordLastCheckedInstant": 1471786483322,
"birthDate": "1976-05-30",
"connectorId": "e3306678-a53a-4964-9040-1c96f36dda72",
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"expiry": 1571786483322,
"firstName": "John",
"fullName": "John Doe",
"id": "00000000-0000-0001-0000-000000000000",
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"lastLoginInstant": 1471786483322,
"lastName": "Doe",
"memberships": [
{
"data": {
"externalId": "cc6714c6-286c-411c-a6bc-ee413cda1dbc"
},
"groupId": "2cb5c83f-53ff-4d16-88bd-c5e3802111a5",
"id": "27218714-305e-4408-bac0-23e7e1ddceb6",
"insertInstant": 1471786482322
}
],
"middleName": "William",
"mobilePhone": "303-555-1234",
"passwordChangeRequired": false,
"passwordLastUpdateInstant": 1471786483322,
"preferredLanguages": [
"en",
"fr"
],
"registrations": [
{
"applicationId": "10000000-0000-0002-0000-000000000001",
"data": {
"displayName": "Johnny",
"favoriteSports": [
"Football",
"Basketball"
]
},
"id": "00000000-0000-0002-0000-000000000000",
"insertInstant": 1446064706250,
"lastLoginInstant": 1456064601291,
"preferredLanguages": [
"en",
"fr"
],
"roles": [
"user",
"community_helper"
],
"timezone": "America/Chicago",
"username": "johnny123",
"usernameStatus": "ACTIVE"
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactor": {
"methods": [
{
"authenticator": {
"algorithm": "HmacSHA1",
"codeLength": 6,
"timeStep": 30
},
"id": "35VW",
"method": "authenticator"
},
{
"id": "V7SH",
"method": "sms",
"mobilePhone": "555-555-5555"
},
{
"email": "example@fusionauth.io",
"id": "7K2G",
"method": "email"
}
]
},
"usernameStatus": "ACTIVE",
"username": "johnny123",
"verified": true
}
}
Retrieve a User
This API is used to retrieve the information about a single User. You can use the User’s Id, username or email address to retrieve the User. The Id is specified on the URI and the username or email are specified as URL parameters.
Request
GET /api/user/{userId}
Request Parameters
- userId [UUID] Required
-
The unique Id of the User to retrieve.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
GET /api/user?loginId={loginId}
Request Parameters
- loginId [String] Required
-
The unique Id of the User to retrieve. The loginId can be either the email or username.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request because the input parameters by themselves do not indicate which tenant the request is intended.
The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
GET /api/user?email={email}
Request Parameters
- email [String] Required
-
The email of the User to retrieve.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request because the input parameters by themselves do not indicate which tenant the request is intended.
The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
GET /api/user?username={username}
Request Parameters
- username [String] Required
-
The username of the User to retrieve.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request because the input parameters by themselves do not indicate which tenant the request is intended.
The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Retrieve a User by Change Password Id
GET /api/user?changePasswordId={changePasswordId}
Request Parameters
- changePasswordId [String] Required
-
The change password Id associated with the user when the Forgot Password workflow has been started.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Retrieve a User by Email Verification Id
GET /api/user?verificationId={verificationId}
Request Parameters
- verificationId [String] Required
-
The verification Id associated with the user when the Email verification process has been started.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
GET /api/user
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Response
The response for this API contains the User.
Code | Description |
---|---|
200 |
The request was successful. The response will contain a JSON body. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 |
The object you requested doesn’t exist. The response will be empty. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
- user.active [Boolean]
-
True if the User is active. False if the User has been deactivated. Deactivated Users will not be able to login.
- user.birthDate [String]
-
The User’s birthdate formatted as
YYYY-MM-DD
- user.breachedPasswordLastCheckedInstant [Long]
-
The instant this user’s password was last checked to determine if it is compromised.
- user.connectorId [UUID] Available since 1.18.0
-
The unique Id of the Connector associated with the System of Record being used to authenticate the user.
- user.cleanSpeakId [UUID]
-
This Id is used by FusionAuth when the User’s username is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- user.data [Object]
-
An object that can hold any information about the User that should be persisted.
- user.data.email [String]
-
This field will be used as the email address if no user.email field is found.
This feature was removed in version 1.26.0 and added back in in 1.27.2.
- user.email [String]
-
The User’s email address.
- user.encryptionScheme [String] Available since 1.20.1
-
The encryption scheme used to hash the password for this user. This value is only returned when the user is retrieved using an API key.
- user.expiry [Long]
-
The expiration instant of the User’s account. An expired user is not permitted to login.
- user.firstName [String]
-
The first name of the User.
- user.fullName [String]
-
The User’s full name as a separate field that is not calculated from firstName and lastName.
- user.id [UUID]
-
The User’s unique Id.
- user.imageUrl [String]
-
The URL that points to an image file that is the User’s profile image.
- user.insertInstant [Long]
-
The instant when the user was created.
- user.lastLoginInstant [Long]
-
The instant when the User logged in last.
- user.lastName [String]
-
The User’s last name.
- user.lastUpdateInstant [Long]
-
The instant when the User was last updated.
- user.memberships [Array]
-
The list of memberships for the User.
- user.memberships
[x]
.data [Object] -
An object that can hold any information about the User for this membership that should be persisted.
- user.memberships
[x]
.groupId [UUID] -
The Id of the Group of this membership.
- user.memberships
[x]
.id [UUID] -
The unique Id of this membership.
- user.memberships
[x]
.insertInstant [Long] -
The instant that the membership was created.
- user.middleName [String]
-
The User’s middle name.
- user.mobilePhone [String]
-
The User’s mobile phone number. This is useful if you will be sending push notifications or SMS messages to the User.
- user.parentEmail [String] Available since 1.7.0
-
The email address of the user’s parent or guardian. If this value was provided during a create or update operation, this value will only remain until the child is claimed by a parent.
- user.passwordChangeRequired [Boolean]
-
Indicates that the User’s password needs to be changed during their next login attempt.
- user.passwordLastUpdateInstant [Long]
-
The instant that the User last changed their password.
- user.preferredLanguages [Array<String>]
-
An array of locale strings that give, in order, the User’s preferred languages. These are important for email templates and other localizable text. See Locales.
- user.registrations [Array]
-
The list of registrations for the User. This will include registrations for inactive applications.
- user.registrations
[x]
.applicationId [UUID] -
The Id of the Application that this registration is for.
- user.registrations
[x]
.authenticationToken [String] -
The Authentication Token for this registration (if one exists).
- user.registrations
[x]
.cleanSpeakId [UUID] -
This Id is used by FusionAuth when the User’s username for this registration is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- user.registrations
[x]
.data [Object] -
An object that can hold any information about the User for this registration that should be persisted.
- user.registrations
[x]
.id [UUID] -
The Id of this registration.
- user.registrations
[x]
.insertInstant [Long] -
The instant that this registration was created.
- user.registrations
[x]
.lastLoginInstant [Long] -
The instant that the User last logged into the Application for this registration.
- user.registrations
[x]
.preferredLanguages [Array<String>] -
An array of locale strings that give, in order, the User’s preferred languages for this registration. These are important for email templates and other localizable text.
- user.registrations
[x]
.roles [Array<String>] -
The list of roles that the User has for this registration.
- user.registrations
[x]
.timezone [String] -
The User’s preferred timezone for this registration. The string will be in an IANA time zone format.
- user.registrations
[x]
.tokens [Map<String,String>] Deprecated -
A map that contains tokens returned from identity providers.
For example, if this user has authenticated using the Facebook Identity Provider, the Facebook access token will be available in this map, keyed by name
Facebook
. For an OpenID Connect Identity provider, or other generic providers, if a token is stored it will be keyed by the Identity Provider unique Id.Removed in 1.28.0
The token returned and stored from the Identity Provider is now stored in the IdP link and is retrievable using the Identity Provider Link API.
- user.registrations
[x]
.username [String] -
The username of the User for this registration only. This is for display purposes and cannot be used to login.
- user.registrations
[x]
.usernameStatus [String] -
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- user.registrations
[x]
.verified [Boolean] -
This value indicates if this User’s registration has been verified.
For additional information, see these tutorials:
- user.tenantId [UUID]
-
The Id of the Tenant that this User belongs to.
- user.timezone [String]
-
The User’s preferred timezone. This can be used as a default to display instants, and it is recommended that you allow Users to change this per-session. The string will be in an IANA time zone format.
- user.twoFactor.methods
[x]
.authenticator.algorithm [String] -
The algorithm used by the TOTP authenticator. With the current implementation, this will always be
HmacSHA1
. - user.twoFactor.methods
[x]
.authenticator.codeLength [Integer] -
The length of code generated by the TOTP. With the current implementation, this will always be
6
. - user.twoFactor.methods
[x]
.authenticator.timeStep [Integer] -
The time-step size in seconds. With the current implementation, this will always be 30.
- user.twoFactor.methods
[x]
.email [String] -
The value of the email address for this method. Only present if user.twoFactor.methods
[x]
.method isemail
. - user.twoFactor.methods
[x]
.id [String] -
The unique Id of the method.
- user.twoFactor.methods
[x]
.lastUsed [Boolean] -
true
if this method was used most recently. - user.twoFactor.methods
[x]
.method [String] -
The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
-
authenticator
-
email
-
sms
-
- user.twoFactor.methods
[x]
.mobilePhone [String] -
The value of the mobile phone for this method. Only present if user.twoFactor.methods
[x]
.method issms
. - user.twoFactor.methods
[x]
.secret [String] -
A base64 encoded secret
- user.twoFactorDelivery [String] Deprecated
-
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
Removed in version 1.26.0
-
- user.twoFactorEnabled [Boolean] Deprecated
-
Determines if the User has two factor authentication enabled for their account or not.
Removed in version 1.26.0
- user.username [String]
-
The username of the User.
- user.usernameStatus [String]
-
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- user.verified [Boolean]
-
Whether or not the User’s email has been verified.
For additional information, see these tutorials:
{
"user": {
"active": true,
"breachedPasswordLastCheckedInstant": 1471786483322,
"birthDate": "1976-05-30",
"connectorId": "e3306678-a53a-4964-9040-1c96f36dda72",
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"expiry": 1571786483322,
"firstName": "John",
"fullName": "John Doe",
"id": "00000000-0000-0001-0000-000000000000",
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"lastLoginInstant": 1471786483322,
"lastName": "Doe",
"memberships": [
{
"data": {
"externalId": "cc6714c6-286c-411c-a6bc-ee413cda1dbc"
},
"groupId": "2cb5c83f-53ff-4d16-88bd-c5e3802111a5",
"id": "27218714-305e-4408-bac0-23e7e1ddceb6",
"insertInstant": 1471786482322
}
],
"middleName": "William",
"mobilePhone": "303-555-1234",
"passwordChangeRequired": false,
"passwordLastUpdateInstant": 1471786483322,
"preferredLanguages": [
"en",
"fr"
],
"registrations": [
{
"applicationId": "10000000-0000-0002-0000-000000000001",
"data": {
"displayName": "Johnny",
"favoriteSports": [
"Football",
"Basketball"
]
},
"id": "00000000-0000-0002-0000-000000000000",
"insertInstant": 1446064706250,
"lastLoginInstant": 1456064601291,
"preferredLanguages": [
"en",
"fr"
],
"roles": [
"user",
"community_helper"
],
"timezone": "America/Chicago",
"username": "johnny123",
"usernameStatus": "ACTIVE"
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactor": {
"methods": [
{
"authenticator": {
"algorithm": "HmacSHA1",
"codeLength": 6,
"timeStep": 30
},
"id": "35VW",
"method": "authenticator"
},
{
"id": "V7SH",
"method": "sms",
"mobilePhone": "555-555-5555"
},
{
"email": "example@fusionauth.io",
"id": "7K2G",
"method": "email"
}
]
},
"usernameStatus": "ACTIVE",
"username": "johnny123",
"verified": true
}
}
Update a User
This API is used to update an existing User.
You must specify the Id of the User you are updating on the URI.
You must specify all of the properties of the User when calling this API with the PUT
HTTP method. When used with PUT
, this API doesn’t merge the existing User and your new data. It replaces the existing User with your new data.
Utilize the PATCH
HTTP method to send specific changes to merge into an existing User.
If you specify a new password for the User, it will be encrypted and stored. However, if you do not provide a new password, the User’s old password will be preserved. This is the only field that is merged during an update using the PUT
method.
Request
Update the User with the given Id
PUT /api/user/{userId}
PATCH /api/user/{userId}
Available since 1.39.0
When using the PATCH method, you can either use the same request body documentation that is provided for the PUT request for backward compatibility. Or you may use either JSON Patch/RFC 6902 or JSON Merge Patch/RFC 7396. See the
PATCH
documentation for more information.Available since 1.12.0
When using the PATCH method, use the same request body documentation that is provided for the PUT request. The PATCH method will merge the provided request parameters into the existing object, this means all parameters are optional when using the PATCH method and you only provide the values you want changed. A
null
value can be used to remove a value. Patching anArray
will result in all values from the new list being appended to the existing list, this is a known limitation to the current implementation of PATCH.
Request Parameters
- userId [UUID] Required
-
The Id of the User to update.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
You must specify either the email or the username or both for the User. Either of these values may be used to uniquely identify the User and may be used to authenticate the User. These fields are marked as optional below, but you must specify at least one of them.
Request Body
- applicationId [UUID] Optional Available since 1.30.0
-
An optional Application Id. When this value is provided, it will be used to resolve an application specific email template if you have configured transactional emails such as setup password, email verification and others.
If not provided, only the tenant configuration will be used when resolving email templates.
- disableDomainBlock [Boolean] Optional defaults to
false
Available since 1.30.0 -
A tenant has the option to configure one or more email domains to be blocked in order to restrict email domains during user create or update.
Setting this property equal to
true
will override the tenant configuration. See tenant.registrationConfiguration.blockedDomains in the Tenant API. - skipVerification [Boolean] Optional defaults to
false
-
Indicates to FusionAuth that it should skip email verification even if it is enabled. This is useful for creating admin or internal User accounts.
Setting this to
true
will set the user.verified field totrue
as well. - user.birthDate [String] Optional
-
An
ISO-8601
formatted date of the User’s birthdate such asYYYY-MM-DD
. - user.data [Object] Optional
-
An object that can hold any information about a User that should be persisted. Please review the limits on data field types as you plan for and build your custom data schema.
- user.data.email [String] Optional
-
This field will be used as the email address if no user.email field is found. This field may be modified by advanced registration forms or the API. Setting this value to another account’s email address allows that account to, in some cases, access information about this user.
If user
richard
has a user.data.email with a value ofdinesh@fusionauth.io
, whoever controlsdinesh@fusionauth.io
has elevated access to therichard
account. That user can now reset the password on therichard
account, for example. This functionality may be useful in certain scenarios, such as when accounts must share an email address. Think through the security ramifications before using this feature.This feature was removed in version 1.26.0 and added back in in 1.27.2.
- user.email [String] Optional
-
The User’s email address. An email address is a unique in FusionAuth and stored in lower case.
If email is not provided, then the username will be required.
- user.encryptionScheme [String] Optional defaults to
salted-pbkdf2-hmac-sha256
-
The method for encrypting the User’s password. The following encryptors are provided with FusionAuth:
-
salted-pbkdf2-hmac-sha256-512
Available since 1.34.0 -
phpass-md5
Available since 1.45.0 -
phpass-sha512
Available since 1.45.0
This field is ignored unless the
password
field is also provided. If omitted and thepassword
is specified, the default encryption scheme will be used.You can also create your own password encryptor. See the Custom Password Hashing section for more information.
- user.expiry [Long] Optional
-
The expiration instant of the User’s account. An expired user is not permitted to login.
- user.factor [String] Optional
-
The factor used by the password encryption scheme. If not provided, the
PasswordEncryptor
provides a default value. Generally this will be used as an iteration count to generate the hash. The actual use of this value is up to thePasswordEncryptor
implementation.This field is ignored unless the
password
field is also provided. If omitted and thepassword
is specified, the default factor for the encryption scheme will be used. - user.firstName [String] Optional
-
The first name of the User.
- user.fullName [String] Optional
-
The User’s full name as a separate field that is not calculated from firstName and lastName.
- user.imageUrl [String] Optional
-
The URL that points to an image file that is the User’s profile image.
- user.lastName [String] Optional
-
The User’s last name.
- user.middleName [String] Optional
-
The User’s middle name.
- user.mobilePhone [String] Optional
-
The User’s mobile phone number. This is useful is you will be sending push notifications or SMS messages to the User.
- user.parentEmail [String] Optional Available since 1.7.0
-
The email address of the user’s parent or guardian. This field is used to allow a child user to identify their parent so FusionAuth can make a request to the parent to confirm the parent relationship.
Family configuration must be enabled in the tenant Family configuration and the corresponding family email templates must be configured for FusionAuth to notify the parent during user creation.
- user.password [String] Optional
-
The User’s plain text password. This password will be hashed and the provided value will never be stored and cannot be retrieved.
If this parameter is provided it indicates you wish to change the User’s password. If you do not want to change the User’s password omit this field from the request.
- user.passwordChangeRequired [Boolean] Optional defaults to
false
-
Indicates that the User’s password needs to be changed during their next login attempt.
- user.preferredLanguages [Array<String>] Optional
-
An array of locale strings that give, in order, the User’s preferred languages. These are important for email templates and other localizable text. See Locales.
- user.timezone [String] Optional
-
The User’s preferred timezone. The string must be in an IANA time zone format. For example:
America/Denver
orUS/Mountain
- user.twoFactor.methods
[x]
.authenticator.algorithm [String] Optional -
The algorithm used by the TOTP authenticator. With the current implementation, this will always be
HmacSHA1
. - user.twoFactor.methods
[x]
.authenticator.codeLength [Integer] Optional -
The length of code generated by the TOTP. With the current implementation, this will always be
6
. - user.twoFactor.methods
[x]
.authenticator.timeStep [Integer] Optional -
The time-step size in seconds. With the current implementation, this will always be 30.
- user.twoFactor.methods
[x]
.email [String] Optional -
The value of the email address for this method. Only present if user.twoFactor.methods
[x]
.method isemail
. - user.twoFactor.methods
[x]
.method [String] Optional -
The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
-
authenticator
-
email
-
sms
-
- user.twoFactor.methods
[x]
.mobilePhone [String] Optional -
The value of the mobile phone for this method. Only present if user.twoFactor.methods
[x]
.method issms
. - user.twoFactor.methods
[x]
.secret [String] Optional -
A base64 encoded secret
This field is required when method is
authenticator
. - user.twoFactorDelivery [String] Optional defaults to
None
Deprecated -
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
When using
TextMessage
the User will also need a validmobilePhone
.If Two Factor authentication is already enabled for this user, the delivery may not be modified. In order to change the delivery type you must first disable Two Factor authentication and re-enable with a new delivery type.
Removed in version 1.26.0
-
- user.twoFactorEnabled [Boolean] Optional defaults to
false
Deprecated -
Determines if the User has two factor authentication enabled for their account or not.
If Two Factor authentication is already enabled for this user disabling Two Factor authentication will reset the delivery type and secret.
See the Enable Two Factor and Disable Two Factor APIs as an alternative to performing this action using the User API.
Removed in version 1.26.0
- user.twoFactorSecret [String] Optional Deprecated
-
The Base64 encoded secret used to generate Two Factor verification codes.
You may optionally use value provided in the
secret
field returned by the Two Factor Secret API instead of generating this value yourself.Unless you are using
TextMessage
as your delivery type, ensure you are able to share the secret with the User before enabling Two Factor authentication. Beginning in version 1.17.0, if you do create a User withTextMessage
set as thetwoFactorDelivery
type and you omit this value, the secret will be generated for you. The secret can be generated because it is not necessary to share the secret with the User for this delivery method.When using
None
as thetwoFactorDelivery
this value will be required.If Two Factor authentication is already enabled for this user, the secret may not be modified. In order to change the secret you must first disable Two Factor authentication and re-enable with a new secret.
Removed in version 1.26.0
- user.username [String] Optional
-
The username of the User. The username is stored and returned as a case sensitive value, however a username is considered unique regardless of the case.
bob
is considered equal toBoB
so either version of this username can be used whenever providing it as input to an API.If username is not provided, then the
email
will be required. - user.usernameStatus [String] Optional
-
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
This state is managed by CleanSpeak, it may be changed by setting it on this request.
-
{
"application": "368994e6-ba8a-49b5-8446-7b99ab1fffdf",
"disableDomainBlock": false,
"user": {
"active": true,
"birthDate": "1976-05-30",
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"encryptionScheme": "salted-sha256",
"factor": 24000,
"expiry": 1571786483322,
"firstName": "John",
"fullName": "John Doe",
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"lastName": "Doe",
"middleName": "William",
"mobilePhone": "303-555-1234",
"passwordChangeRequired": false,
"preferredLanguages": [
"en",
"fr"
],
"timezone": "America/Denver",
"twoFactorEnabled": false,
"usernameStatus": "ACTIVE",
"username": "johnny123"
}
}
Response
The response for this API contains the User that was updated. The password hash and other sensitive fields are never returned on the API response.
Code | Description |
---|---|
200 |
The request was successful. The response will contain a JSON body. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 |
The object you are trying to update doesn’t exist. The response will be empty. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
504 |
One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |
Response Body
- user.active [Boolean]
-
True if the User is active. False if the User has been deactivated. Deactivated Users will not be able to login.
- user.birthDate [String]
-
The User’s birthdate formatted as
YYYY-MM-DD
- user.breachedPasswordLastCheckedInstant [Long]
-
The instant this user’s password was last checked to determine if it is compromised.
- user.connectorId [UUID] Available since 1.18.0
-
The unique Id of the Connector associated with the System of Record being used to authenticate the user.
- user.cleanSpeakId [UUID]
-
This Id is used by FusionAuth when the User’s username is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- user.data [Object]
-
An object that can hold any information about the User that should be persisted.
- user.data.email [String]
-
This field will be used as the email address if no user.email field is found.
This feature was removed in version 1.26.0 and added back in in 1.27.2.
- user.email [String]
-
The User’s email address.
- user.expiry [Long]
-
The expiration instant of the User’s account. An expired user is not permitted to login.
- user.firstName [String]
-
The first name of the User.
- user.fullName [String]
-
The User’s full name as a separate field that is not calculated from firstName and lastName.
- user.id [UUID]
-
The User’s unique Id.
- user.imageUrl [String]
-
The URL that points to an image file that is the User’s profile image.
- user.insertInstant [Long]
-
The instant when the user was created.
- user.lastLoginInstant [Long]
-
The instant when the User logged in last.
- user.lastName [String]
-
The User’s last name.
- user.lastUpdateInstant [Long]
-
The instant when the User was last updated.
- user.memberships [Array]
-
The list of memberships for the User.
- user.memberships
[x]
.data [Object] -
An object that can hold any information about the User for this membership that should be persisted.
- user.memberships
[x]
.groupId [UUID] -
The Id of the Group of this membership.
- user.memberships
[x]
.id [UUID] -
The unique Id of this membership.
- user.memberships
[x]
.insertInstant [Long] -
The instant that the membership was created.
- user.middleName [String]
-
The User’s middle name.
- user.mobilePhone [String]
-
The User’s mobile phone number. This is useful if you will be sending push notifications or SMS messages to the User.
- user.parentEmail [String] Available since 1.7.0
-
The email address of the user’s parent or guardian. If this value was provided during a create or update operation, this value will only remain until the child is claimed by a parent.
- user.passwordChangeRequired [Boolean]
-
Indicates that the User’s password needs to be changed during their next login attempt.
- user.passwordLastUpdateInstant [Long]
-
The instant that the User last changed their password.
- user.preferredLanguages [Array<String>]
-
An array of locale strings that give, in order, the User’s preferred languages. These are important for email templates and other localizable text. See Locales.
- user.registrations [Array]
-
The list of registrations for the User. This will include registrations for inactive applications.
- user.registrations
[x]
.applicationId [UUID] -
The Id of the Application that this registration is for.
- user.registrations
[x]
.authenticationToken [String] -
The Authentication Token for this registration (if one exists).
- user.registrations
[x]
.cleanSpeakId [UUID] -
This Id is used by FusionAuth when the User’s username for this registration is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- user.registrations
[x]
.data [Object] -
An object that can hold any information about the User for this registration that should be persisted.
- user.registrations
[x]
.id [UUID] -
The Id of this registration.
- user.registrations
[x]
.insertInstant [Long] -
The instant that this registration was created.
- user.registrations
[x]
.lastLoginInstant [Long] -
The instant that the User last logged into the Application for this registration.
- user.registrations
[x]
.preferredLanguages [Array<String>] -
An array of locale strings that give, in order, the User’s preferred languages for this registration. These are important for email templates and other localizable text.
- user.registrations
[x]
.roles [Array<String>] -
The list of roles that the User has for this registration.
- user.registrations
[x]
.timezone [String] -
The User’s preferred timezone for this registration. The string will be in an IANA time zone format.
- user.registrations
[x]
.tokens [Map<String,String>] Deprecated -
A map that contains tokens returned from identity providers.
For example, if this user has authenticated using the Facebook Identity Provider, the Facebook access token will be available in this map, keyed by name
Facebook
. For an OpenID Connect Identity provider, or other generic providers, if a token is stored it will be keyed by the Identity Provider unique Id.Removed in 1.28.0
The token returned and stored from the Identity Provider is now stored in the IdP link and is retrievable using the Identity Provider Link API.
- user.registrations
[x]
.username [String] -
The username of the User for this registration only. This is for display purposes and cannot be used to login.
- user.registrations
[x]
.usernameStatus [String] -
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- user.registrations
[x]
.verified [Boolean] -
This value indicates if this User’s registration has been verified.
For additional information, see these tutorials:
- user.tenantId [UUID]
-
The Id of the Tenant that this User belongs to.
- user.timezone [String]
-
The User’s preferred timezone. This can be used as a default to display instants, and it is recommended that you allow Users to change this per-session. The string will be in an IANA time zone format.
- user.twoFactor.methods
[x]
.authenticator.algorithm [String] -
The algorithm used by the TOTP authenticator. With the current implementation, this will always be
HmacSHA1
. - user.twoFactor.methods
[x]
.authenticator.codeLength [Integer] -
The length of code generated by the TOTP. With the current implementation, this will always be
6
. - user.twoFactor.methods
[x]
.authenticator.timeStep [Integer] -
The time-step size in seconds. With the current implementation, this will always be 30.
- user.twoFactor.methods
[x]
.email [String] -
The value of the email address for this method. Only present if user.twoFactor.methods
[x]
.method isemail
. - user.twoFactor.methods
[x]
.id [String] -
The unique Id of the method.
- user.twoFactor.methods
[x]
.lastUsed [Boolean] -
true
if this method was used most recently. - user.twoFactor.methods
[x]
.method [String] -
The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
-
authenticator
-
email
-
sms
-
- user.twoFactor.methods
[x]
.mobilePhone [String] -
The value of the mobile phone for this method. Only present if user.twoFactor.methods
[x]
.method issms
. - user.twoFactor.methods
[x]
.secret [String] -
A base64 encoded secret
- user.twoFactorDelivery [String] Deprecated
-
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
Removed in version 1.26.0
-
- user.twoFactorEnabled [Boolean] Deprecated
-
Determines if the User has two factor authentication enabled for their account or not.
Removed in version 1.26.0
- user.username [String]
-
The username of the User.
- user.usernameStatus [String]
-
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- user.verified [Boolean]
-
Whether or not the User’s email has been verified.
For additional information, see these tutorials:
{
"user": {
"active": true,
"breachedPasswordLastCheckedInstant": 1471786483322,
"birthDate": "1976-05-30",
"connectorId": "e3306678-a53a-4964-9040-1c96f36dda72",
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"expiry": 1571786483322,
"firstName": "John",
"fullName": "John Doe",
"id": "00000000-0000-0001-0000-000000000000",
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"lastLoginInstant": 1471786483322,
"lastName": "Doe",
"memberships": [
{
"data": {
"externalId": "cc6714c6-286c-411c-a6bc-ee413cda1dbc"
},
"groupId": "2cb5c83f-53ff-4d16-88bd-c5e3802111a5",
"id": "27218714-305e-4408-bac0-23e7e1ddceb6",
"insertInstant": 1471786482322
}
],
"middleName": "William",
"mobilePhone": "303-555-1234",
"passwordChangeRequired": false,
"passwordLastUpdateInstant": 1471786483322,
"preferredLanguages": [
"en",
"fr"
],
"registrations": [
{
"applicationId": "10000000-0000-0002-0000-000000000001",
"data": {
"displayName": "Johnny",
"favoriteSports": [
"Football",
"Basketball"
]
},
"id": "00000000-0000-0002-0000-000000000000",
"insertInstant": 1446064706250,
"lastLoginInstant": 1456064601291,
"preferredLanguages": [
"en",
"fr"
],
"roles": [
"user",
"community_helper"
],
"timezone": "America/Chicago",
"username": "johnny123",
"usernameStatus": "ACTIVE"
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactor": {
"methods": [
{
"authenticator": {
"algorithm": "HmacSHA1",
"codeLength": 6,
"timeStep": 30
},
"id": "35VW",
"method": "authenticator"
},
{
"id": "V7SH",
"method": "sms",
"mobilePhone": "555-555-5555"
},
{
"email": "example@fusionauth.io",
"id": "7K2G",
"method": "email"
}
]
},
"usernameStatus": "ACTIVE",
"username": "johnny123",
"verified": true
}
}
Delete a User
This API is used to delete a User. You must specify the Id of the User on the URI. You can also specify whether or not the User is soft or hard deleted. A soft delete deactivates the User. A hard delete permanently deletes a User’s data.
Soft deleted users are marked as inactive but not deleted from FusionAuth. Deactivated users have their data retained but they are unable to authenticate. Users who have been deactivated can be reactivated; see Reactivate a User for more.
The data of a User who has been hard deleted is permanently removed from FusionAuth. The User’s data cannot be restored via the FusionAuth API or the administrative user interface. If you need to restore the User’s data, you must retrieve it from a database backup.
Request
Deactivate a User (Soft Delete)
DELETE /api/user/{userId}
DELETE /api/user/{userId}?hardDelete=true
Request Parameters
- userId [UUID] Required
-
The Id of the User to delete.
- hardDelete [Boolean] Optional defaults to
false
-
To Permanently delete a user from FusionAuth set this value to
true
. Once a user has been permanently deleted, the action cannot be undone. When this value is set tofalse
the user is marked as inactive and the user will be unable log into FusionAuth. This action may be undone by reactivating the user.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Response
This API does not return a JSON response body.
Code | Description |
---|---|
200 |
The request was successful. The response will be empty. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 |
The object you are trying to delete doesn’t exist. The response will be empty. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
504 |
One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |
Bulk Delete Users
This API is used to deactivate or delete multiple users in a single request.
This API has some limitations when FusionAuth is configured to use the database as the user search engine. These limitations are noted on the impacted request parameters below.
Request
DELETE /api/user/bulk?userId={userId}&userId={userId}
Deactivate Users by Search Query String
DELETE /api/user/bulk?queryString={queryString}&dryRun=false
Deactivate Users by Raw JSON Search Query
DELETE /api/user/bulk?query={query}&dryRun=false
Permanently Delete Users by User Id
DELETE /api/user/bulk?userId={userId}&userId={userId}&hardDelete=true
Permanently Delete Users by Search Query String
DELETE /api/user/bulk?queryString={queryString}&hardDelete=true&dryRun=false
Permanently Delete Users by Raw JSON Search Query
DELETE /api/user/bulk?query={query}&hardDelete=true&dryRun=false
Request Parameters
- dryRun [Boolean] Optional defaults to
false
-
To preview the user Ids to be deleted by the request without applying the requested action set this value to
true
. - hardDelete [Boolean] Optional defaults to
false
-
To Permanently delete a user from FusionAuth set this value to
true
. Once a user has been permanently deleted, the action cannot be undone. When this value is set tofalse
the user is marked as inactive and the user will be unable log into FusionAuth. This action may be undone by reactivating the user. - query [String] Optional Available since 1.13.0
-
The raw JSON Elasticsearch query that is used to search for Users. The userId, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
It is necessary to use the query parameter when querying against
registrations
in order to achieve expected results, as this field is defined as a nested datatype in the Elasticsearch mapping.Database search engine
This parameter is not compatible with the database search engine, it may only be used when Elasticsearch is configured as the user search engine.
- queryString [String] Optional Available since 1.13.0
-
The Elasticsearch query string that is used to search for Users to be deleted. The userId, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
Database search engine
The Elasticsearch query string DSL is not supported for the database search engine. Database search limits effective queries to single search terms that may match the following fields on the User:
-
firstName
-
lastName
-
fullName
-
email
-
username
The following is an example bulk delete request with a
queryString
value that is compatible with the database search engine:DELETE /api/user/bulk?queryString=jared%40fusionauth.io
-
- userId [UUID] Optional
-
The Id of the User to delete. Repeat this parameter for each user to be deleted. The userId, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Bulk delete using the request body. This allows for larger requests than are possible using request parameters.
DELETE /api/user/bulk
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- dryRun [Boolean] Optional defaults to
false
-
To preview the user Ids to be deleted by the request without applying the requested action set this value to
true
. - hardDelete [Boolean] Optional defaults to
false
-
To Permanently delete a user from FusionAuth set this value to
true
. Once a user has been permanently deleted, the action cannot be undone. When this value is set tofalse
the user is marked as inactive and the user will be unable log into FusionAuth. This action may be undone by reactivating the user. - query [String] Optional Available since 1.13.0
-
The raw JSON Elasticsearch query that is used to search for Users. The userIds, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
It is necessary to use the query parameter when querying against
registrations
in order to achieve expected results, as this field is defined as a nested datatype in the Elasticsearch mapping.Database search engine
This parameter is not compatible with the database search engine, it may only be used when Elasticsearch is configured as the user search engine.
- queryString [String] Optional Available since 1.13.0
-
The Elasticsearch query string that is used to search for Users to be deleted. The userIds, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
Database search engine
The Elasticsearch query string DSL is not supported for the database search engine. Database search limits effective queries to single search terms that may match the following fields on the User:
-
firstName
-
lastName
-
fullName
-
email
-
username
The following is an example bulk delete request with a
queryString
value that is compatible with the database search engine:DELETE /api/user/bulk?queryString=jared%40fusionauth.io
-
- userIds [Array] Optional
-
An array of User Ids to delete. The userIds, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
userIds
{
"dryRun": true,
"hardDelete": true,
"userIds": [
"5c1dc1a8-2fc8-4ae0-9372-e994be0f4341",
"dbf59ee1-2d24-4ea0-b977-2b6e2a5350bf",
"3e74294d-7de7-45a4-9592-4a198ddbdc73",
"cfaf34a0-aa66-4d3a-af14-6dbc5f9fb577",
"a2eb9268-e6f1-45f4-8eaa-50c0154983fe",
"b1b42d6b-3b44-47fb-bb32-26e0c71c62d3",
"8c91cb08-27df-4725-b3a8-98631bc8d9af",
"54df878b-c0a1-4951-a63a-3cf2f97edd17",
"946b3deb-25a5-4155-b137-bb5202d2ac98"
]
}
query
parameter to search for users with unverified registrations to a specific application
{
"bool": {
"must": [
{
"nested": {
"path": "registrations",
"query": {
"bool": {
"must": [
{
"match": {
"registrations.applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32"
}
},
{
"match": {
"registrations.verified": false
}
}
]
}
}
}
}
]
}
}
query
for users with unverified registrations to a specific application
{
"dryRun": true,
"hardDelete": true,
"query": "{\"bool\":{\"must\":[{\"nested\":{\"path\":\"registrations\",\"query\":{\"bool\":{\"must\":[{\"match\":{\"registrations.applicationId\":\"3c219e58-ed0e-4b18-ad48-f4f92793ae32\"}},{\"match\":{\"registrations.verified\":false}}]}}}}]}}"
}
query
parameter to search for users with a specific role
{
"bool": {
"must": [
[
{
"nested": {
"path": "registrations",
"query": {
"bool": {
"must": [
{
"match": {
"registrations.applicationId": "c50329fa-93e5-4618-8d9f-73d0ab069a54"
}
},
{
"match": {
"registrations.roles": "admin"
}
}
]
}
}
}
}
]
]
}
}
query
for users with with a specific role
{
"dryRun": true,
"hardDelete": true,
"query": "{\"bool\":{\"must\":[[{\"nested\":{\"path\":\"registrations\",\"query\":{\"bool\":{\"must\":[{\"match\":{\"registrations.applicationId\":\"c50329fa-93e5-4618-8d9f-73d0ab069a54\"}},{\"match\":{\"registrations.roles\":\"admin\"}}]}}}}]]}}"
}
queryString
for users with an email address matching a pattern
{
"dryRun": true,
"hardDelete": true,
"queryString": "email:*@fusionauth.io"
}
queryString
for users belonging to a specific group
{
"dryRun": true,
"hardDelete": true,
"queryString": "memberships.groupId:7f318a9d-3de4-4ded-9b53-1d97fd730868"
}
queryString
for users of a specific tenant. A global API key must be used, and you may not use the X-FusionAuth-TenantId
header when the search parameters include tenantId
{
"dryRun": true,
"hardDelete": true,
"queryString": "tenantId:39666465-6535-3731-3139-666363356438"
}
Response
The response for this API contains the information for the Users that were affected by the request.
Code | Description |
---|---|
200 |
The request was successful. The response will contain a JSON body. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
504 |
One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |
Response Body
- dryRun [Boolean]
-
Whether the request was a dry run or the requested action was applied.
- hardDelete [Boolean]
-
Whether the requested action was deactivation or permanent deletion.
- total [Integer]
-
The count of affected Users.
- userIds [Array<UUID>]
-
The list of affected User Ids. This field is omitted from the response when no users were affected by the request.
{
"dryRun": true,
"hardDelete": true,
"total": 2,
"userIds": [
"00000000-0000-0001-0000-000000000000",
"00000000-0000-0001-0000-000000000001"
]
}
Reactivate a User
This API is used to reactivate an inactive Users. You must specify the Id of the User on the URI.
Request
PUT /api/user/{userId}?reactivate=true
Request Parameters
- userId [UUID] Required
-
The Id of the User to reactivate.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Response
The response for this API contains the information for the User that was reactivated.
Code | Description |
---|---|
200 |
The request was successful. The response will contain a JSON body. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 |
The object you are trying to update doesn’t exist. The response will be empty. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
504 |
One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |
Response Body
- user.active [Boolean]
-
True if the User is active. False if the User has been deactivated. Deactivated Users will not be able to login.
- user.birthDate [String]
-
The User’s birthdate formatted as
YYYY-MM-DD
- user.breachedPasswordLastCheckedInstant [Long]
-
The instant this user’s password was last checked to determine if it is compromised.
- user.connectorId [UUID] Available since 1.18.0
-
The unique Id of the Connector associated with the System of Record being used to authenticate the user.
- user.cleanSpeakId [UUID]
-
This Id is used by FusionAuth when the User’s username is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- user.data [Object]
-
An object that can hold any information about the User that should be persisted.
- user.data.email [String]
-
This field will be used as the email address if no user.email field is found.
This feature was removed in version 1.26.0 and added back in in 1.27.2.
- user.email [String]
-
The User’s email address.
- user.expiry [Long]
-
The expiration instant of the User’s account. An expired user is not permitted to login.
- user.firstName [String]
-
The first name of the User.
- user.fullName [String]
-
The User’s full name as a separate field that is not calculated from firstName and lastName.
- user.id [UUID]
-
The User’s unique Id.
- user.imageUrl [String]
-
The URL that points to an image file that is the User’s profile image.
- user.insertInstant [Long]
-
The instant when the user was created.
- user.lastLoginInstant [Long]
-
The instant when the User logged in last.
- user.lastName [String]
-
The User’s last name.
- user.lastUpdateInstant [Long]
-
The instant when the User was last updated.
- user.memberships [Array]
-
The list of memberships for the User.
- user.memberships
[x]
.data [Object] -
An object that can hold any information about the User for this membership that should be persisted.
- user.memberships
[x]
.groupId [UUID] -
The Id of the Group of this membership.
- user.memberships
[x]
.id [UUID] -
The unique Id of this membership.
- user.memberships
[x]
.insertInstant [Long] -
The instant that the membership was created.
- user.middleName [String]
-
The User’s middle name.
- user.mobilePhone [String]
-
The User’s mobile phone number. This is useful if you will be sending push notifications or SMS messages to the User.
- user.parentEmail [String] Available since 1.7.0
-
The email address of the user’s parent or guardian. If this value was provided during a create or update operation, this value will only remain until the child is claimed by a parent.
- user.passwordChangeRequired [Boolean]
-
Indicates that the User’s password needs to be changed during their next login attempt.
- user.passwordLastUpdateInstant [Long]
-
The instant that the User last changed their password.
- user.preferredLanguages [Array<String>]
-
An array of locale strings that give, in order, the User’s preferred languages. These are important for email templates and other localizable text. See Locales.
- user.registrations [Array]
-
The list of registrations for the User. This will include registrations for inactive applications.
- user.registrations
[x]
.applicationId [UUID] -
The Id of the Application that this registration is for.
- user.registrations
[x]
.authenticationToken [String] -
The Authentication Token for this registration (if one exists).
- user.registrations
[x]
.cleanSpeakId [UUID] -
This Id is used by FusionAuth when the User’s username for this registration is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- user.registrations
[x]
.data [Object] -
An object that can hold any information about the User for this registration that should be persisted.
- user.registrations
[x]
.id [UUID] -
The Id of this registration.
- user.registrations
[x]
.insertInstant [Long] -
The instant that this registration was created.
- user.registrations
[x]
.lastLoginInstant [Long] -
The instant that the User last logged into the Application for this registration.
- user.registrations
[x]
.preferredLanguages [Array<String>] -
An array of locale strings that give, in order, the User’s preferred languages for this registration. These are important for email templates and other localizable text.
- user.registrations
[x]
.roles [Array<String>] -
The list of roles that the User has for this registration.
- user.registrations
[x]
.timezone [String] -
The User’s preferred timezone for this registration. The string will be in an IANA time zone format.
- user.registrations
[x]
.tokens [Map<String,String>] Deprecated -
A map that contains tokens returned from identity providers.
For example, if this user has authenticated using the Facebook Identity Provider, the Facebook access token will be available in this map, keyed by name
Facebook
. For an OpenID Connect Identity provider, or other generic providers, if a token is stored it will be keyed by the Identity Provider unique Id.Removed in 1.28.0
The token returned and stored from the Identity Provider is now stored in the IdP link and is retrievable using the Identity Provider Link API.
- user.registrations
[x]
.username [String] -
The username of the User for this registration only. This is for display purposes and cannot be used to login.
- user.registrations
[x]
.usernameStatus [String] -
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- user.registrations
[x]
.verified [Boolean] -
This value indicates if this User’s registration has been verified.
For additional information, see these tutorials:
- user.tenantId [UUID]
-
The Id of the Tenant that this User belongs to.
- user.timezone [String]
-
The User’s preferred timezone. This can be used as a default to display instants, and it is recommended that you allow Users to change this per-session. The string will be in an IANA time zone format.
- user.twoFactor.methods
[x]
.authenticator.algorithm [String] -
The algorithm used by the TOTP authenticator. With the current implementation, this will always be
HmacSHA1
. - user.twoFactor.methods
[x]
.authenticator.codeLength [Integer] -
The length of code generated by the TOTP. With the current implementation, this will always be
6
. - user.twoFactor.methods
[x]
.authenticator.timeStep [Integer] -
The time-step size in seconds. With the current implementation, this will always be 30.
- user.twoFactor.methods
[x]
.email [String] -
The value of the email address for this method. Only present if user.twoFactor.methods
[x]
.method isemail
. - user.twoFactor.methods
[x]
.id [String] -
The unique Id of the method.
- user.twoFactor.methods
[x]
.lastUsed [Boolean] -
true
if this method was used most recently. - user.twoFactor.methods
[x]
.method [String] -
The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
-
authenticator
-
email
-
sms
-
- user.twoFactor.methods
[x]
.mobilePhone [String] -
The value of the mobile phone for this method. Only present if user.twoFactor.methods
[x]
.method issms
. - user.twoFactor.methods
[x]
.secret [String] -
A base64 encoded secret
- user.twoFactorDelivery [String] Deprecated
-
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
Removed in version 1.26.0
-
- user.twoFactorEnabled [Boolean] Deprecated
-
Determines if the User has two factor authentication enabled for their account or not.
Removed in version 1.26.0
- user.username [String]
-
The username of the User.
- user.usernameStatus [String]
-
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- user.verified [Boolean]
-
Whether or not the User’s email has been verified.
For additional information, see these tutorials:
{
"user": {
"active": true,
"breachedPasswordLastCheckedInstant": 1471786483322,
"birthDate": "1976-05-30",
"connectorId": "e3306678-a53a-4964-9040-1c96f36dda72",
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"expiry": 1571786483322,
"firstName": "John",
"fullName": "John Doe",
"id": "00000000-0000-0001-0000-000000000000",
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"lastLoginInstant": 1471786483322,
"lastName": "Doe",
"memberships": [
{
"data": {
"externalId": "cc6714c6-286c-411c-a6bc-ee413cda1dbc"
},
"groupId": "2cb5c83f-53ff-4d16-88bd-c5e3802111a5",
"id": "27218714-305e-4408-bac0-23e7e1ddceb6",
"insertInstant": 1471786482322
}
],
"middleName": "William",
"mobilePhone": "303-555-1234",
"passwordChangeRequired": false,
"passwordLastUpdateInstant": 1471786483322,
"preferredLanguages": [
"en",
"fr"
],
"registrations": [
{
"applicationId": "10000000-0000-0002-0000-000000000001",
"data": {
"displayName": "Johnny",
"favoriteSports": [
"Football",
"Basketball"
]
},
"id": "00000000-0000-0002-0000-000000000000",
"insertInstant": 1446064706250,
"lastLoginInstant": 1456064601291,
"preferredLanguages": [
"en",
"fr"
],
"roles": [
"user",
"community_helper"
],
"timezone": "America/Chicago",
"username": "johnny123",
"usernameStatus": "ACTIVE"
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactor": {
"methods": [
{
"authenticator": {
"algorithm": "HmacSHA1",
"codeLength": 6,
"timeStep": 30
},
"id": "35VW",
"method": "authenticator"
},
{
"id": "V7SH",
"method": "sms",
"mobilePhone": "555-555-5555"
},
{
"email": "example@fusionauth.io",
"id": "7K2G",
"method": "email"
}
]
},
"usernameStatus": "ACTIVE",
"username": "johnny123",
"verified": true
}
}
Import Users
This API is used to bulk import multiple Users into FusionAuth. Each User must have at least an email or a username. This request is useful for migrating data from an existing database into FusionAuth. Additionally, you can provide an Id for each User inside the JSON User object of the request body.
Request
POST /api/user/import
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
You must provide either the email or the username field for each User. This will be used to authenticate the User and is also the User’s unique identifier. These fields are marked as optional below, but you must provide one of them.
Request Body
- encryptionScheme [String] Optional
-
The encryption scheme used to encrypt plaintext passwords encountered in the request. If this value is omitted the system configured value will be used.
The following encryptors are provided with FusionAuth:
-
salted-pbkdf2-hmac-sha256-512
Available since 1.34.0 -
salted-pbkdf2-hmac-sha512-512
Available since 1.43.0 -
phpass-md5
Available since 1.45.0 -
phpass-sha512
Available since 1.45.0
- factor [Integer] Optional
-
The factor used to encrypt plaintext passwords encountered in the request. If this value is omitted the system configured value will be used.
- users [Array] Required
-
The list of Users to import.
- users
[x]
.active [Boolean] Optional defaults tofalse
-
True if the User is active. False if the User has been deactivated. Deactivated Users will not be able to login. Generally this should be set to
true
during the bulk import. - users
[x]
.birthDate [String] Optional -
YYYY-MM-DD
formatted date of the User’s birth. - users
[x]
.data [Object] Optional -
An object that can hold any information about a User that should be persisted.
- user
[x]
.data.email [String] Optional -
This field will be used as the email address if no user.email field is found. This field may be modified by advanced registration forms or the API. Setting this value to another account’s email address allows that account to, in some cases, access information about this user.
If user
richard
has a user.data.email with a value ofdinesh@fusionauth.io
, whoever controlsdinesh@fusionauth.io
has elevated access to therichard
account. That user can now reset the password on therichard
account, for example. This functionality may be useful in certain scenarios, such as when accounts must share an email address. Think through the security ramifications before using this feature.This feature was removed in version 1.26.0 and added back in in 1.27.2.
- users
[x]
.email [String] Optional -
The User’s email address.
- users
[x]
.encryptionScheme [String] Optional defaults tosalted-pbkdf2-hmac-sha256
-
The method for encrypting the User’s password. If the password value is already encrypted this value is required.
Omitting this value indicates the password is in plain text and it will be encrypted using the default password encryptor.
Importing users with plain text passwords is very slow because FusionAuth will hash each one using the default scheme. Grab some popcorn and catch a movie it can take up to several hundred milliseconds per user.
The following encryptors are provided with FusionAuth:
-
salted-pbkdf2-hmac-sha256-512
Available since 1.34.0 -
salted-pbkdf2-hmac-sha512-512
Available since 1.43.0 -
phpass-md5
Available since 1.45.0 -
phpass-sha512
Available since 1.45.0If you don’t see the scheme needed for importing your existing password you can also create your own password encryptor or we can build it for you. See the Custom Password Hashing section for more information.
- users
[x]
.expiry [Long] Optional -
The expiration instant of the User’s account. After this instant is reached, the User’s account will automatically be deactivated.
- users
[x]
.factor [String] Optional -
The factor used by the password encryption scheme. If omitted the factor will determined either by the system configured factor or the default value defined by the
PasswordEncryptor
.The factor will generally be used as an iteration count to generate the hash. The actual use of this value is up to the
PasswordEncryptor
implementation. - users
[x]
.firstName [String] Optional -
The first name of the User.
- users
[x]
.fullName [String] Optional -
The User’s full name as a separate field that is not calculated from firstName and lastName.
- users
[x]
.id [UUID] Optional defaults to secure random UUID -
The Id of the User. If not specified a secure random UUID will be generated.
- users
[x]
.imageUrl [String] Optional -
The URL that points to an image file that is the User’s profile image.
- users
[x]
.insertInstant [Long] Optional defaults to now -
The instant when the user was created.
- users
[x]
.lastName [String] Optional -
The User’s last name.
- users
[x]
.memberships [Array] Optional -
The list of memberships for the User.
- users
[x]
.memberships[x]
.data [Object] Optional -
An object that can hold any information about the User for this membership that should be persisted.
- users
[x]
.memberships[x]
.groupId [UUID] Required -
The Id of the Group of this membership.
- users
[x]
.memberships[x]
.id [UUID] Optional defaults to secure random UUID -
The unique Id of this membership. If not specified a secure random UUID will be generated.
- users
[x]
.middleName [String] Optional -
The User’s middle name.
- users
[x]
.mobilePhone [String] Optional -
The User’s mobile phone number. This is useful is you will be sending push notifications or SMS messages to the User.
- users
[x]
.password [String] Required -
The User’s password. If encryptionScheme is provided this value is the existing password hash, if encryptionScheme is not provided this value is assumed to be plain text and it will be hashed during import.
The value of password should contain only the password hash, or, if the encryptionScheme is omitted, the plain text password. Unless you are using a custom plugin that does not utilize base64, password should be base64 encoded. It is recommended to use a base64 encoded string, but if you are importing hashes from a legacy system that uses base16, base32, or another encoding and are writing a custom plugin, import the hash in the same format the plugin produces.
Please see the Password Hashes section for more information about importing particular password hashes.
- users
[x]
.passwordChangeReason [String] Optional defaults toAdministrative
-
When passwordChangeRequired is set to
true
you may optionally set a reason for this change. The possible values are:-
Administrative
- the password must be changed due to an administrative action -
Breached
- the password must be changed due to it being identified as breached in some fashion -
Expired
- the password must be changed due to expiration -
Validation
- the password must be changed due to the password no longer meeting the configured minimum requirements
In practice, leaving the default makes the most sense. The other reasons are used by FusionAuth during runtime to automatically require a user to change their password.
-
- users
[x]
.passwordChangeRequired [Boolean] Optional defaults tofalse
-
Indicates that the User’s password needs to be changed during the next login attempt.
- users
[x]
.passwordLastUpdateInstant [Long] Optional defaults to now -
Indicates that last instant the password was changed.
If
encryptionScheme
is omitted this value will be ignored and set to now.Note that if you have enabled password expiration or plan to do so in the future and you set this value to
0
or some other arbitrary time in the past that is greater than the password expiration value in days, these users will be required to change their password. It is recommended that you omit this value and allow the default value to be set unless you know the last time the user changed their password. - users
[x]
.preferredLanguages [Array<String>] Optional -
An array of locale strings that give, in order, the User’s preferred languages. These are important for email templates and other localizable text. See Locales.
- users
[x]
.registrations [Array] Optional -
The list of registrations for the User.
- users
[x]
.registrations[x]
.applicationId [UUID] Required -
The Id of the Application that this registration is for.
- users
[x]
.registrations[x]
.cleanSpeakId [UUID] Optional -
This Id is used by FusionAuth when the User’s username for this registration is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- users
[x]
.registrations[x]
.data [Object] Optional -
An object that can hold any information about the User for this registration that should be persisted.
- users
[x]
.registrations[x]
.id [UUID] Optional defaults to secure random UUID -
The Id of this registration. If not specified a secure random UUID will be generated.
- users
[x]
.registrations[x]
.insertInstant [Long] Optional defaults to now -
The instant that this registration was created.
- users
[x]
.registrations[x]
.lastLoginInstant [Long] Optional -
The instant that the User last logged into the Application for this registration.
- users
[x]
.registrations[x]
.preferredLanguages [Array<String>] Optional -
An array of locale strings that give, in order, the User’s preferred languages for this registration. These are important for email templates and other localizable text. See Locales.
- users
[x]
.registrations[x]
.roles [Array<String>] Optional -
The list of roles that the User has for this registration.
- users
[x]
.registrations[x]
.username [String] Optional -
The username of the User for this registration only.
- users
[x]
.registrations[x]
.usernameStatus [String] Optional defaults toACTIVE
-
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
This state is managed by CleanSpeak, it may be changed by setting it on this request.
-
- users
[x]
.registrations[x]
.verified [Boolean] Optional defaults tofalse
-
Set this value to
true
in order to mark this registration as verified. - users
[x]
.salt [String] Optional -
The User’s password salt. Required if
encryptionScheme
is provided. Empty string is allowed.When using any of the FusionAuth provided password encryption schemes, the incoming value is expected to be a Base64 encoded string of UTF-8 bytes. If your salt is stored as a plain string, you will need to Base64 encode it prior to import.
- users
[x]
.tenantId [UUID] Optional -
The User’s tenant Id. If more than one tenant exists and you do not provide the
X-FusionAuth-TenantId
HTTP header or use API key to indicate which Tenant this request is for then this field will be required to complete the request.When an API key is used that is locked to a Tenant or the tenant
X-FusionAuth-TenantId
HTTP header is provided this field is ignored. - users
[x]
.timezone [String] Optional -
The User’s preferred timezone. The string must be in an IANA time zone format.
- users
[x]
.twoFactor.methods[x]
.authenticator.algorithm [String] Optional -
The algorithm used by the TOTP authenticator. With the current implementation, this must be
HmacSHA1
if provided. Any other value will be ignored. - users
[x]
.twoFactor.methods[x]
.authenticator.codeLength [Integer] Optional -
The length of code generated by the TOTP. With the current implementation, this must be
6
if provided. Any other value will be ignored. - users
[x]
.twoFactor.methods[x]
.authenticator.timeStep [Integer] Optional -
The time-step size in seconds. With the current implementation, this must be
30
if provided. Any other value will be ignored. - users
[x]
.twoFactor.methods[x]
.email [String] Optional -
The value of the email address for this method. Only present if user.twoFactor.methods
[x]
.method isemail
. - users
[x]
.twoFactor.methods[x]
.method [String] Optional -
The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
-
authenticator
-
email
-
sms
-
- users
[x]
.twoFactor.methods[x]
.mobilePhone [String] Optional -
The value of the mobile phone for this method. Only present if user.twoFactor.methods
[x]
.method issms
. - users
[x]
.twoFactor.methods[x]
.secret [String] Optional -
A base64 encoded secret
This field is required when method is
authenticator
. - users
[x]
.twoFactor.recoveryCodes [Array<String>] Optional -
A list of recovery codes. These may be used in place of a code provided by an MFA factor. They are single use.
If a recovery code is used in a disable request, all MFA methods are removed. If, after that, a Multi-Factor method is added, a new set of recovery codes will be generated.
- users
[x]
.twoFactorDelivery [String] Optional defaults toNone
Deprecated -
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
When using
TextMessage
the User will also need a validmobilePhone
.Removed in version 1.26.0
-
- users
[x]
.twoFactorEnabled [Boolean] Optional defaults tofalse
-
Determines if the User has two factor authentication enabled for their account or not.
See the Enable Two Factor and Disable Two Factor APIs as an alternative to performing this action using the User API.
Removed in version 1.26.0
- users
[x]
.twoFactorSecret [String] Optional Deprecated -
The Base64 encode secret used to generate Two Factor verification codes.
You may optionally use value provided in the
secret
field returned by the Two Factor Secret API instead of generating this value yourself.Unless you are using
TextMessage
as your delivery type, ensure you are able to share the secret with the User before enabling Two Factor authentication. Beginning in version 1.17.0, if you do create a User withTextMessage
set as thetwoFactorDelivery
type and you omit this value, the secret will be generated for you. The secret can be generated because it is not necessary to share the secret with the User for this delivery method.When using
None
as thetwoFactorDelivery
this value will be required.Removed in version 1.26.0
- users
[x]
.username [String] Optional -
The username of the User.
- users
[x]
.usernameStatus [String] Optional defaults toACTIVE
-
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
This state is managed by CleanSpeak, it may be changed by setting it on this request.
-
- users
[x]
.verified [Boolean] Optional defaults tofalse
-
Set this value to
true
in order to mark the user as having a verified email address. - validateDbConstraints [Boolean] Optional defaults to
false
-
Set this value to
true
in order to perform additional validation of the request.The import request is intended to be used to populate the initial set of users, this means FusionAuth does not expect to find duplicate users in the database. If a duplicate is encountered a
500
will be returned without this additional validation.If you intend to use this API with existing users in FusionAuth set this value to
true
to request additional validation be performed on the input request and a400
response will be returned with a JSON body indicating the duplicate values encountered.Setting this value to
true
will dramatically decrease the performance of this request. If importing large numbers of users in a single request you may need to increase request timeouts to ensure this request does not timeout before it has completed.
{
"users": [
{
"active": true,
"birthDate": "1976-05-30",
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"encryptionScheme": "salted-sha256",
"expiry": 1571786483322,
"factor": 24000,
"firstName": "John",
"fullName": "John Doe",
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"insertInstant": 1331449200000,
"lastName": "Doe",
"memberships": [
{
"data": {
"externalId": "cc6714c6-286c-411c-a6bc-ee413cda1dbc"
},
"groupId": "2cb5c83f-53ff-4d16-88bd-c5e3802111a5"
}
],
"middleName": "William",
"mobilePhone": "303-555-1234",
"password": "5ac152b6f8bdb8bb12959548d542cb237c4a730064bf88bbb8dd6e204912baad",
"passwordChangeRequired": false,
"preferredLanguages": [
"en",
"fr"
],
"registrations": [
{
"applicationId": "00000000-0000-0000-0000-000000000002",
"data": {
"birthplace": "Bremen"
},
"insertInstant": 1331449200000,
"preferredLanguages": [
"de"
],
"roles": [
"moderator"
],
"username": "Mausebär",
"verified": true
}
],
"salt": "NDdiYWZkZDMtYjk5ZC00ZmZkLWE1YmUtZTQxNGM4MDkwNWYw",
"timezone": "America/Denver",
"twoFactor": {
"methods": [
{
"authenticator": {
"algorithm": "HmacSHA1",
"codeLength": 6,
"timeStep": 30
},
"secret": "aGVsbG8Kd29ybGQKaGVsbG8gaGVsbG8=",
"method": "authenticator"
},
{
"method": "sms",
"mobilePhone": "555-555-5555"
},
{
"method": "email",
"email": "example@fusionauth.io"
}
]
},
"usernameStatus": "ACTIVE",
"username": "johnny123",
"verified": true
}
]
}
Response
Only a status code is available on the Import API, no JSON body will be returned.
Code | Description |
---|---|
200 |
The request was successful. The response will contain a JSON body. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
504 |
One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |
Password Hashes
Password hashes can be imported into FusionAuth. This allows users to transparently use their old passwords while at no time exposing the plaintext password. This section contains details about importing specific password hashes.
You can also learn more about hashes in the password hashing reference, and you can implement your own custom hash as well.
Encoding
The standard FusionAuth password hashing schemes require the password hash to be a base64 encoded string. If your password hashes are encoded in a different format, they will need to either be converted and imported as base64, or you can create a custom plugin using an alternative encoding. You can see an example of converting below.
It is recommended to use a base64 encoded string, but if importing hashes from a legacy system that uses base16, base32, or another encoding, import the hash in the same format the plugin produces.
hash_in_hex = "25d55ad283aa400af464c76d713c07ad"
def hex_to_base64_digest(hexdigest)
[[hexdigest].pack("H*")].pack("m0")
end
puts hex_to_base64_digest(hash_in_hex)
Bcrypt
When importing a bcrypt hash, you may have a value such as $2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
. This single string represents the bcrypt version, factor, salt and hash.
The number before the final $
is the factor, the 22 characters after the final $
is the salt and the last 31 characters are the hash.
For the above bcrypt hash, 10
is the factor and should be placed in the factor field. N9qo8uLOickgx2ZMRZoMye
is the salt and should be placed in the salt field. IjZAgcfl7p92ldGxad68LJZdL17lhWy
is the hash value and should be placed in the password field.
MD5
When importing an MD5 password hash, you may not have a salt. If this is the case, use the empty string, ''
, as the salt. You may still use the salted MD5 plugin provided by FusionAuth.
MD5 is commonly stored in hexadecimal format, such as 25d55ad283aa400af464c76d713c07ad
. The FusionAuth Import Users API requires imported password hashes to be base64 encoded. Convert any hexadecimal values to base64 before importing, or the import will not work.
Here is an example ruby script to convert hexadecimal values to base64 encoded:
hash_in_hex = "25d55ad283aa400af464c76d713c07ad"
def hex_to_base64_digest(hexdigest)
[[hexdigest].pack("H*")].pack("m0")
end
puts hex_to_base64_digest(hash_in_hex)
Import Refresh Tokens
Available Since Version 1.19.0
This API is used to import refresh tokens from an external system, this would generally be done during an initial user import or as an auxiliary step during a migration strategy.
Before using this API, create the Users, Applications and User Registrations. A validation error will be returned if the user does not exist, or is not registered for the application.
Request
POST /api/user/refresh-token/import
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- refreshTokens [Array] Required
-
The list of refresh tokens to import.
- refreshTokens
[x]
.applicationId [UUID] Required -
The unique Application Id that corresponds to the User Registration for this refresh token.
- refreshTokens
[x]
.metaData.device.description [String] Optional -
A human readable description of the device represented by the
device
parameter. - refreshTokens
[x]
.metaData.device.lastAccessedAddress [String] Optional -
The IP address of this login request.
- refreshTokens
[x]
.metaData.device.lastAccessedInstant [Long] Optional -
The instant of this login request.
- refreshTokens
[x]
.metaData.device.name [String] Optional -
A human readable name of the device represented by the
device
parameter. - refreshTokens
[x]
.metaData.device.type [String] Optional -
The type of device represented by the
device
parameter. The following types may be specified:-
BROWSER
-
DESKTOP
-
LAPTOP
-
MOBILE
-
OTHER
-
SERVER
-
TABLET
-
TV
-
UNKNOWN
-
- refreshTokens
[x]
.startInstant [String] Required -
The instant of the start of this token. This value will be used to calculate the token expiration.
- refreshTokens
[x]
.token [String] Required -
The string representation of the refresh token.
Prior to version
1.33.0
, this value was limited to a maximum length of191
characters. If you need to import a token that is longer than191
characters, ensure you have upgraded to version1.33.0
or later. - refreshTokens
[x]
.userId [UUID] Required -
The unique user Id of the refresh token owner.
- validateDbConstraints [Boolean] Optional defaults to
false
-
Set this value to
true
in order to perform additional validation of the request. This validation includes, among other things, confirming that a user exists and is registered for the application which thisrefreshToken
was created for.If this is
false
, any errors such as duplicated refresh token values will return a500
error without any additional messages. If this istrue
, additional validation will be performed on the input request and a400
response will be returned with a JSON body indicating duplicate values or other error conditions encountered.Setting this value to
true
will dramatically decrease the performance of this request. If importing large numbers of tokens in a single request you may need to increase request timeouts to ensure this request does not timeout before it has completed.
{
"refreshTokens": [
{
"applicationId": "18a054da-f72d-480d-8da5-1f17d63bda87",
"metaData": {
"device": {
"description": "My refresh token imported from Umbrella Corp.",
"lastAccessedAddress": "42.42.42.42",
"lastAccessedInstant": 1598315358855,
"name": "John's iPad",
"type": "TABLET"
}
},
"startInstant": 1598315358855,
"token": "YRjxLpsjRqL7zYuKstXogqioA_P3Z4fiEuga0NCVRcDSc8cy_9msxg",
"userId": "e2b25780-fe20-4a69-ab6f-5e84744bc959"
}
]
}
Response
The response does not contain a body, the HTTP status code will indicate the result of the request.
Code | Description |
---|---|
200 |
The request was successful. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
Search for Users
This API is used to search for Users.
This API may be called using the GET
or POST
HTTP methods, examples of each are provided below.
The POST
method is provided to allow for a richer request object without worrying about exceeding the maximum length of a URL.
Calling this API with either the GET
or POST
HTTP method will will provide the same search results given the same query parameters.
Request
Which search query parameters are available and how they behave depends on the search engine type. Read more about the different types of search engines.
Database Search Engine
This is a good choice for smaller installs, embedded scenarios, or other places where the additional capability of Elasticsearch is not required.
Available Since Version 1.16.0
GET /api/user/search?ids={uuid}&ids={uuid}
Search for Users by a query string
GET /api/user/search?queryString={queryString}
Search for Users by a query string and sort the response
GET /api/user/search?queryString={queryString}&sortFields[0].name={name}&sortFields[0].order={order}
Request Parameters
- accurateTotal [Boolean] Optional Defaults to
false
Available since 1.24.0 -
Set this value equal to
true
to receive an accurate hit count on the API response.By default the search engine will limit the hit count to 10,000 users. This means that even if your query may match more than 10,000 users, the returned total count will be 10,000. This is adequate for many use cases such as pagination and general purpose queries. If you are looking for an accurate user count that can exceed 10,000 matches, you will want to set this value equal to
true
. - ids [UUID] Optional
-
A User Id to retrieve. By specifying this URL parameter multiple times you can lookup multiple Users. Using this parameter is mutually exclusive with the queryString field and is not paginated or sorted using the sortFields field.
- numberOfResults [Integer] Optional defaults to
25
-
The number of search results to return. Used for pagination.
- queryString [String] Optional
-
A query string that is used to search for Users. Using this parameter is mutually exclusive with the ids field.
Database search limits effective queries to single search terms that may match the following fields on the User:
-
firstName
-
lastName
-
fullName
-
email
-
username
The search matches against all of these fields and any user with a matching field will be returned. The match is case-insensitive, and you may not search by prefix or suffix. Whitespace is not allowed in the search. Regular expressions may not be used. A value of
*
will match all records.
-
- startRow [Integer] Optional defaults to 0
-
The start row within the search results to return. Used for pagination.
- sortFields [Array] Optional
-
An array of sort fields used to sort the result. The order the sort fields are provided will be maintained in the sorted output.
- sortFields[
x
].name [String] Required -
The name of the field to sort.
Required if sortFields is provided.
The following field names are supported for the database search engine:
-
birthDate
-
email
-
fullName
-
id
-
insertInstant
-
lastLoginInstant
-
login
-
tenantId
-
username
-
- sortFields
[x]
.order [String] Optional defaults toasc
-
The order to sort the specified field. Possible values are:
-
asc
-
desc
-
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Search for Users using a JSON request body. This allows for larger requests than are possible using request parameters.
POST /api/user/search
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- search.accurateTotal [Boolean] Optional Defaults to
false
Available since 1.24.0 -
Set this value equal to
true
to receive an accurate hit count on the API response.By default the search engine will limit the hit count to 10,000 users. This means that even if your query may match more than 10,000 users, the returned total count will be 10,000. This is adequate for many use cases such as pagination and general purpose queries. If you are looking for an accurate user count that can exceed 10,000 matches, you will want to set this value equal to
true
. - search.ids [UUID] Optional
-
A User Id to retrieve. By specifying this URL parameter multiple times you can lookup multiple Users. Using this parameter is mutually exclusive with the queryString field and is not paginated or sorted using the sortFields field.
- search.numberOfResults [Integer] Optional defaults to
25
-
The number of search results to return. Used for pagination.
- search.queryString [String] Optional
-
A query string that is used to search for Users. Using this parameter is mutually exclusive with the ids field.
Database search limits effective queries to single search terms that may match the following fields on the User:
-
firstName
-
lastName
-
fullName
-
email
-
username
The search matches against all of these fields and any user with a matching field will be returned. The match is case-insensitive, and you may not search by prefix or suffix. Whitespace is not allowed in the search. Regular expressions may not be used. A value of
*
will match all records.
-
- search.startRow [Integer] Optional defaults to 0
-
The start row within the search results to return. Used for pagination.
- search.sortFields [Array] Optional
-
An array of sort fields used to sort the result. The order the sort fields are provided will be maintained in the sorted output.
- search.sortFields[
x
].name [String] Required -
The name of the field to sort.
Required if sortFields is provided.
The following field names are supported for the database search engine:
-
birthDate
-
email
-
fullName
-
id
-
insertInstant
-
lastLoginInstant
-
login
-
tenantId
-
username
-
- search.sortFields
[x]
.order [String] Optional defaults toasc
-
The order to sort the specified field. Possible values are:
-
asc
-
desc
-
Request Body Examples
{
"search": {
"ids": [
"a6e3ed2d-582b-4ec3-aa3f-4323c8f39fe9",
"00000000-0000-0001-0000-000000000000"
]
}
}
{
"search": {
"numberOfResults": 25,
"queryString": "@fusionauth.io",
"sortFields": [
{
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
piper
.
{
"search": {
"numberOfResults": 25,
"queryString": "piper",
"sortFields": [
{
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
{
"search": {
"numberOfResults": 25,
"queryString": "*",
"sortFields": [
{
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
Elasticsearch Search Engine
The Elasticsearch engine has advanced querying capabilities and better performance. You can also review the Elasticsearch search guide for more examples.
GET /api/user/search?ids={uuid}&ids={uuid}
Search for Users by a query string
GET /api/user/search?queryString={queryString}
Search for Users by a query string and sort the response
GET /api/user/search?queryString={queryString}&sortFields[0].name={name}&sortFields[0].order={order}
Search for Users by a raw JSON query
GET /api/user/search?query={query}
Request Parameters
- accurateTotal [Boolean] Optional Defaults to
false
Available since 1.24.0 -
Set this value equal to
true
to receive an accurate hit count on the API response.By default the search engine will limit the hit count to 10,000 users. This means that even if your query may match more than 10,000 users, the returned total count will be 10,000. This is adequate for many use cases such as pagination and general purpose queries. If you are looking for an accurate user count that can exceed 10,000 matches, you will want to set this value equal to
true
. - ids [UUID] Optional
-
A User Id to retrieve. By specifying this URL parameter multiple times you can lookup multiple Users. Using this parameter is mutually exclusive with the query and queryString fields and is not paginated or sorted using sortFields field.
Using this parameter will not hit the Elasticsearch index, instead it will cause users to be retrieved by Id only.
- numberOfResults [Integer] Optional defaults to
25
-
The number of search results to return. Used for pagination.
- query [String] Optional Available since 1.13.0
-
The raw JSON Elasticsearch query that is used to search for Users. The ids, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
It is necessary to use the query parameter when querying against
registrations
in order to achieve expected results, as this field is defined as a nested datatype in the Elasticsearch mapping. - queryString [String] Optional
-
The Elasticsearch query string that is used to search for Users. The ids, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
The match is case-insensitive. Whitespace is allowed in the search, but must be URL escaped; for example, using
%20
for a space character. Elasticsearch compatible regular expressions may be used, so you may search by prefix or suffix using the*
wildcard.You may search against specific fields like so:
email:*fusionauth.io
. This will match only users with afusionauth.io
email address. You may find the available fields for matching by retrieving the Elasticsearch mapping. - startRow [Integer] Optional defaults to 0
-
The start row within the search results to return. Used for pagination.
- sortFields [Array] Optional
-
An array of sort fields used to sort the result. The order the sort fields are provided will be maintained in the sorted output.
- sortFields[
x
].missing [String] Optional defaults to_last
-
The value to substitute if this field is not defined. Two special values may be used:
-
_first
When the field is not defined sort this record first. -
_last
When the field is not defined sort this record last.
-
- sortFields[
x
].name [String] Optional -
The name of the field to sort.
Required if sortFields is provided.
Due to how the search index is structured not all fields on the user are sortable. The following field names are currently supported.
-
birthDate
-
email
-
fullName
-
id
Available since 1.13.0 -
insertInstant
-
lastLoginInstant
Available since 1.13.0 -
login
-
registrations.applicationId
Available since 1.13.0 -
registrations.id
Available since 1.13.0 -
registrations.insertInstant
Available since 1.13.0 -
registrations.lastLoginInstant
Available since 1.13.0 -
registrations.roles
Available since 1.13.0 -
tenantId
-
username
-
- sortFields
[x]
.order [String] Optional defaults toasc
-
The order to sort the specified field. Possible values are:
-
asc
-
desc
-
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Search for Users using a JSON request body. This allows for larger requests than are possible using request parameters.
POST /api/user/search
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- search.accurateTotal [Boolean] Optional Defaults to
false
Available since 1.24.0 -
Set this value equal to
true
to receive an accurate hit count on the API response.By default the search engine will limit the hit count to 10,000 users. This means that even if your query may match more than 10,000 users, the returned total count will be 10,000. This is adequate for many use cases such as pagination and general purpose queries. If you are looking for an accurate user count that can exceed 10,000 matches, you will want to set this value equal to
true
. - search.ids [UUID] Optional
-
A User Id to retrieve. By specifying this URL parameter multiple times you can lookup multiple Users. Using this parameter is mutually exclusive with the query and queryString fields and is not paginated or sorted using sortFields field.
Using this parameter will not hit the Elasticsearch index, instead it will cause users to be retrieved by Id only.
- search.numberOfResults [Integer] Optional defaults to
25
-
The number of search results to return. Used for pagination.
- search.query [String] Optional Available since 1.13.0
-
The raw JSON Elasticsearch query that is used to search for Users. The ids, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
It is necessary to use the search.query parameter when querying against
registrations
in order to achieve expected results, as this field is defined as a nested datatype in the Elasticsearch mapping. - search.queryString [String] Optional
-
The Elasticsearch query string that is used to search for Users. The ids, query, and queryString parameters are mutually exclusive, they are listed here in order of precedence.
The match is case-insensitive. Whitespace is allowed in the search, but must be URL escaped; for example, using
%20
for a space character. Elasticsearch compatible regular expressions may be used, so you may search by prefix or suffix using the*
wildcard.You may search against specific fields like so:
email:*fusionauth.io
. This will match only users with afusionauth.io
email address. You may find the available fields for matching by retrieving the Elasticsearch mapping. - search.startRow [Integer] Optional defaults to 0
-
The start row within the search results to return. Used for pagination.
- search.sortFields [Array] Optional
-
An array of sort fields used to sort the result. The order the sort fields are provided will be maintained in the sorted output.
- search.sortFields[
x
].missing [String] Optional defaults to_last
-
The value to substitute if this field is not defined. Two special values may be used:
-
_first
When the field is not defined sort this record first. -
_last
When the field is not defined sort this record last.
-
- search.sortFields[
x
].name [String] Optional -
The name of the field to sort.
Required if sortFields is provided.
Due to how the search index is structured not all fields on the user are sortable. The following field names are currently supported.
-
birthDate
-
email
-
fullName
-
id
Available since 1.13.0 -
insertInstant
-
lastLoginInstant
Available since 1.13.0 -
login
-
registrations.applicationId
Available since 1.13.0 -
registrations.id
Available since 1.13.0 -
registrations.insertInstant
Available since 1.13.0 -
registrations.lastLoginInstant
Available since 1.13.0 -
registrations.roles
Available since 1.13.0 -
tenantId
-
username
-
- search.sortFields
[x]
.order [String] Optional defaults toasc
-
The order to sort the specified field. Possible values are:
-
asc
-
desc
-
Request Body Examples
{
"search": {
"ids": [
"a6e3ed2d-582b-4ec3-aa3f-4323c8f39fe9",
"00000000-0000-0001-0000-000000000000"
]
}
}
query
parameter to search for users with unverified registrations to a specific application
{
"bool": {
"must": [
{
"nested": {
"path": "registrations",
"query": {
"bool": {
"must": [
{
"match": {
"registrations.applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32"
}
},
{
"match": {
"registrations.verified": false
}
}
]
}
}
}
}
]
}
}
{
"search": {
"numberOfResults": 25,
"query": "{\"bool\":{\"must\":[{\"nested\":{\"path\":\"registrations\",\"query\":{\"bool\":{\"must\":[{\"match\":{\"registrations.applicationId\":\"3c219e58-ed0e-4b18-ad48-f4f92793ae32\"}},{\"match\":{\"registrations.verified\":false}}]}}}}]}}",
"sortFields": [
{
"missing": "_first",
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
query
parameter to search for users with a specific role
{
"bool": {
"must": [
[
{
"nested": {
"path": "registrations",
"query": {
"bool": {
"must": [
{
"match": {
"registrations.applicationId": "c50329fa-93e5-4618-8d9f-73d0ab069a54"
}
},
{
"match": {
"registrations.roles": "admin"
}
}
]
}
}
}
}
]
]
}
}
query
for users with with a specific role
{
"search": {
"numberOfResults": 25,
"query": "{\"bool\":{\"must\":[[{\"nested\":{\"path\":\"registrations\",\"query\":{\"bool\":{\"must\":[{\"match\":{\"registrations.applicationId\":\"c50329fa-93e5-4618-8d9f-73d0ab069a54\"}},{\"match\":{\"registrations.roles\":\"admin\"}}]}}}}]]}}",
"sortFields": [
{
"missing": "_first",
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
query
for users with a given email address
{
"search": {
"numberOfResults": 25,
"query": "{\"match\":{\"email\":{\"query\":\"dinesh@fusionauth.io\"}}}",
"sortFields": [
{
"missing": "_first",
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
query
for users with custom user data of dataMigrated equal to true
{
"search": {
"numberOfResults": 25,
"query": "{\"match\":{\"data.userMigrated\":{\"query\":\"true\"}}}",
"sortFields": [
{
"missing": "_first",
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
query
parameter to search for users with a price range in their registration data
{
"bool": {
"must": [
{
"nested": {
"path": "registrations",
"query": {
"range": {
"registrations.data.minprice": {
"gte": 50000,
"lte": 100000
}
}
}
}
}
]
}
}
query
parameter to search for users with any value for userMigrated
{
"constant_score": {
"filter": {
"exists": {
"field": "data.userMigrated"
}
}
}
}
{
"search": {
"numberOfResults": 25,
"queryString": "email:*@fusionauth.io",
"sortFields": [
{
"missing": "_first",
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
{
"search": {
"numberOfResults": 25,
"queryString": "memberships.groupId:7f318a9d-3de4-4ded-9b53-1d97fd730868",
"sortFields": [
{
"missing": "_first",
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
queryString
for users of a specific tenant. A global API key must be used, and you may not use the X-FusionAuth-TenantId
header when the search parameters include tenantId
{
"search": {
"numberOfResults": 25,
"queryString": "tenantId:39666465-6535-3731-3139-666363356438",
"sortFields": [
{
"missing": "_first",
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
Response
The response contains the User objects that were found as part of the lookup or search. Both the database and Elasticsearch search engines return the response in the same format.
Code | Description |
---|---|
200 |
The request was successful. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 |
The object you requested doesn’t exist. The response will be empty. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
- total [Long]
-
The number of users that matched the search criteria. The number of results in the response will be equal to the
numberOfResults
provided on the request, if not provided the default number of results will be returned.This value may cap out at 10,000 even if more users are found based upon the provided search query. Use the
accurateTotal
request parameter if you require this value to represent the actual number of matching users in the search index when your query may match more than 10,000 users. - users [Array]
-
The list of Users.
- users
[x]
.active [Boolean] -
True if the User is active. False if the User has been deactivated. Deactivated Users will not be able to login.
- users
[x]
.breachedPasswordLastCheckedInstant [Long] -
The instant this user’s password was last checked to determine if is compromised.
- users
[x]
.birthDate [String] -
YYYY-MM-DD formatted date of the User’s birth.
- users
[x]
.cleanSpeakId [UUID] -
This Id is used by FusionAuth when the User’s username is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- users
[x]
.connectorId [UUID] Available since 1.18.0 -
The unique Id of the Connector associated with the System of Record being used to authenticate the user.
- users
[x]
.data [Object] -
An object that can hold any information about the User that should be persisted.
- users
[x]
.email [String] -
The User’s email address.
- users
[x]
.encryptionScheme [String] Available since 1.20.1 -
The encryption scheme used to hash the password for this user. This value is only returned when the user is retrieved using an API key.
- users
[x]
.expiry [Long] -
The expiration instant of the User’s account. After this instant is reached, the User’s account will automatically be deactivated.
- users
[x]
.firstName [String] -
The first name of the User.
- users
[x]
.fullName [String] -
The User’s full name as a separate field that is not calculated from firstName and lastName.
- users
[x]
.id [UUID] -
The User’s unique Id.
- users
[x]
.imageUrl [String] -
The URL that points to an image file that is the User’s profile image.
- users
[x]
.insertInstant [Long] -
The instant when the User was created.
- users
[x]
.lastLoginInstant [Long] -
The instant when the User logged in last.
- users
[x]
.lastName [String] -
The User’s last name.
- users
[x]
.lastUpdateInstant [Long] -
The last instant when the User was updated. Note: webhooks may be another effective way to track user changes.
- users
[x]
.memberships [Array] -
The list of memberships for the User.
- users
[x]
.memberships[x]
.data [Object] -
An object that can hold any information about the User for this membership that should be persisted.
- users
[x]
.memberships[x]
.groupId [UUID] -
The Id of the Group of this membership.
- users
[x]
.memberships[x]
.id [UUID] -
The unique Id of this membership.
- users
[x]
.memberships[x]
.insertInstant [Long] -
The instant that the membership was created.
- users
[x]
.middleName [String] -
The User’s middle name.
- users
[x]
.mobilePhone [String] -
The User’s mobile phone number. This is useful is you will be sending push notifications or SMS messages to the User.
- users
[x]
.passwordChangeRequired [Boolean] -
Indicates that the User’s password needs to be changed during their next login attempt.
- users
[x]
.passwordLastUpdateInstant [Long] -
The instant that the User last changed their password.
- users
[x]
.preferredLanguages [Array<String>] -
An array of locale strings that give, in order, the User’s preferred languages. These are important for email templates and other localizable text. See Locales.
- users
[x]
.registrations [Array] -
The list of registrations for the User.
- users
[x]
.registrations[x]
.applicationId [UUID] -
The Id of the Application that this registration is for.
- users
[x]
.registrations[x]
.authenticationToken [String] -
The Authentication Token for this registration (if one exists).
- users
[x]
.registrations[x]
.cleanSpeakId [UUID] -
This Id is used by FusionAuth when the User’s username for this registration is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
- users
[x]
.registrations[x]
.data [Object] -
An object that can hold any information about the User for this registration that should be persisted.
- users
[x]
.registrations[x]
.id [UUID] -
The Id of this registration.
- users
[x]
.registrations[x]
.insertInstant [Long] -
The instant that this registration was created.
- users
[x]
.registrations[x]
.lastLoginInstant [Long] -
The instant that the User last logged into the Application for this registration.
- users
[x]
.registrations[x]
.preferredLanguages [Array<String>] -
An array of locale strings that give, in order, the User’s preferred languages for this registration. These are important for email templates and other localizable text. See Locales.
- users
[x]
.registrations[x]
.roles [Array<String>] -
The list of roles that the User has for this registration.
- users
[x]
.registrations[x]
.timezone [String] -
The User’s preferred timezone for this registration. The string will be in an IANA time zone format.
- users
[x]
.registrations[x]
.tokens [Map<String,String>] Deprecated -
A map that contains tokens returned from identity providers.
For example, if this user has authenticated using the Facebook Identity Provider, the Facebook access token will be available in this map, keyed by name
Facebook
. For an OpenID Connect Identity provider, or other generic providers, if a token is stored it will be keyed by the Identity Provider unique Id.Removed in 1.28.0
The token returned and stored from the Identity Provider is now stored in the IdP link and is retrievable using the Identity Provider Link API.
- users
[x]
.registrations[x]
.username [String] -
The username of the User for this registration only. This is for display purposes and cannot be used to login.
- users
[x]
.registrations[x]
.usernameStatus [String] -
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- users
[x]
.registrations[x]
.verified [Boolean] -
This value indicates if this User’s registration has been verified.
- users
[x]
.tenantId [UUID] -
The Id of the Tenant that this User belongs to.
- users
[x]
.timezone [String] -
The User’s preferred timezone. This can be used as a default to display instants, and it is recommended that you allow User’s to change this per-session. The string will be in an IANA time zone format.
- users
[x]
.twoFactor.methods[x]
.authenticator.algorithm [String] -
The algorithm used by the TOTP authenticator. With the current implementation, this will always be
HmacSHA1
. - users
[x]
.twoFactor.methods[x]
.authenticator.codeLength [Integer] -
The length of code generated by the TOTP. With the current implementation, this will always be
6
. - users
[x]
.twoFactor.methods[x]
.authenticator.timeStep [Integer] -
The time-step size in seconds. With the current implementation, this will always be 30.
- users
[x]
.twoFactor.methods[x]
.email [String] -
The value of the email address for this method. Only present if user.twoFactor.methods
[x]
.method isemail
. - users
[x]
.twoFactor.methods[x]
.id [String] -
The unique Id of the method.
- users
[x]
.twoFactor.methods[x]
.lastUsed [Boolean] -
true
if this method was used most recently. - users
[x]
.twoFactor.methods[x]
.method [String] -
The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
-
authenticator
-
email
-
sms
-
- users
[x]
.twoFactor.methods[x]
.mobilePhone [String] -
The value of the mobile phone for this method. Only present if user.twoFactor.methods
[x]
.method issms
. - users
[x]
.twoFactor.methods[x]
.secret [String] -
A base64 encoded secret
This field is required when method is
authenticator
. - users
[x]
.twoFactorDelivery [String] Deprecated -
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
Removed in version 1.26.0
-
- users
[x]
.twoFactorEnabled [Boolean] Deprecated -
Determines if the User has two factor authentication enabled for their account or not.
Removed in version 1.26.0
- users
[x]
.username [String] -
The username of the User.
- users
[x]
.usernameStatus [String] -
The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
-
ACTIVE
- the username is active -
PENDING
- the username is pending approval/moderation -
REJECTED
- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
-
- users
[x]
.verified [Boolean] -
Whether or not the User’s email has been verified.
{
"total": 1,
"users": [
{
"active": true,
"birthDate": "1976-05-30",
"breachedPasswordLastCheckedInstant": 1471786483322,
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"expiry": 1571786483322,
"firstName": "John",
"fullName": "John Doe",
"id": "00000000-0000-0001-0000-000000000000",
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"lastLoginInstant": 1471786483322,
"lastName": "Doe",
"memberships": [
{
"data": {
"externalId": "cc6714c6-286c-411c-a6bc-ee413cda1dbc"
},
"groupId": "2cb5c83f-53ff-4d16-88bd-c5e3802111a5",
"id": "27218714-305e-4408-bac0-23e7e1ddceb6",
"insertInstant": 1471786482322
}
],
"middleName": "William",
"mobilePhone": "303-555-1234",
"passwordChangeRequired": false,
"passwordLastUpdateInstant": 1471786483322,
"preferredLanguages": [
"en",
"fr"
],
"registrations": [
{
"applicationId": "10000000-0000-0002-0000-000000000001",
"data": {
"displayName": "Johnny",
"favoriteSports": [
"Football",
"Basketball"
]
},
"id": "00000000-0000-0002-0000-000000000000",
"insertInstant": 1446064706250,
"lastLoginInstant": 1456064601291,
"preferredLanguages": [
"en",
"fr"
],
"roles": [
"user",
"community_helper"
],
"username": "johnny123",
"usernameStatus": "ACTIVE",
"verified": true
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactor": {
"methods": [
{
"authenticator": {
"algorithm": "HmacSHA1",
"codeLength": 6,
"timeStep": 30
},
"id": "35VW",
"method": "authenticator"
},
{
"id": "V7SH",
"method": "sms",
"mobilePhone": "555-555-5555"
},
{
"email": "example@fusionauth.io",
"id": "7K2G",
"method": "email"
}
]
},
"usernameStatus": "ACTIVE",
"username": "johnny123",
"verified": true
}
]
}
Flush the Search Engine
This API is used to issue a flush request to the FusionAuth Search. This will cause any cached data to be written to disk. In practice it is unlikely you’ll find a need for this API in production unless you are performing search requests immediately following an operation that modifies the index and expecting to see the results immediately.
Request
PUT /api/user/search
Response
The response does not contain a body. It only contains one of the status codes below.
Code | Description |
---|---|
200 |
The request was successful. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Retrieve Recent Logins
Available Since Version 1.4.0
This API is used to retrieve recent logins.
Request
GET /api/user/recent-login?limit={limit}&offset={offset}&userId={userId}
Request Parameters
- limit [Integer] Optional defaults to
10
-
This parameter indicates the maximum amount of logins to return for a single request.
- offset [Integer] Optional defaults to
0
-
This parameter provides the offset into the result set. Generally speaking if you wish to paginate the results, you will increment this parameter on subsequent API request by the size of the
limit
parameter. - userId [UUID] Optional
-
This parameter will narrow the results to only logins for a particular user. When this parameter is omitted, the most recent logins for all of FusionAuth will be returned.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Response
The response will contain recent logins containing no more than the value set by the limit
parameter. By design, this API does not return the total number of results and only lets paginate through the results from newest to oldest.
Code | Description |
---|---|
200 |
The request was successful. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 |
The object you requested doesn’t exist. The response will be empty. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
- logins [Array]
-
A list of recent logins.
- logins
[x]
.applicationId [UUID] -
The unique Id of the application that is represented by this login record.
- logins
[x]
.applicationName [String] -
The name of the application at the time this record was created.
- logins
[x]
.instant [Long] -
The instant this login occurred.
- logins
[x]
.ipAddress [String] -
The IP address if provided during the login request.
- logins
[x]
.location.city [String] Available since 1.30.0 -
The city where the login request originated.
Note: A paid plan is required to utilize login location.
- logins
[x]
.location.country [String] Available since 1.30.0 -
The country where the login request originated.
Note: A paid plan is required to utilize login location.
- logins
[x]
.location.latitude [Double] Available since 1.30.0 -
The latitude where the login request originated.
Note: A paid plan is required to utilize login location.
- logins
[x]
.location.longitude [Double] Available since 1.30.0 -
The longitude where the login request originated.
Note: A paid plan is required to utilize login location.
- logins
[x]
.location.region [String] Available since 1.30.0 -
The geographic location where the login request originated.
Note: A paid plan is required to utilize login location.
- logins
[x]
.location.zipcode [String] Available since 1.30.0 -
The zipcode where the login request originated.
Note: A paid plan is required to utilize login location.
- logins
[x]
.loginId [String] -
The User’s email address or username at the time of the login request.
- logins
[x]
.userId [UUID] -
The unique Id of the user that is represented by this login record.
{
"logins": [
{
"applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32",
"applicationName": "PiedPiper",
"instant": 1549493410058,
"ipAddress": "42.42.42.42",
"location": {
"city": "Seattle",
"country": "US",
"latitude": 47.60621,
"longitude": -122.33207,
"region": "WA"
},
"loginId": "jared@piedpiper.com",
"userId": "4469bea7-8b10-4ad3-94f2-bc8df962b489"
},
{
"applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32",
"applicationName": "Acme Corp.",
"instant": 1549485962036,
"ipAddress": "42.42.42.42",
"location": {
"city": "Denver",
"country": "US",
"latitude": 39.73913,
"longitude": -104.9845,
"region": "CO"
},
"loginId": "admin@acme.com",
"userId": "4469bea7-8b10-4ad3-94f2-bc8df962b489"
},
{
"applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32",
"applicationName": "Support Portal",
"instant": 1549387234024,
"ipAddress": "42.42.42.42",
"location": {
"city": "Dhaka",
"country": "BD",
"latitude": 23.7104,
"longitude": 90.40744,
"region": "81"
},
"loginId": "bob@gmail.com",
"userId": "6a802b03-17e3-404f-830f-ea5c30ca50df"
}
]
}
Verify a User’s Email
This API is used to mark a User’s email as verified. This is usually called after the User receives the verification email after they register and they click the link in the email.
Request
Verifies the User’s email address using the verificationId
.
POST /api/user/verify-email
POST /api/user/verify-email/{verificationId}
Request Parameters
- verificationId [String] Required Deprecated
-
The verification Id generated by FusionAuth used to verify the User’s registration is valid by ensuring they have access to the provided email address.
Deprecated in version 1.27.0 This value can still be provided on the URL segment as shown in the above example, but it is recommended you send this value in the request body instead using the verificationId field. If the value is provided in the URL segment and in the request body, the value provided in the request body will be preferred.
Request Body
- oneTimeCode [String] Optional Available since 1.27.0
-
The short code used to verify the User’s account is valid by ensuring they have access to the provided email address. This field is required when the email verification strategy on the Tenant is set to
Form field
. - verificationId [String] Required Available since 1.27.0
-
The verification Id generated by FusionAuth used to verify the User’s account is valid by ensuring they have access to the provided email address.
When using the
Form field
strategy for Email verification, this value is used along with theoneTimeCode
as a pair to verify the email address.If the verificationId is provided in the URL segment and in the request body, the value provided in the request body will be preferred.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Administratively verify the User’s email address.
Available since version 1.37.0
This API can be used to mark a user as verified without requiring the user to actually complete a verification process.
POST /api/user/verify-email
Request Body
- userId [String] Required
-
The unique Id of the user to mark verified.
Response
The response does not contain a body. It only contains one of the status codes below.
Code | Description |
---|---|
200 |
The request was successful. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 |
The object you are trying to update doesn’t exist. The response will be empty. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Resend Verification Email
This API is used to resend the verification email to a User. This API is useful if the User has deleted the email, or the verification Id has expired. By default, the verification Id will expire after 24 hours. You can modify this duration in the Tenant settings.
Request
PUT /api/user/verify-email?applicationId={applicationId}&email={email}
Request Parameters
- applicationId [String] Optional Available since 1.21.0
-
The Id of the application. If valid, the email template configured in the Application settings will be used, if present. If not present, the email template configured in the Tenant settings will be used. In either case, the corresponding Application object will be available to the template.
- email [String] Required
-
The email address used to uniquely identify the User.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request because the input parameters by themselves do not indicate which tenant the request is intended.
The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Resend the verification email using an API key
PUT /api/user/verify-email?applicationId={applicationId}&email={email}&sendVerifyEmail={sendVerifyEmail}
Request Parameters
- applicationId [String] Optional Available since 1.21.0
-
The Id of the application. If valid, the email template configured in the Application settings will be used, if present. If not present, the email template configured in the Tenant settings will be used. In either case, the corresponding Application object will be available to the template.
- email [String] Required
-
The email address used to uniquely identify the User.
- sendVerifyEmail [Boolean] Optional defaults to
true
-
If you would only like to generate a new verificationId and return it in the JSON body without FusionAuth attempting to send the User an email set this optional parameter to
false
.This may be useful if you need to integrate the Email Verification process using a third party messaging service.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request because the input parameters by themselves do not indicate which tenant the request is intended.
The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Response
When authenticated using an API key a response body will be provided. If an API key was not used to authenticate the request no body is returned.
Code | Description |
---|---|
200 |
The request was successful. The response will contain a JSON body if an API key was used for authentication. If no API key was provided no response body will be returned. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
403 |
The verify email functionality has been disabled. FusionAuth is unable to send Email Verification emails. |
404 |
The object you are trying to update doesn’t exist. The response will be empty. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
- verificationId [String]
-
The email verification Id that was generated by this API request. This identifier may be used by the Verify a User’s Email API. This field is only returned in the JSON response body if the request was authenticated using an API key, if an API key is not used no response body is returned.
- verificationOneTimeCode [String]
-
Depending on your tenant configuration, this may be returned. The verification One Time Code is used with the gated Email Verification workflow. The user enters this code to verify their email.
Note: A paid plan is required to utilize gated email.
{
"verificationId": "YkQY5Gsyo4RlfmDciBGRmvfj3RmatUqrbjoIZ19fmw4",
"verificationOneTimeCode": "JJ6RTS"
}
Start Forgot Password Workflow
This API is used to start the forgot password workflow for a single User.
For example, on your login form you may have a button for Forgot your password. This would be the API you would call to initiate the request for the user. If the email configuration is complete, the user will be sent the forgot password email containing a link containing the changePasswordId
. The provided link should take the user to a form that allows them to change their password. This form should contain a hidden field for the changePasswordId
generated by this API.
By default the changePasswordId
is valid to be used with the Change Password API for 10 minutes. If a 404
is returned when using this Id to change the password, the workflow
will need to be started again to generate a new identifier. This duration can be modified using the Tenant API or in the FusionAuth UI.
You may optionally authenticate this request with an API key to allow for some additional request parameters and the generated changePasswordId
will be returned in the JSON body. This may be helpful if you wish to use your own email system or you have an alternative method to call the Change Password API.
If FusionAuth sends an email to the user, it will either use the email
top level property on the user or it will use a custom data attribute named email
as well (i.e. data.email
). This allows you to have a user that has no email address for login or allow distinct users to share email addresses.
Request
Start the forgot password workflow without an API Key.
POST /api/user/forgot-password
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request because the input parameters by themselves do not indicate which tenant the request is intended.
The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- applicationId [UUID] Optional Available since 1.21.0
-
The Id of the application. If valid, the email template configured in the Application settings will be used, if present. If not present, the email template configured in the Tenant settings will be used. In either case, the corresponding Application object will be available to the template.
- loginId [String] Required
-
The login identifier of the user. The login identifier can be either the
email
or theusername
. The username is not case sensitive. - state [Object] Optional
-
An optional object that will be returned un-modified when you complete the forgot password request. This may be useful to return the user to particular state once they complete the password change.
{
"applicationId": "8174f72f-5ecd-4eae-8de8-7fef597b3473",
"loginId": "example@fusionauth.io"
}
Start the forgot password workflow using an API key
POST /api/user/forgot-password
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request because the input parameters by themselves do not indicate which tenant the request is intended.
The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- applicationId [UUID] Optional Available since 1.21.0
-
The Id of the application. If valid, the email template configured in the Application settings will be used, if present. If not present, the email template configured in the Tenant settings will be used. In either case, the corresponding Application object will be available to the template.
- changePasswordId [String] Optional
-
The optional change password Id to be used on the Change a User’s Password API.
It is recommended to omit this parameter and allow FusionAuth to generate the identifier. Use this parameter only if you must supply your own value for integration into existing systems.
- loginId [String] Required
-
The login identifier of the user. The login identifier can be either the
email
or theusername
. The username is not case sensitive. - sendForgotPasswordEmail [Boolean] Optional defaults to
true
-
Whether or not calling this API should attempt to send the user an email using the configured Forgot Password email template. Setting this to
false
will begin the Forgot Password workflow without sending an email and only create thechangePasswordId
, this may be useful if you want to send an email outside of FusionAuth, or complete this workflow without the use of email.Since 1.43.0 Beginning in version
1.43.0
, when setting this tofalse
you will not be required to have configured the Forgot Password email template in the FusionAuth tenant. Prior to this version, even when setting this tofalse
the Tenant would be required to have configured the Forgot Password email template. - state [Object] Optional
-
An optional object that will be returned un-modified when you complete the forgot password request. This may be useful to return the user to particular state once they complete the password change.
{
"applicationId": "8174f72f-5ecd-4eae-8de8-7fef597b3473",
"changePasswordId": "YkQY5Gsyo4RlfmDciBGRmvfj3RmatUqrbjoIZ19fmw4",
"loginId": "example@fusionauth.io",
"sendForgotPasswordEmail": false,
"state": {
"lastPage": "/foo/baz"
}
}
Response
Code | Description |
---|---|
200 |
The request was successful. A JSON response body will be provided when authenticated using an API key, when the API key has been omitted from the request, no response body is provided. |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
403 |
The forgot password functionality has been disabled. This is caused by an administrator setting the Forgot Password Email Template to the option Feature Disabled. No template selected. in the Tenant Email configuration. See in the FusionAuth admin UI. |
404 |
The User could not be found. |
422 |
The User does not have an email address, this request cannot be completed. Before attempting the request again add an email address to the user. |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
- changePasswordId [String]
-
The change password Id that was generated by this API request. This identifier may be used by the Change Password API. This field is only returned in the JSON response body if the request was authenticated using an API key, if an API key is not used no response body is returned.
{
"changePasswordId": "YkQY5Gsyo4RlfmDciBGRmvfj3RmatUqrbjoIZ19fmw4"
}
Change a User’s Password
This API is used to change the User’s password.
This API may be used as the second part of the Forgot Password workflow. For example, after the User is sent an email that contains a link to a web form that allows them to update their password you will call this API with the changePasswordId
and their updated password. If the changePasswordId
is valid then the User’s password will be updated.
This API may also be used separately from the Forgot Password workflow by omitting the changePasswordId
and using the loginId
instead.
By default the changePasswordId
is valid for 10 minutes after it was generated. If a 404
is returned when using the change password Id, the workflow will need to be started again to generate a new identifier. This duration can be modified using the System Configuration API or in the FusionAuth UI.
When this API successfully completes, all refresh tokens and outstanding Change Password Ids (i.e. changePasswordId
) currently assigned to the user will be expired or revoked. This means
that if a user is using a refresh token they will be forced to re-authenticate with their new password.
Request
Changes a User’s password using the change password Id.
This usage is generally intended to be part of an email workflow and does not require authentication. The changePasswordId
used on this API request will have been previously generated by the Start Forgot Password API or by using the Forgot Password workflow on the FusionAuth login page.
POST /api/user/change-password
POST /api/user/change-password/{changePasswordId}
Request Parameters
- changePasswordId [String] Required Deprecated
-
The
changePasswordId
that is used to identity the user after the Start Forgot Password workflow has been initiated.If this
changePasswordId
was sent via an email to the User by FusionAuth during User create in order to set up a new password, or as part of a Forgot Password request, then successful use of this identifier to change the User’s password will implicitly complete Email Verification if not already verified and the Tenant configuration has enabled implicit email verification.Deprecated in version 1.33.0 This value can still be provided on the URL segment as shown in the above example, but it is recommended you send this value in the request body instead using the changePasswordId field. If the value is provided in the URL segment and in the request body, the value provided in the request body will be preferred.
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- changePasswordId [String] Required Available since 1.33.0
-
The
changePasswordId
that is used to identity the user after the Start Forgot Password workflow has been initiated.If this
changePasswordId
was sent via an email to the User by FusionAuth during User create in order to set up a new password, or as part of a Forgot Password request, then successful use of this identifier to change the User’s password will implicitly complete Email Verification if not already verified and the Tenant configuration has enabled implicit email verification.If the changePasswordId is provided in the URL segment and in the request body, the value provided in the request body will be preferred.
- currentPassword [String] Optional
-
The User’s current password. When this parameter is provided the current password will be verified to be correct.
- password [String] Required
-
The User’s new password.
- trustChallenge [String] Optional Available since 1.33.0
-
This field is marked optional because it is only required when the user has enabled two-factor authentication, and a
trustChallenge
was provided on the Two-Factor Start API request. When a user has enabled two-factor authentication this field becomes required if atrustChallenge
was provided on the Two-Factor Start API request. When required, this value must be equal to the value provided to the Two-Factor Start API. - trustToken [String] Optional Available since 1.33.0
-
This field is marked optional, because it is only required when the user has enabled two-factor authentication. When a user has enabled two-factor authentication this field becomes required when attempting to change a password using the
changePasswordId
.
{
"currentPassword": "too many secrets",
"password": "Setec Astronomy"
}
Changes a User’s password using an email address or username.
This usage requires and API key and allows you to change any user’s password if you have a unique email or username.
POST /api/user/change-password
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
When only a single tenant is configured the tenant Id can be assumed and this additional header is optional. Once more than one tenant has been configured in FusionAuth the tenant Id is required for this request because the input parameters by themselves do not indicate which tenant the request is intended.
The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- applicationId [UUID] Optional Available since 1.30.0
-
An optional Application Id. When this value is provided, it will be used to resolve an application specific email template if you have configured transactional emails such as setup password, email verification and others.
If not provided, only the tenant configuration will be used when resolving email templates.
- currentPassword [String] Optional
-
The User’s current password. When this parameter is provided the current password will be verified to be correct.
- loginId [String] Required
-
The login identifier of the user. The login identifier can be either the
email
or theusername
. The username is not case sensitive.When this value is provided it should be in place of the
changePasswordId
request parameter. If both thechangePasswordId
andloginId
are provided on the request, thechangePasswordId
will take precedence. - password [String] Required
-
The User’s new password.
- trustChallenge [String] Optional Available since 1.33.0
-
This field is marked optional because it is only required when the user has enabled two-factor authentication, and a
trustChallenge
was provided on the Two-Factor Start API request. When a user has enabled two-factor authentication this field becomes required if atrustChallenge
was provided on the Two-Factor Start API request. When required, this value must be equal to the value provided to the Two-Factor Start API. - trustToken [String] Optional Available since 1.33.0
-
This field is marked optional, because it is only required when the user has enabled two-factor authentication. When a user has enabled two-factor authentication this field becomes required when attempting to change a password using the
changePasswordId
.
{
"applicationId": "18cec3c9-003b-433f-8412-6e31afca5bcf",
"currentPassword": "too many secrets",
"loginId": "cosmo@playtronics.com",
"password": "Setec Astronomy"
}
Changes a User’s password using a JWT
Available Since Version 1.5.0
This API will use a JWT as authentication. See JWT Authentication for examples of how you can send the JWT to FusionAuth.
A common use case for using this API with a JWT will be if you want to allow the user to change their own password. Specifically if you are attempting to perform this request in a frontend browser that cannot store an API key.
Because changing a User’s password will revoke all existing refresh tokens if you allow the user to change their password they will need to re-authenticate to stay logged into your application if you are utilizing JWTs and Refresh Tokens.
For this reason, this API will return a oneTimePassword
that is intended to be used programatically after a Change Password request completes to keep the user logged in and provide a better user experience. A successful login will return you a new access token (JWT) and a refresh token. This will allow you to make the change password workflow seamless to the user.
POST /api/user/change-password
Request Headers
- X-FusionAuth-TenantId [String] Optional
-
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
- currentPassword [String] Required
-
The User’s current password. This is required when using a JWT to change your password.
- password [String] Required
-
The User’s new password.
- refreshToken [String] Optional
-
The user’s existing refresh token. If you have access to your current refresh token, it can be provided in the request body using this parameter. If the
refresh_token
cookie also exists and is present on the request it will take precedence over this parameter.This parameter is used to determine if the
oneTimePassword
that is returned from this API will be eligible to request a refresh token when used by the Login API. If this parameter is not provided and no cookie is found on the request, a refresh token will not be provided on the Login response when using the returnedoneTimePassword
. - trustChallenge [String] Optional Available since 1.33.0
-
This field is marked optional because it is only required when the user has enabled two-factor authentication, and a
trustChallenge
was provided on the Two-Factor Start API request. When a user has enabled two-factor authentication this field becomes required if atrustChallenge
was provided on the Two-Factor Start API request. When required, this value must be equal to the value provided to the Two-Factor Start API. - trustToken [String] Optional Available since 1.33.0
-
This field is marked optional, because it is only required when the user has enabled two-factor authentication. When a user has enabled two-factor authentication this field becomes required when attempting to change a password using the
changePasswordId
.
{
"currentPassword": "too many secrets",
"password": "Setec Astronomy"
}
Response
Code | Description |
---|---|
200 |
The request was successful. Starting in version |
400 |
The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors.
Beginning in version Example Response JSON
To complete this request you must obtain a
Beginning in version |
401 |
You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 |
The User could not be found using the |
500 |
There was an internal error. A stack trace is provided and logged in the FusionAuth log files. |
503 |
The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
- oneTimePassword [String] Available since 1.5.0
-
A one time password that can be used as a substitute for your
loginId
andpassword
on the Login API.This JSON response body will only be returned when using a
changePasswordId
or JWT to change the password. When calling this API with an API key no response body will be returned.
{
"oneTimePassword": "YQNfvoDJy4_0As9iLTk9hpjF5z_C3VWVyBy95vFZr0M"
}
Feedback
How helpful was this page?
See a problem?
File an issue in our docs repo
Have a question or comment to share?
Visit the FusionAuth community forum.