Form Field API
On this page
This feature requires at least a Starter plan.
A FusionAuth Form Field is an object that can be customized to receive input within a FusionAuth Form.
The following APIs are provided to manage Forms Fields.
Create a Form Field#
This API is used to create a new Form Field.
Request#
Create a Form Field with either a randomly generated Id or one you provide on the URI.
OpenAPI Spec
OpenAPI Spec
Path Parameters#
fieldIdThe Id to use for the new Form Field. If not specified a secure random UUID will be generated.
Request Body#
field.confirm Determines if the user input should be confirmed by requiring the value to be entered twice. If true, a confirmation field is included.
field.consentId The Id of an existing Consent. This field is required when type is consent.
A consent Form Field lets users self-consent during registration to a FusionAuth Consent, such as terms of service, an end user license agreement, or another opt-in or opt-out agreement.
field.control The form control that displays the Form Field. The possible values are:
checkboxnumberpasswordradioselecttextareatext
You can set the control for custom fields only. The default value is text. FusionAuth sets the control of managed fields, such as user.firstName.
field.data An object that can hold any information about the Form Field that should be persisted.
This may be useful to add additional meta data to the field that will help you style or render the Form Field. For example, in the JSON example an attribute is added to this data field as follows:
{
"data": {
"leftAddOn": "user"
}
}
This additional meta data is then used to render an icon on the Form Field. Use of this additional data is optional and not required to render the field.
field.description A description of the Form Field.
field.key The path to the value in the user or registration object.
You can't change the key after you create the Form Field. To use a different key, create a new Form Field.
FusionAuth manages the following predefined keys. A Form Field with a predefined key has a fixed data type and form control.
registration.preferredLanguagesAvailable since1.20.0registration.rolesAvailable since1.20.0registration.timezoneAvailable since1.20.0registration.usernameuser.birthDateuser.emailuser.firstNameuser.fullNameuser.imageUrlAvailable since1.20.0user.lastNameuser.middleNameuser.mobilePhoneuser.parentEmailAvailable since1.33.0user.passworduser.phoneNumberAvailable since1.59.0user.preferredLanguagesAvailable since1.20.0user.timezoneAvailable since1.20.0user.username
To store custom data, start the key with one of the following prefixes:
user.data.registration.data.
For example, to store the favorite color of a User, set the key to user.data.favoriteColor.
A key can't contain spaces or special characters. To store the value in an array, use array syntax, such as [0] for the first position. To store the value in a nested object, use object syntax, such as ['foo'] for the property named foo. For example:
user.data.preferences[0]stores the value in the first position of an array namedpreferences.user.data.preferences['color']stores the value in thecolorproperty of an object namedpreferences.
To show a readable, localized label for the key during registration, add the key to the messages of your theme. For example, the following message shows Favorite color for the user.data.favoriteColor key:
user.data.favoriteColor=Favorite color
field.name The unique name of the Form Field.
field.options A list of options that are applied to checkbox, radio, or select controls.
The options for a field must conform to the field.type. If the field.type is number, the options must be numbers. If the field.type is boolean, only true and/or false are allowed.
You may localize the displayed values during registration by adding these values to your theme.
For example, if you specify the values ["red", "green", "blue"] as the field options, these will be stored on the user in this lowercase form. By default the values red, green and blue will be rendered in the UI.
If you were to add the following messages to your theme, the capitalized form of the values will be shown to the end user. This allows you to provide a human-readable form of the value and optionally localize the displayed values.
red=Red
green=Green
blue=Blue
red=Roja
green=Verde
blue=Azul
field.required Determines if a value is required to complete the form.
field.type The data type FusionAuth uses to store the value. The possible values are:
bool: a boolean value,trueorfalse.consent: a value that completes self-consent.date: a date inYYYY-MM-DDformat, such as2025-01-31. A JavaScript date picker can convert the selected date to this format.email: a valid email address.number: a numeric value.phoneNumber: a phone number, such as+13035551212or(303) 555-1212. FusionAuth treats a number without a country code as a US number. FusionAuth stores the value as the user enters the value, without converting the value to E.164 format. FusionAuth accepts short values such as123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since1.59.0string: a string.
FusionAuth validates all user input against the data type. When FusionAuth can't convert the input, FusionAuth shows a validation error to the user. Each option in options must also match the data type. A phoneNumber Form Field with a checkbox, radio, or select control returns a 400 status code, because FusionAuth can't validate options for the phoneNumber data type. An email Form Field always uses the text control.
When type is consent, consentId is required.
You can set the data type for custom fields only. The default value is string. FusionAuth sets the data type of managed fields, such as user.firstName.
You can't change the data type after you create the Form Field. To use a different data type, create a new Form Field.
field.validator.enabled Determines if user input should be validated.
field.validator.expression A regular expression used to validate user input. Must be a valid regular expression pattern. The expression must match the whole value, so [0-9]+ rejects abc123.
See Pattern for examples and syntax.
{
"field": {
"data": {
"leftAddOn": "send"
},
"description": "Information about this custom field",
"key": "user.firstName",
"name": "Custom first-name Form Field",
"required": true
}
}Response#
The response for this API contains the Form Field that was created.
| Code | Description |
|---|---|
| 200 | The request succeeded. The response contains a JSON body. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes. |
Response Body#
field.confirm Determines if the user input should be confirmed by requiring the value to be entered twice. If true, a confirmation field is included.
field.consentId The Id of an existing Consent. This field is required when type is consent.
A consent Form Field lets users self-consent during registration to a FusionAuth Consent, such as terms of service, an end user license agreement, or another opt-in or opt-out agreement.
field.control The form control that displays the Form Field. The possible values are:
checkboxnumberpasswordradioselecttextareatext
field.data An object that can hold any information about the Form Field that should be persisted.
This may be useful to add additional meta data to the field that will help you style or render the Form Field. For example, in the JSON example an attribute is added to this data field as follows:
{
"data": {
"leftAddOn": "user"
}
}
This additional meta data is then used to render an icon on the Form Field. Use of this additional data is optional and not required to render the field.
field.description A description of the Form Field.
field.id The unique Id of the form field.
field.insertInstant The instant that the form field was added to the FusionAuth database.
field.key The path to the value in the user or registration object.
FusionAuth manages the following predefined keys. A Form Field with a predefined key has a fixed data type and form control.
registration.preferredLanguagesAvailable since1.20.0registration.rolesAvailable since1.20.0registration.timezoneAvailable since1.20.0registration.usernameuser.birthDateuser.emailuser.firstNameuser.fullNameuser.imageUrlAvailable since1.20.0user.lastNameuser.middleNameuser.mobilePhoneuser.parentEmailAvailable since1.33.0user.passworduser.phoneNumberAvailable since1.59.0user.preferredLanguagesAvailable since1.20.0user.timezoneAvailable since1.20.0user.username
To store custom data, start the key with one of the following prefixes:
user.data.registration.data.
For example, to store the favorite color of a User, set the key to user.data.favoriteColor.
A key can't contain spaces or special characters. To store the value in an array, use array syntax, such as [0] for the first position. To store the value in a nested object, use object syntax, such as ['foo'] for the property named foo. For example:
user.data.preferences[0]stores the value in the first position of an array namedpreferences.user.data.preferences['color']stores the value in thecolorproperty of an object namedpreferences.
To show a readable, localized label for the key during registration, add the key to the messages of your theme. For example, the following message shows Favorite color for the user.data.favoriteColor key:
user.data.favoriteColor=Favorite color
field.lastUpdateInstant The instant that the form field was last updated in the FusionAuth database.
field.name The unique name of the Form Field.
field.options A list of options that are applied to checkbox, radio, or select controls.
The options for a field must conform to the field.type. If the field.type is number, the options must be numbers. If the field.type is boolean, only true and/or false are allowed.
You may localize the displayed values during registration by adding these values to your theme.
For example, if you specify the values ["red", "green", "blue"] as the field options, these will be stored on the user in this lowercase form. By default the values red, green and blue will be rendered in the UI.
If you were to add the following messages to your theme, the capitalized form of the values will be shown to the end user. This allows you to provide a human-readable form of the value and optionally localize the displayed values.
red=Red
green=Green
blue=Blue
red=Roja
green=Verde
blue=Azul
field.required Determines if a value is required to complete the form.
field.type The data type FusionAuth uses to store the value. The possible values are:
bool: a boolean value,trueorfalse.consent: a value that completes self-consent.date: a date inYYYY-MM-DDformat, such as2025-01-31. A JavaScript date picker can convert the selected date to this format.email: a valid email address.number: a numeric value.phoneNumber: a phone number, such as+13035551212or(303) 555-1212. FusionAuth treats a number without a country code as a US number. FusionAuth stores the value as the user enters the value, without converting the value to E.164 format. FusionAuth accepts short values such as123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since1.59.0string: a string.
field.validator.enabled Determines if user input should be validated.
field.validator.expression A regular expression used to validate user input. Must be a valid regular expression pattern.
See Pattern for examples and syntax.
{
"field": {
"confirm": false,
"control": "text",
"data": {
"leftAddOn": "send"
},
"description": "Information about this custom field",
"id": "e96f02db-4567-43a6-a876-74a3869fe94a",
"insertInstant": 1562189072183,
"key": "user.firstName",
"lastUpdateInstant": 1562189927638,
"name": "Custom first-name Form Field",
"required": true,
"type": "string",
"validator": {
"enabled": false
}
}
}Retrieve a Form Field#
This API is used to retrieve a single Form Field by unique Id or all of the configured Form Fields.
Request#
Retrieve all of the Form Fields, or provide an Id to retrieve a single Form Field.
OpenAPI Spec
OpenAPI Spec
Path Parameters#
fieldIdThe unique Id of the Form Field to retrieve.
Response#
The response for this API contains either a single Form Field or all of the Form Fields. When you call this API with an Id, the response will contain a single Form Field. When you call this API without an Id, the response will contain all of the Form Fields. Both response types are defined below along with an example JSON response.
| Code | Description |
|---|---|
| 200 | The request succeeded. The response contains a JSON body. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 404 | The object you requested doesn't exist. The response is empty. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty. |
Response Body#
field.confirm Determines if the user input should be confirmed by requiring the value to be entered twice. If true, a confirmation field is included.
field.consentId The Id of an existing Consent. This field is required when type is consent.
A consent Form Field lets users self-consent during registration to a FusionAuth Consent, such as terms of service, an end user license agreement, or another opt-in or opt-out agreement.
field.control The form control that displays the Form Field. The possible values are:
checkboxnumberpasswordradioselecttextareatext
field.data An object that can hold any information about the Form Field that should be persisted.
This may be useful to add additional meta data to the field that will help you style or render the Form Field. For example, in the JSON example an attribute is added to this data field as follows:
{
"data": {
"leftAddOn": "user"
}
}
This additional meta data is then used to render an icon on the Form Field. Use of this additional data is optional and not required to render the field.
field.description A description of the Form Field.
field.id The unique Id of the form field.
field.insertInstant The instant that the form field was added to the FusionAuth database.
field.key The path to the value in the user or registration object.
FusionAuth manages the following predefined keys. A Form Field with a predefined key has a fixed data type and form control.
registration.preferredLanguagesAvailable since1.20.0registration.rolesAvailable since1.20.0registration.timezoneAvailable since1.20.0registration.usernameuser.birthDateuser.emailuser.firstNameuser.fullNameuser.imageUrlAvailable since1.20.0user.lastNameuser.middleNameuser.mobilePhoneuser.parentEmailAvailable since1.33.0user.passworduser.phoneNumberAvailable since1.59.0user.preferredLanguagesAvailable since1.20.0user.timezoneAvailable since1.20.0user.username
To store custom data, start the key with one of the following prefixes:
user.data.registration.data.
For example, to store the favorite color of a User, set the key to user.data.favoriteColor.
A key can't contain spaces or special characters. To store the value in an array, use array syntax, such as [0] for the first position. To store the value in a nested object, use object syntax, such as ['foo'] for the property named foo. For example:
user.data.preferences[0]stores the value in the first position of an array namedpreferences.user.data.preferences['color']stores the value in thecolorproperty of an object namedpreferences.
To show a readable, localized label for the key during registration, add the key to the messages of your theme. For example, the following message shows Favorite color for the user.data.favoriteColor key:
user.data.favoriteColor=Favorite color
field.lastUpdateInstant The instant that the form field was last updated in the FusionAuth database.
field.name The unique name of the Form Field.
field.options A list of options that are applied to checkbox, radio, or select controls.
The options for a field must conform to the field.type. If the field.type is number, the options must be numbers. If the field.type is boolean, only true and/or false are allowed.
You may localize the displayed values during registration by adding these values to your theme.
For example, if you specify the values ["red", "green", "blue"] as the field options, these will be stored on the user in this lowercase form. By default the values red, green and blue will be rendered in the UI.
If you were to add the following messages to your theme, the capitalized form of the values will be shown to the end user. This allows you to provide a human-readable form of the value and optionally localize the displayed values.
red=Red
green=Green
blue=Blue
red=Roja
green=Verde
blue=Azul
field.required Determines if a value is required to complete the form.
field.type The data type FusionAuth uses to store the value. The possible values are:
bool: a boolean value,trueorfalse.consent: a value that completes self-consent.date: a date inYYYY-MM-DDformat, such as2025-01-31. A JavaScript date picker can convert the selected date to this format.email: a valid email address.number: a numeric value.phoneNumber: a phone number, such as+13035551212or(303) 555-1212. FusionAuth treats a number without a country code as a US number. FusionAuth stores the value as the user enters the value, without converting the value to E.164 format. FusionAuth accepts short values such as123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since1.59.0string: a string.
field.validator.enabled Determines if user input should be validated.
field.validator.expression A regular expression used to validate user input. Must be a valid regular expression pattern.
See Pattern for examples and syntax.
{
"field": {
"confirm": false,
"control": "text",
"data": {
"leftAddOn": "send"
},
"description": "Information about this custom field",
"id": "e96f02db-4567-43a6-a876-74a3869fe94a",
"insertInstant": 1562189072183,
"key": "user.firstName",
"lastUpdateInstant": 1562189927638,
"name": "Custom first-name Form Field",
"required": true,
"type": "string",
"validator": {
"enabled": false
}
}
}Response Body#
fieldsThe list of Form Field objects.
fields[x].confirm Determines if the user input should be confirmed by requiring the value to be entered twice. If true, a confirmation field is included.
fields[x].consentId The Id of an existing Consent. This field is required when type is consent.
A consent Form Field lets users self-consent during registration to a FusionAuth Consent, such as terms of service, an end user license agreement, or another opt-in or opt-out agreement.
fields[x].control The form control that displays the Form Field. The possible values are:
checkboxnumberpasswordradioselecttextareatext
fields[x].data An object that can hold any information about the Form Field that should be persisted.
This may be useful to add additional meta data to the field that will help you style or render the Form Field. For example, in the JSON example an attribute is added to this data field as follows:
{
"data": {
"leftAddOn": "user"
}
}
This additional meta data is then used to render an icon on the Form Field. Use of this additional data is optional and not required to render the field.
fields[x].description A description of the Form Field.
fields[x].id The unique Id of the form field.
fields[x].inseertInstant The instant that the Form Field was added to the FusionAuth database.
fields[x].key The path to the value in the user or registration object.
FusionAuth manages the following predefined keys. A Form Field with a predefined key has a fixed data type and form control.
registration.preferredLanguagesAvailable since1.20.0registration.rolesAvailable since1.20.0registration.timezoneAvailable since1.20.0registration.usernameuser.birthDateuser.emailuser.firstNameuser.fullNameuser.imageUrlAvailable since1.20.0user.lastNameuser.middleNameuser.mobilePhoneuser.parentEmailAvailable since1.33.0user.passworduser.phoneNumberAvailable since1.59.0user.preferredLanguagesAvailable since1.20.0user.timezoneAvailable since1.20.0user.username
To store custom data, start the key with one of the following prefixes:
user.data.registration.data.
For example, to store the favorite color of a User, set the key to user.data.favoriteColor.
A key can't contain spaces or special characters. To store the value in an array, use array syntax, such as [0] for the first position. To store the value in a nested object, use object syntax, such as ['foo'] for the property named foo. For example:
user.data.preferences[0]stores the value in the first position of an array namedpreferences.user.data.preferences['color']stores the value in thecolorproperty of an object namedpreferences.
To show a readable, localized label for the key during registration, add the key to the messages of your theme. For example, the following message shows Favorite color for the user.data.favoriteColor key:
user.data.favoriteColor=Favorite color
fields[x].lastUpdateInstant The instant that the form field was last updated in the FusionAuth database.
fields[x].name The unique name of the Form Field.
fields[x].confirm A list of options that are applied to checkbox, radio, or select controls.
The options for a field must conform to the field.type. If the field.type is number, the options must be numbers. If the field.type is boolean, only true and/or false are allowed.
You may localize the displayed values during registration by adding these values to your theme.
For example, if you specify the values ["red", "green", "blue"] as the field options, these will be stored on the user in this lowercase form. By default the values red, green and blue will be rendered in the UI.
If you were to add the following messages to your theme, the capitalized form of the values will be shown to the end user. This allows you to provide a human-readable form of the value and optionally localize the displayed values.
red=Red
green=Green
blue=Blue
red=Roja
green=Verde
blue=Azul
fields[x].required Determines if a value is required to complete the form.
fields[x].type The data type FusionAuth uses to store the value. The possible values are:
bool: a boolean value,trueorfalse.consent: a value that completes self-consent.date: a date inYYYY-MM-DDformat, such as2025-01-31. A JavaScript date picker can convert the selected date to this format.email: a valid email address.number: a numeric value.phoneNumber: a phone number, such as+13035551212or(303) 555-1212. FusionAuth treats a number without a country code as a US number. FusionAuth stores the value as the user enters the value, without converting the value to E.164 format. FusionAuth accepts short values such as123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since1.59.0string: a string.
fields[x].validator.enabled Determines if user input should be validated.
fields[x].validator.expression A regular expression used to validate user input.
{
"fields": [
{
"confirm": false,
"control": "text",
"data": {
"leftAddOn": "send"
},
"description": "Information about this custom field",
"id": "e96f02db-4567-43a6-a876-74a3869fe94a",
"insertInstant": 1562189072183,
"key": "user.firstName",
"lastUpdateInstant": 1562189927638,
"name": "Custom first-name Form Field",
"required": true,
"type": "string",
"validator": {
"enabled": false
}
}
]
}Update a Form Field#
This API is used to update an existing Form Field.
You must specify all of the properties of the Form Field when calling this API with the PUT HTTP method. When used with PUT, this API doesn't merge the existing Form Field and your new data. It replaces the existing Form Field with your new data.
Utilize the PATCH HTTP method to send specific changes to merge into an existing Form Field.
You can't change key or type after you create a Form Field. FusionAuth keeps the original values. To use a different key or data type, create a new Form Field.
Request#
Send the full Form Field with your changes applied.
OpenAPI Spec
OpenAPI Spec
For backward compatibility, a PATCH request with a Content-Type of application/json accepts the same body as the PUT request. FusionAuth merges the request into the existing object:
- FusionAuth keeps every field that the request leaves out, so send only the fields you want to change.
- FusionAuth merges a map, such as
data, by key. To remove a key, set the key tonull. - FusionAuth appends the values in a request array to the existing array, unless this API documents otherwise. An empty array leaves the existing array unchanged, so you can't remove values from an appending array.
- FusionAuth adds each object in an array of objects as a new element. FusionAuth doesn't match the object to an existing element by Id or by position.
- Don't send a value that an array of Ids already contains, such as a key Id or a Tenant Id. Some of these arrays then return a
500status code. - Don't set an array to
null. Depending on the field, FusionAuth clears the array or returns a500status code.
To remove values from an array, PUT the full object, or set the Content-Type to one of the following media types:
application/json-patch+jsonfor JSON Patch (RFC 6902)application/merge-patch+jsonfor JSON Merge Patch (RFC 7396)
For more information, see The PATCH HTTP Method.
Path Parameters#
fieldIdThe Id of the Form Field to update.
Request Body#
field.confirm Determines if the user input should be confirmed by requiring the value to be entered twice. If true, a confirmation field is included.
field.consentId The Id of an existing Consent. This field is required when type is consent.
A consent Form Field lets users self-consent during registration to a FusionAuth Consent, such as terms of service, an end user license agreement, or another opt-in or opt-out agreement.
You can change the Consent of a consent Form Field with this API. FusionAuth updates the key of the Form Field to match the new Consent. The Admin UI doesn't allow this change.
field.control The form control that displays the Form Field. The possible values are:
checkboxnumberpasswordradioselecttextareatext
This field is required when you update a custom Form Field with PUT, unless the Form Field is a consent Form Field. You can change the control of a custom Form Field with this API. The Admin UI doesn't allow this change.
FusionAuth ignores this field for managed fields, such as user.firstName, and for consent Form Fields. FusionAuth keeps the original control of those Form Fields.
field.data An object that can hold any information about the Form Field that should be persisted.
This may be useful to add additional meta data to the field that will help you style or render the Form Field. For example, in the JSON example an attribute is added to this data field as follows:
{
"data": {
"leftAddOn": "user"
}
}
This additional meta data is then used to render an icon on the Form Field. Use of this additional data is optional and not required to render the field.
field.description A description of the Form Field.
field.name The unique name of the Form Field.
field.options A list of options that are applied to checkbox, radio, or select controls.
The options for a field must conform to the field.type. If the field.type is number, the options must be numbers. If the field.type is boolean, only true and/or false are allowed.
You may localize the displayed values during registration by adding these values to your theme.
For example, if you specify the values ["red", "green", "blue"] as the field options, these will be stored on the user in this lowercase form. By default the values red, green and blue will be rendered in the UI.
If you were to add the following messages to your theme, the capitalized form of the values will be shown to the end user. This allows you to provide a human-readable form of the value and optionally localize the displayed values.
red=Red
green=Green
blue=Blue
red=Roja
green=Verde
blue=Azul
field.required Determines if a value is required to complete the form.
field.type The data type FusionAuth uses to store the value. The possible values are:
bool: a boolean value,trueorfalse.consent: a value that completes self-consent.date: a date inYYYY-MM-DDformat, such as2025-01-31. A JavaScript date picker can convert the selected date to this format.email: a valid email address.number: a numeric value.phoneNumber: a phone number, such as+13035551212or(303) 555-1212. FusionAuth treats a number without a country code as a US number. FusionAuth stores the value as the user enters the value, without converting the value to E.164 format. FusionAuth accepts short values such as123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since1.59.0string: a string.
You can't change the data type after you create the Form Field. FusionAuth keeps the original data type, but still validates the request against the type you send. Send the original type, or leave type out. When you update a consent Form Field with PUT, set type to consent.
field.validator.enabled Determines if user input should be validated.
field.validator.expression A regular expression used to validate user input. Must be a valid regular expression pattern. The expression must match the whole value, so [0-9]+ rejects abc123.
See Pattern for examples and syntax.
{
"field": {
"control": "text",
"data": {
"leftAddOn": "send"
},
"description": "Updated information about this custom field",
"name": "Custom, updated, first-name Form Field",
"required": false
}
}Response#
The response for this API contains the Form Field that was updated.
| Code | Description |
|---|---|
| 200 | The request succeeded. The response contains a JSON body. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 404 | The object you're updating doesn't exist. The response is empty. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes. |
Response Body#
field.confirm Determines if the user input should be confirmed by requiring the value to be entered twice. If true, a confirmation field is included.
field.consentId The Id of an existing Consent. This field is required when type is consent.
A consent Form Field lets users self-consent during registration to a FusionAuth Consent, such as terms of service, an end user license agreement, or another opt-in or opt-out agreement.
field.control The form control that displays the Form Field. The possible values are:
checkboxnumberpasswordradioselecttextareatext
field.data An object that can hold any information about the Form Field that should be persisted.
This may be useful to add additional meta data to the field that will help you style or render the Form Field. For example, in the JSON example an attribute is added to this data field as follows:
{
"data": {
"leftAddOn": "user"
}
}
This additional meta data is then used to render an icon on the Form Field. Use of this additional data is optional and not required to render the field.
field.description A description of the Form Field.
field.id The unique Id of the form field.
field.insertInstant The instant that the form field was added to the FusionAuth database.
field.key The path to the value in the user or registration object.
FusionAuth manages the following predefined keys. A Form Field with a predefined key has a fixed data type and form control.
registration.preferredLanguagesAvailable since1.20.0registration.rolesAvailable since1.20.0registration.timezoneAvailable since1.20.0registration.usernameuser.birthDateuser.emailuser.firstNameuser.fullNameuser.imageUrlAvailable since1.20.0user.lastNameuser.middleNameuser.mobilePhoneuser.parentEmailAvailable since1.33.0user.passworduser.phoneNumberAvailable since1.59.0user.preferredLanguagesAvailable since1.20.0user.timezoneAvailable since1.20.0user.username
To store custom data, start the key with one of the following prefixes:
user.data.registration.data.
For example, to store the favorite color of a User, set the key to user.data.favoriteColor.
A key can't contain spaces or special characters. To store the value in an array, use array syntax, such as [0] for the first position. To store the value in a nested object, use object syntax, such as ['foo'] for the property named foo. For example:
user.data.preferences[0]stores the value in the first position of an array namedpreferences.user.data.preferences['color']stores the value in thecolorproperty of an object namedpreferences.
To show a readable, localized label for the key during registration, add the key to the messages of your theme. For example, the following message shows Favorite color for the user.data.favoriteColor key:
user.data.favoriteColor=Favorite color
field.lastUpdateInstant The instant that the form field was last updated in the FusionAuth database.
field.name The unique name of the Form Field.
field.options A list of options that are applied to checkbox, radio, or select controls.
The options for a field must conform to the field.type. If the field.type is number, the options must be numbers. If the field.type is boolean, only true and/or false are allowed.
You may localize the displayed values during registration by adding these values to your theme.
For example, if you specify the values ["red", "green", "blue"] as the field options, these will be stored on the user in this lowercase form. By default the values red, green and blue will be rendered in the UI.
If you were to add the following messages to your theme, the capitalized form of the values will be shown to the end user. This allows you to provide a human-readable form of the value and optionally localize the displayed values.
red=Red
green=Green
blue=Blue
red=Roja
green=Verde
blue=Azul
field.required Determines if a value is required to complete the form.
field.type The data type FusionAuth uses to store the value. The possible values are:
bool: a boolean value,trueorfalse.consent: a value that completes self-consent.date: a date inYYYY-MM-DDformat, such as2025-01-31. A JavaScript date picker can convert the selected date to this format.email: a valid email address.number: a numeric value.phoneNumber: a phone number, such as+13035551212or(303) 555-1212. FusionAuth treats a number without a country code as a US number. FusionAuth stores the value as the user enters the value, without converting the value to E.164 format. FusionAuth accepts short values such as123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since1.59.0string: a string.
field.validator.enabled Determines if user input should be validated.
field.validator.expression A regular expression used to validate user input. Must be a valid regular expression pattern.
See Pattern for examples and syntax.
{
"field": {
"confirm": false,
"control": "text",
"data": {
"leftAddOn": "send"
},
"description": "Information about this custom field",
"id": "e96f02db-4567-43a6-a876-74a3869fe94a",
"insertInstant": 1562189072183,
"key": "user.firstName",
"lastUpdateInstant": 1562189927638,
"name": "Custom first-name Form Field",
"required": true,
"type": "string",
"validator": {
"enabled": false
}
}
}Delete a Form Field#
This API is used to permanently delete a Form Field. A form field cannot be deleted when in use by a one or more forms.
Request#
Delete a Form Field by its Id.
OpenAPI Spec
Path Parameters#
fieldIdThe unique Id of the Form Field to delete.
Response#
This API does not return a JSON response body.
| Code | Description |
|---|---|
| 200 | The request succeeded. |
| 400 | The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present. |
| 401 | FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses. |
| 404 | The object you requested doesn't exist. The response is empty. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty. |
Related
Learn about the APIs for creating, retrieving, updating and deleting forms.
API documentation for the FusionAuth Create a User and Registration (combined) API.
API documentation for the FusionAuth Create a User Registration (for an existing user) API.
API documentation for the FusionAuth Delete a User Registration API.