Form Field API

On this page
Starter plan required

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.

Global API Key Authentication
Create a Form Field with a randomly generated Id
POST/api/form/field
OpenAPI Spec
Global API Key Authentication
Create a Form Field with the provided unique Id
POST/api/form/field/{fieldId}
OpenAPI Spec

Path Parameters#

fieldId
  • Type: UUID
  • Optional
  • Defaults to secure random UUID

The Id to use for the new Form Field. If not specified a secure random UUID will be generated.

Request Body#
field.confirm
  • Type: Boolean
  • Optional
  • Defaults to false

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
  • Type: UUID
  • Optional

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
  • Type: String
  • Optional
  • Defaults to text

The form control that displays the Form Field. The possible values are:

  • checkbox
  • number
  • password
  • radio
  • select
  • textarea
  • text

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
  • Type: Object
  • Optional

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
  • Type: String
  • Optional

A description of the Form Field.

field.key
  • Type: String
  • Required

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.preferredLanguages Available since 1.20.0
  • registration.roles Available since 1.20.0
  • registration.timezone Available since 1.20.0
  • registration.username
  • user.birthDate
  • user.email
  • user.firstName
  • user.fullName
  • user.imageUrl Available since 1.20.0
  • user.lastName
  • user.middleName
  • user.mobilePhone
  • user.parentEmail Available since 1.33.0
  • user.password
  • user.phoneNumber Available since 1.59.0
  • user.preferredLanguages Available since 1.20.0
  • user.timezone Available since 1.20.0
  • user.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 named preferences.
  • user.data.preferences['color'] stores the value in the color property of an object named preferences.

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
  • Type: String
  • Required

The unique name of the Form Field.

field.options
  • Type: Array<String>
  • Optional

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.

Default
red=Red
green=Green
blue=Blue
Spanish
red=Roja
green=Verde
blue=Azul
field.required
  • Type: Boolean
  • Optional
  • Defaults to false

Determines if a value is required to complete the form.

field.type
  • Type: String
  • Optional
  • Defaults to string

