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
- sendSetPasswordEmail [Boolean] Optional defaults to
false
-
Indicates to FusionAuth to send the User an email asking them to set their password. The Email Template that is used is configured in the System Configuration setting for Set Password Email Template.
If you set this value to
true
thepassword
field is then ignored, FusionAuth will set the initial password to a securely generated random string.If you have also enabled email verification and do not select to skip verification using 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 implicitly 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.
- 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.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:
You can also create your own password encryptor. See the Password Encryptors 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 texts 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
- users.twoFactorDelivery [String] Optional defaults to
None
-
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
. -
- user.twoFactorEnabled [Boolean] Optional defaults to
false
-
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.
- user.twoFactorSecret [String] Optional
-
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. - 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.
-
{
"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",
"twoFactorEnabled": false,
"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).
- 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.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.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 user was created.
- user.lastLoginInstant [Long]
-
The instant when the User logged in last.
- user.lastName [String]
-
The User’s last name.
- user.middleName [String]
-
The User’s middle name.
- user.mobilePhone [String]
-
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] 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 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.
- 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>] Available since 1.1.0 -
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. - user.registrations
[x]
.username [String] -
The username of the User for this registration only.
- 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.
- 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 User’s to change this per-session. The string will be in an IANA time zone format.
- user.twoFactorDelivery [String]
-
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
-
- user.twoFactorEnabled [Boolean]
-
Determines if the User has two factor authentication enabled for their account or not.
- 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.
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImMxVU5ON0pIUVc4X21ROHBTaWZKbzBXekdybDlTbTRnIn0.eyJleHAiOjE1ODY4ODQzNzksImlhdCI6MTU4Njg4NDMxOSwiaXNzIjoiZnVzaW9uYXV0aC5pbyIsInN1YiI6IjAwMDAwMDAwLTAwMDAtMDAwMS0wMDAwLTAwMDAwMDAwMDAwMCIsImF1dGhlbnRpY2F0aW9uVHlwZSI6IlVTRVJfQ1JFQVRFIiwiZW1haWwiOiJ0ZXN0MEBmdXNpb25hdXRoLmlvIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInByZWZlcnJlZF91c2VybmFtZSI6InVzZXJuYW1lMCJ9.Z1jV8xDcayZZDBdLRVd2fIyowhstRI4Dgk7_u2XFerc",
"user": {
"active": true,
"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",
"tokens": {
"Facebook": "nQbbBIzDhMXXfa7iDUoonz5zS",
"19544aa2-d634-4859-b193-e57af82b5d12": "eu1SsrjsiDf3h3LryUjxHIKTS0yyrbiPcsKF3HDp"
},
"username": "johnny123",
"usernameStatus": "ACTIVE"
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactorEnabled": false,
"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
- token [String] Available since 1.16.0
-
The access token, this string is an encoded JSON Web Token (JWT).
- 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.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.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 user was created.
- user.lastLoginInstant [Long]
-
The instant when the User logged in last.
- user.lastName [String]
-
The User’s last name.
- 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 is 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 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.
- 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>] Available since 1.1.0 -
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. - user.registrations
[x]
.username [String] -
The username of the User for this registration only.
- 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.
- 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 User’s to change this per-session. The string will be in an IANA time zone format.
- user.twoFactorDelivery [String]
-
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
-
- user.twoFactorEnabled [Boolean]
-
Determines if the User has two factor authentication enabled for their account or not.
- 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.
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImMxVU5ON0pIUVc4X21ROHBTaWZKbzBXekdybDlTbTRnIn0.eyJleHAiOjE1ODY4ODQzNzksImlhdCI6MTU4Njg4NDMxOSwiaXNzIjoiZnVzaW9uYXV0aC5pbyIsInN1YiI6IjAwMDAwMDAwLTAwMDAtMDAwMS0wMDAwLTAwMDAwMDAwMDAwMCIsImF1dGhlbnRpY2F0aW9uVHlwZSI6IlVTRVJfQ1JFQVRFIiwiZW1haWwiOiJ0ZXN0MEBmdXNpb25hdXRoLmlvIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInByZWZlcnJlZF91c2VybmFtZSI6InVzZXJuYW1lMCJ9.Z1jV8xDcayZZDBdLRVd2fIyowhstRI4Dgk7_u2XFerc",
"user": {
"active": true,
"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",
"tokens": {
"Facebook": "nQbbBIzDhMXXfa7iDUoonz5zS",
"19544aa2-d634-4859-b193-e57af82b5d12": "eu1SsrjsiDf3h3LryUjxHIKTS0yyrbiPcsKF3HDp"
},
"username": "johnny123",
"usernameStatus": "ACTIVE"
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactorEnabled": false,
"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.
When using the PUT
HTTP method, you must specify all of the properties of the User when calling this API. 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 only 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 with PUT
.
Request
Update the User with the given Id
PUT /api/user/{userId}
PATCH /api/user/{userId}
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
- 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.
- 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.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:
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 Password Encryptors 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 texts 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
- users.twoFactorDelivery [String] Optional defaults to
None
-
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.
-
- user.twoFactorEnabled [Boolean] Optional defaults to
false
-
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.
- user.twoFactorSecret [String] Optional
-
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.
- 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.
-
{
"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 updated 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
- token [String] Available since 1.16.0
-
The access token, this string is an encoded JSON Web Token (JWT).
- 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.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.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 user was created.
- user.lastLoginInstant [Long]
-
The instant when the User logged in last.
- user.lastName [String]
-
The User’s last name.
- 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 is 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 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.
- 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>] Available since 1.1.0 -
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. - user.registrations
[x]
.username [String] -
The username of the User for this registration only.
- 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.
- 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 User’s to change this per-session. The string will be in an IANA time zone format.
- user.twoFactorDelivery [String]
-
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
-
- user.twoFactorEnabled [Boolean]
-
Determines if the User has two factor authentication enabled for their account or not.
- 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.
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImMxVU5ON0pIUVc4X21ROHBTaWZKbzBXekdybDlTbTRnIn0.eyJleHAiOjE1ODY4ODQzNzksImlhdCI6MTU4Njg4NDMxOSwiaXNzIjoiZnVzaW9uYXV0aC5pbyIsInN1YiI6IjAwMDAwMDAwLTAwMDAtMDAwMS0wMDAwLTAwMDAwMDAwMDAwMCIsImF1dGhlbnRpY2F0aW9uVHlwZSI6IlVTRVJfQ1JFQVRFIiwiZW1haWwiOiJ0ZXN0MEBmdXNpb25hdXRoLmlvIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInByZWZlcnJlZF91c2VybmFtZSI6InVzZXJuYW1lMCJ9.Z1jV8xDcayZZDBdLRVd2fIyowhstRI4Dgk7_u2XFerc",
"user": {
"active": true,
"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",
"tokens": {
"Facebook": "nQbbBIzDhMXXfa7iDUoonz5zS",
"19544aa2-d634-4859-b193-e57af82b5d12": "eu1SsrjsiDf3h3LryUjxHIKTS0yyrbiPcsKF3HDp"
},
"username": "johnny123",
"usernameStatus": "ACTIVE"
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactorEnabled": false,
"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 updated 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
- token [String] Available since 1.16.0
-
The access token, this string is an encoded JSON Web Token (JWT).
- 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.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.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 user was created.
- user.lastLoginInstant [Long]
-
The instant when the User logged in last.
- user.lastName [String]
-
The User’s last name.
- 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 is 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 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.
- 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>] Available since 1.1.0 -
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. - user.registrations
[x]
.username [String] -
The username of the User for this registration only.
- 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.
- 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 User’s to change this per-session. The string will be in an IANA time zone format.
- user.twoFactorDelivery [String]
-
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
-
- user.twoFactorEnabled [Boolean]
-
Determines if the User has two factor authentication enabled for their account or not.
- 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.
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImMxVU5ON0pIUVc4X21ROHBTaWZKbzBXekdybDlTbTRnIn0.eyJleHAiOjE1ODY4ODQzNzksImlhdCI6MTU4Njg4NDMxOSwiaXNzIjoiZnVzaW9uYXV0aC5pbyIsInN1YiI6IjAwMDAwMDAwLTAwMDAtMDAwMS0wMDAwLTAwMDAwMDAwMDAwMCIsImF1dGhlbnRpY2F0aW9uVHlwZSI6IlVTRVJfQ1JFQVRFIiwiZW1haWwiOiJ0ZXN0MEBmdXNpb25hdXRoLmlvIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInByZWZlcnJlZF91c2VybmFtZSI6InVzZXJuYW1lMCJ9.Z1jV8xDcayZZDBdLRVd2fIyowhstRI4Dgk7_u2XFerc",
"user": {
"active": true,
"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",
"tokens": {
"Facebook": "nQbbBIzDhMXXfa7iDUoonz5zS",
"19544aa2-d634-4859-b193-e57af82b5d12": "eu1SsrjsiDf3h3LryUjxHIKTS0yyrbiPcsKF3HDp"
},
"username": "johnny123",
"usernameStatus": "ACTIVE"
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactorEnabled": false,
"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:
- 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.
- 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:
-
If 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 Password Encryptors 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 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.
- 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]
.twoFactorDelivery [String] Optional defaults toNone
-
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
.
-
- 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.
- users
[x]
.twoFactorSecret [String] Optional -
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. - 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 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",
"twoFactorEnabled": false,
"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. |
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.
- metaData.device.description [String] Optional
-
A human readable description of the device represented by the
device
parameter. - metaData.device.lastAccessedAddress [String] Optional
-
The IP address of this login request.
- metaData.device.name [String] Optional
-
A human readable name of the device represented by the
device
parameter. - 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.
- 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 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": 50,
"queryString": "@fusionauth.io",
"sortFields": [
{
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
piper
.{
"search": {
"numberOfResults": 50,
"queryString": "piper",
"sortFields": [
{
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
{
"search": {
"numberOfResults": 50,
"queryString": "*",
"sortFields": [
{
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
Elasticsearch Search Engine
The Elasticsearch engine has advanced querying capabilities and better performance.
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": 50,
"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": 50,
"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": 50,
"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": 50,
"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
}
}
}
}
}]
}
}
{
"search": {
"numberOfResults": 50,
"queryString": "email:*@fusionauth.io",
"sortFields": [
{
"missing": "_first",
"name": "email",
"order": "asc"
}
],
"startRow": 0
}
}
{
"search": {
"numberOfResults": 50,
"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": 50,
"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]
.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 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]
.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>] Available since 1.1.0 -
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. - users
[x]
.registrations[x]
.username [String] -
The username of the User for this registration only.
- 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]
.twoFactorDelivery [String] -
The User’s preferred delivery for verification codes during a two factor login request.
The possible values are:
-
None
-
TextMessage
-
- users
[x]
.twoFactorEnabled [Boolean] -
Determines if the User has two factor authentication enabled for their account or not.
- 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.
{
"users": [
{
"active": true,
"birthDate": "1976-05-30",
"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"
],
"tokens": {
"Facebook": "nQbbBIzDhMXXfa7iDUoonz5zS",
"19544aa2-d634-4859-b193-e57af82b5d12": "eu1SsrjsiDf3h3LryUjxHIKTS0yyrbiPcsKF3HDp"
},
"username": "johnny123",
"usernameStatus": "ACTIVE",
"verified": true
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactorEnabled": false,
"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]
.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",
"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",
"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",
"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/{verificationId}
Request Parameters
- verificationId [String] Required
-
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.
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 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 updated 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.
Request
PUT /api/user/verify-email?email={email}
Request Parameters
- 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?email={email}&sendVerifyEmail={sendVerifyEmail}
Request Parameters
- 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 tofalse
.
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 updated 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.
{
"verificationId": "YkQY5Gsyo4RlfmDciBGRmvfj3RmatUqrbjoIZ19fmw4"
}
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 have user’s that 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
- 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.
{
"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
- 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 Forgot Password Email Template. Setting this to false will skip the email attempt and only set the
changePasswordId
for the user.
{
"changePasswordId": "YkQY5Gsyo4RlfmDciBGRmvfj3RmatUqrbjoIZ19fmw4",
"loginId": "example@fusionauth.io",
"sendForgotPasswordEmail": false
}
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/{changePasswordId}
Request Parameters
- changePasswordId [String] Required
-
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.
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] 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.
{
"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
- 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.
{
"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
.
{
"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. |
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"
}