The data type FusionAuth uses to store the value. The possible values are:

  • bool: a boolean value, true or false.
  • consent: a value that completes self-consent.
  • date: a date in YYYY-MM-DD format, such as 2025-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 +13035551212 or (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 as 123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since 1.59.0
  • string: 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
  • Type: Boolean
  • Optional
  • Defaults to false

Determines if user input should be validated.

field.validator.expression
  • Type: String
  • Optional

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.

Example Request JSON
{
  "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.

Response Codes
CodeDescription
200The request succeeded. The response contains a JSON body.
400The 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.
401FusionAuth 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.
500FusionAuth 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
  • Type: Boolean

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
  • Type: UUID

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
  • Type: String

The form control that displays the Form Field. The possible values are:

  • checkbox
  • number
  • password
  • radio
  • select
  • textarea
  • text
field.data
  • Type: Object

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
  • Type: String

A description of the Form Field.

field.id
  • Type: UUID

The unique Id of the form field.

field.insertInstant
  • Type: Long

The instant that the form field was added to the FusionAuth database.

field.key
  • Type: String

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.preferredLanguages Available since 1.20.0
  • registration.roles Available since 1.20.0
  • registration.timezone Available since 1.20.0
  • registration.username
  • user.birthDate
  • user.email
  • user.firstName
  • user.fullName
  • user.imageUrl Available since 1.20.0
  • user.lastName
  • user.middleName
  • user.mobilePhone
  • user.parentEmail Available since 1.33.0
  • user.password
  • user.phoneNumber Available since 1.59.0
  • user.preferredLanguages Available since 1.20.0
  • user.timezone Available since 1.20.0
  • user.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 named preferences.
  • user.data.preferences['color'] stores the value in the color property of an object named preferences.

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
  • Type: Long

The instant that the form field was last updated in the FusionAuth database.

field.name
  • Type: String

The unique name of the Form Field.

field.options
  • Type: Array<String>

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.

Default
red=Red
green=Green
blue=Blue
Spanish
red=Roja
green=Verde
blue=Azul
field.required
  • Type: Boolean

Determines if a value is required to complete the form.

field.type
  • Type: String

The data type FusionAuth uses to store the value. The possible values are:

  • bool: a boolean value, true or false.
  • consent: a value that completes self-consent.
  • date: a date in YYYY-MM-DD format, such as 2025-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 +13035551212 or (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 as 123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since 1.59.0
  • string: a string.
field.validator.enabled
  • Type: Boolean

Determines if user input should be validated.

field.validator.expression
  • Type: String

A regular expression used to validate user input. Must be a valid regular expression pattern.

See Pattern for examples and syntax.

Example Response JSON
{
  "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.

Global API Key Authentication
Retrieve all of the Form Fields
GET/api/form/field
OpenAPI Spec
Global API Key Authentication
Retrieve a Form Field by Id
GET/api/form/field/{fieldId}
OpenAPI Spec

Path Parameters#

fieldId
  • Type: UUID
  • Required

The 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.

Response Codes
CodeDescription
200The request succeeded. The response contains a JSON body.
400The 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.
401FusionAuth 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.
404The object you requested doesn't exist. The response is empty.
500FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty.

Response Body#

field.confirm
  • Type: Boolean

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
  • Type: UUID

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
  • Type: String

The form control that displays the Form Field. The possible values are:

  • checkbox
  • number
  • password
  • radio
  • select
  • textarea
  • text
field.data
  • Type: Object

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
  • Type: String

A description of the Form Field.

field.id
  • Type: UUID

The unique Id of the form field.

field.insertInstant
  • Type: Long

The instant that the form field was added to the FusionAuth database.

field.key
  • Type: String

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.preferredLanguages Available since 1.20.0
  • registration.roles Available since 1.20.0
  • registration.timezone Available since 1.20.0
  • registration.username
  • user.birthDate
  • user.email
  • user.firstName
  • user.fullName
  • user.imageUrl Available since 1.20.0
  • user.lastName
  • user.middleName
  • user.mobilePhone
  • user.parentEmail Available since 1.33.0
  • user.password
  • user.phoneNumber Available since 1.59.0
  • user.preferredLanguages Available since 1.20.0
  • user.timezone Available since 1.20.0
  • user.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 named preferences.
  • user.data.preferences['color'] stores the value in the color property of an object named preferences.

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
  • Type: Long

The instant that the form field was last updated in the FusionAuth database.

field.name
  • Type: String

The unique name of the Form Field.

field.options
  • Type: Array<String>

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.

Default
red=Red
green=Green
blue=Blue
Spanish
red=Roja
green=Verde
blue=Azul
field.required
  • Type: Boolean

Determines if a value is required to complete the form.

field.type
  • Type: String

The data type FusionAuth uses to store the value. The possible values are:

  • bool: a boolean value, true or false.
  • consent: a value that completes self-consent.
  • date: a date in YYYY-MM-DD format, such as 2025-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 +13035551212 or (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 as 123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since 1.59.0
  • string: a string.
field.validator.enabled
  • Type: Boolean

Determines if user input should be validated.

field.validator.expression
  • Type: String

A regular expression used to validate user input. Must be a valid regular expression pattern.

See Pattern for examples and syntax.

Example Response JSON
{
  "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#

fields
  • Type: Array

The list of Form Field objects.

fields[x].confirm
  • Type: Boolean

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
  • Type: UUID

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
  • Type: String

The form control that displays the Form Field. The possible values are:

  • checkbox
  • number
  • password
  • radio
  • select
  • textarea
  • text
fields[x].data
  • Type: Object

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
  • Type: String

A description of the Form Field.

fields[x].id
  • Type: UUID

The unique Id of the form field.

fields[x].inseertInstant
  • Type: Long

The instant that the Form Field was added to the FusionAuth database.

fields[x].key
  • Type: String

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.preferredLanguages Available since 1.20.0
  • registration.roles Available since 1.20.0
  • registration.timezone Available since 1.20.0
  • registration.username
  • user.birthDate
  • user.email
  • user.firstName
  • user.fullName
  • user.imageUrl Available since 1.20.0
  • user.lastName
  • user.middleName
  • user.mobilePhone
  • user.parentEmail Available since 1.33.0
  • user.password
  • user.phoneNumber Available since 1.59.0
  • user.preferredLanguages Available since 1.20.0
  • user.timezone Available since 1.20.0
  • user.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 named preferences.
  • user.data.preferences['color'] stores the value in the color property of an object named preferences.

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
  • Type: Long

The instant that the form field was last updated in the FusionAuth database.

fields[x].name
  • Type: String

The unique name of the Form Field.

fields[x].confirm
  • Type: Array<String>

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.

Default
red=Red
green=Green
blue=Blue
Spanish
red=Roja
green=Verde
blue=Azul
fields[x].required
  • Type: Boolean

Determines if a value is required to complete the form.

fields[x].type
  • Type: String

The data type FusionAuth uses to store the value. The possible values are:

  • bool: a boolean value, true or false.
  • consent: a value that completes self-consent.
  • date: a date in YYYY-MM-DD format, such as 2025-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 +13035551212 or (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 as 123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since 1.59.0
  • string: a string.
fields[x].validator.enabled
  • Type: Boolean

Determines if user input should be validated.

fields[x].validator.expression
  • Type: String

A regular expression used to validate user input.

Example Response JSON
{
  "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.

Global API Key Authentication
Update the Form Field with the given Id
PUT/api/form/field/{fieldId}
OpenAPI Spec
PATCH/api/form/field/{fieldId}
OpenAPI Spec
Note

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 to null.
  • 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 500 status code.
  • Don't set an array to null. Depending on the field, FusionAuth clears the array or returns a 500 status code.

To remove values from an array, PUT the full object, or set the Content-Type to one of the following media types:

For more information, see The PATCH HTTP Method.

Path Parameters#

fieldId
  • Type: UUID
  • Required

The Id of the Form Field to update.

Request Body#
field.confirm
  • Type: Boolean
  • Optional
  • Defaults to false

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
  • Type: UUID
  • Optional

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
  • Type: String
  • Optional

The form control that displays the Form Field. The possible values are:

  • checkbox
  • number
  • password
  • radio
  • select
  • textarea
  • text

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
  • Type: Object
  • Optional

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
  • Type: String
  • Optional

A description of the Form Field.

field.name
  • Type: String
  • Required

The unique name of the Form Field.

field.options
  • Type: Array<String>
  • Optional

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.

Default
red=Red
green=Green
blue=Blue
Spanish
red=Roja
green=Verde
blue=Azul
field.required
  • Type: Boolean
  • Optional
  • Defaults to false

Determines if a value is required to complete the form.

field.type
  • Type: String
  • Optional

The data type FusionAuth uses to store the value. The possible values are:

  • bool: a boolean value, true or false.
  • consent: a value that completes self-consent.
  • date: a date in YYYY-MM-DD format, such as 2025-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 +13035551212 or (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 as 123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since 1.59.0
  • string: 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
  • Type: Boolean
  • Optional
  • Defaults to false

Determines if user input should be validated.

field.validator.expression
  • Type: String
  • Optional

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.

Example Request JSON
{
  "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.

Response Codes
CodeDescription
200The request succeeded. The response contains a JSON body.
400The 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.
401FusionAuth 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.
404The object you're updating doesn't exist. The response is empty.
500FusionAuth 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
  • Type: Boolean

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
  • Type: UUID

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
  • Type: String

The form control that displays the Form Field. The possible values are:

  • checkbox
  • number
  • password
  • radio
  • select
  • textarea
  • text
field.data
  • Type: Object

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
  • Type: String

A description of the Form Field.

field.id
  • Type: UUID

The unique Id of the form field.

field.insertInstant
  • Type: Long

The instant that the form field was added to the FusionAuth database.

field.key
  • Type: String

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.preferredLanguages Available since 1.20.0
  • registration.roles Available since 1.20.0
  • registration.timezone Available since 1.20.0
  • registration.username
  • user.birthDate
  • user.email
  • user.firstName
  • user.fullName
  • user.imageUrl Available since 1.20.0
  • user.lastName
  • user.middleName
  • user.mobilePhone
  • user.parentEmail Available since 1.33.0
  • user.password
  • user.phoneNumber Available since 1.59.0
  • user.preferredLanguages Available since 1.20.0
  • user.timezone Available since 1.20.0
  • user.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 named preferences.
  • user.data.preferences['color'] stores the value in the color property of an object named preferences.

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
  • Type: Long

The instant that the form field was last updated in the FusionAuth database.

field.name
  • Type: String

The unique name of the Form Field.

field.options
  • Type: Array<String>

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.

Default
red=Red
green=Green
blue=Blue
Spanish
red=Roja
green=Verde
blue=Azul
field.required
  • Type: Boolean

Determines if a value is required to complete the form.

field.type
  • Type: String

The data type FusionAuth uses to store the value. The possible values are:

  • bool: a boolean value, true or false.
  • consent: a value that completes self-consent.
  • date: a date in YYYY-MM-DD format, such as 2025-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 +13035551212 or (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 as 123. To require a stricter format, enable validator and set validator.expression to a regular expression. Available since 1.59.0
  • string: a string.
field.validator.enabled
  • Type: Boolean

Determines if user input should be validated.

field.validator.expression
  • Type: String

A regular expression used to validate user input. Must be a valid regular expression pattern.

See Pattern for examples and syntax.

Example Response JSON
{
  "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.

Global API Key Authentication
Delete a Form Field by Id
DELETE/api/form/field/{fieldId}
OpenAPI Spec

Path Parameters#

fieldId
  • Type: UUID
  • Required

The unique Id of the Form Field to delete.

Response#

This API does not return a JSON response body.

Response Codes
CodeDescription
200The request succeeded.
400The 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.
401FusionAuth 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.
404The object you requested doesn't exist. The response is empty.
500FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty.