Breached password detection is a critical component of secure applications.    Read the white paper

FusionAuth logo
FusionAuth logo
  • Features
    FusionAuth Reactor

    FusionAuth Reactor is a powerful suite of features developed to extend FusionAuth's core functionality.

    • Flexible Architecture   Flexible Architecture
    • Auth the Way You Want It   Auth the Way You Want It
    • Security & Compliance   Security & Compliance
    • Ultimate Password Control   Ultimate Password Control
    • Customizable User Experience   Customizable User Experience
    • Advanced Registration Forms   Advanced Registration Forms
    • Built for Devs   Built for Devs
    • User Management & Reporting   User Management & Reporting
    • Scalability   Scalability
    • Breached Password Detection   Breached Password Detection
    • Connectors   Connectors
    • FusionAuth Reactor   FusionAuth Reactor
  • Pricing
  • Docs
  • Downloads
  • Resources
    FusionAuth Resources
    • Upgrade from SaaS
    • Upgrade from Open Source
    • Upgrade from Home Grown
    • Blog   Blog
    • Forum   Forum
    • Community & Support   Community & Support
    • Customer & Partners   Customers & Partners
    • Video & Podcasts   Videos & Podcasts
    • Tech Guides   Getting Started
  • Expert Advice
    Expert Advice for Developers

    Learn everything you need to know about authentication, authorization, identity, and access management from our team of industry experts.

    • Authentication   Authentication
    • CIAM   CIAM
    • Identity Basics   Identity Basics
    • OAuth   OAuth
    • Security   Security
    • Tokens   Tokens
    • Dev Tools   Dev Tools
  • Account
Navigate to...
  • Welcome
  • Getting Started
  • 5-Minute Setup Guide
  • Reactor
  • Core Concepts
    • Overview
    • Users
    • Roles
    • Groups
    • Registrations
    • Applications
    • Tenants
    • Identity Providers
    • Authentication and Authorization
    • Integration Points
    • Roadmap
  • Installation Guide
    • Overview
    • System Requirements
    • Server Layout
    • Cluster
    • Docker
    • Fast Path
    • Kickstart™
    • Homebrew
    • Packages
    • Database
    • FusionAuth App
    • FusionAuth Search
    • Securing
    • Upgrading
  • APIs
    • Overview
    • Authentication
    • Errors
    • Actioning Users
    • Applications
    • Audit Logs
    • Connectors
      • Overview
      • Generic
      • LDAP
    • Consent
    • Emails
    • Event Logs
    • Families
    • Forms
    • Form Fields
    • Groups
    • Identity Providers
      • Overview
      • Apple
      • Facebook
      • Google
      • HYPR
      • Twitter
      • OpenID Connect
      • SAML v2
      • External JWT
    • Integrations
    • JWT
    • Keys
    • Lambdas
    • Login
    • Passwordless
    • Registrations
    • Reports
    • System
    • Tenants
    • Themes
    • Two Factor
    • Users
    • User Actions
    • User Action Reasons
    • User Comments
    • Webhooks
  • Client Libraries
    • Overview
    • Dart
    • Go
    • Java
    • JavaScript
    • .NET Core
    • Node
    • PHP
    • Python
    • Ruby
    • Typescript
  • Themes
    • Overview
    • Localization
    • Examples
  • Email & Templates
    • Overview
    • Configure Email
    • Email Templates
  • Events & Webhooks
    • Overview
    • Events
    • Writing a Webhook
    • Securing Webhooks
  • Example Apps
    • Overview
    • Go
    • Java
    • JavaScript
    • .NET Core
    • PHP
    • Python
    • Ruby
  • Lambdas
    • Overview
    • Apple Reconcile
    • External JWT Reconcile
    • Facebook Reconcile
    • Google Reconcile
    • HYPR Reconcile
    • JWT Populate
    • LDAP Connector Reconcile
    • OpenID Connect Reconcile
    • SAML v2 Populate
    • SAML v2 Reconcile
    • Twitter Reconcile
  • Identity Providers
    • Overview
    • Apple
    • Facebook
    • Google
    • HYPR
    • Twitter
    • OpenID Connect
      • Overview
      • Azure AD
      • Github
      • Discord
    • SAML v2
      • Overview
      • ADFS
    • External JWT
      • Overview
      • Example
  • Connectors
    • Overview
    • Generic Connector
    • LDAP Connector
    • FusionAuth Connector
  • Integrations
    • Overview
    • CleanSpeak
    • Kafka
    • Twilio
  • OpenID Connect & OAuth 2.0
    • Overview
    • Endpoints
    • Tokens
  • SAML v2 IdP
    • Overview
    • Google
    • Zendesk
  • Plugins
    • Writing a Plugin
    • Password Encryptors
  • Guides
    • Overview
    • Advanced Registration Forms
    • Breached Password Detection
    • Migration
    • Passwordless
    • Securing Your APIs
    • Silent Mode
  • Tutorials
    • Overview
    • Setup Wizard & First Login
    • Register/Login a User
    • Migrate Users
    • JSON Web Tokens
    • Authentication Tokens
    • Start and Stop FusionAuth
    • Switch Search Engines
    • User Account Lockout
    • Two Factor
  • Reference
    • CORS
    • Configuration
    • Data Types
    • Known Limitations
    • Password Encryptors
  • Release Notes
  • Troubleshooting

Form Field APIs

Overview

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

  • Retrieve a Form Field

  • Update a Form Field

  • Delete a Form Field

Create a Form Field

This API is used to create a new Form Field.

Request

Create a Form Field with a randomly generated Id

URI

POST /api/form/field

Create a Form Field with the provided unique Id

URI

POST /api/form/field/{fieldId}

Request Parameters

fieldId [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 [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 [UUID] Optional

The Id of an existing Consent. This field will be required when the type is set to consent.

Using a form field for consent allows you to leverage a FusionAuth consent to allow your end users to self consent to terms and service, end user license agreements, or other opt-in, or opt-out agreements during registration.

field.control [String] Optional defaults to text

The Form Field control. The possible values are:

  • checkbox

  • number

  • password

  • radio

  • select

  • textarea

  • text

The field control can only be set for custom fields, and if not provided the default value will be text. For all managed fields, such as user.firstName, the control will be set by FusionAuth and it may not be modified.

field.data [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 [String] Optional

A description of the Form Field.

field.key [String] Required

The key is the path to the value in the user or registration object.

 

Predefined keys

Predefined keys are typed values managed by FusionAuth. When using a pre-defined key, the field data type and form control are not configurable.

  • 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.password

  • user.preferredLanguages Available since 1.20.0

  • user.timezone Available since 1.20.0

  • user.twoFactorEnabled Available since 1.20.0

  • user.username

 

Custom Keys

When defining a key to store custom data, you may use one of the following prefixes:

  • user.data.

  • registration.data.

For example, in order to store a custom value on the user object to collect the User’s favorite color, set the key value equal to user.data.favoriteColor.

A valid key name must not contain spaces or special characters. An array may be specified by using the array syntax of [0] to indicate the first position in an array. Nested objects may be specified by using the object syntax of ['foo'] to indicate the named property of the object named foo. Consider the following examples:

  • user.data.preferences[0] would store the value in the first position of an array named preferences.

  • user.data.preferences['color'] would store the value in an object named preferences with a key of color.

 

Localization

You may localize the displayed value of this key during registration by adding the key to your theme. For example, if you specify the key value of user.data.favoriteColor this key value be rendered in the UI.

If you were to add the following messages to your theme, the localized form of the value will be shown to the end user. This allows you to provide a human readable field name and optionally localize the field name as well.

user.data.favoriteColor=Favorite color
field.name [String] Required

The unique name of the Form Field.

field.options [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 [Boolean] Optional defaults to false

Determines if a value is required to complete the form.

field.type [String] Optional defaults to string

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

  • bool the value must be a boolean value, true or false

  • consent the value will be used to complete self consent

  • date the value will be stored as a date. The value must be formatted as ISO-8601 or YYY-MM-DD, you may want to use a JavaScript data picker that can convert the selected value to this format.

  • email the value will be expected to be a valid email address

  • number the value will be stored as a numerical value

  • string the value will be stored as a string

All user provided input will be validated to ensure it can be stored in this data type. If the user input cannot be converted a validation error will be shown to the user. When providing options for this control each option must also be compatible with this data type.

When using the consent type, the field consentId is required and must be included in the request.

The data type can only be set for custom fields, and if not provided the default value will be string. For all managed fields, such as user.firstName, the data type will be set by FusionAuth and it may not be modified.

field.validator.enabled [Boolean] Optional defaults to false

Determines if user input should be validated.

field.validator.expression [String] Optional

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

See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html 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.

Table 1. Response Codes
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.

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.

Response Body

field.confirm [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 [UUID]

The Id of an existing Consent. This field will be required when the type is set to consent.

Using a form field for consent allows you to leverage a FusionAuth consent to allow your end users to self consent to terms and service, end user license agreements, or other opt-in, or opt-out agreements during registration.

field.control [String]

The Form Field control. The possible values are:

  • checkbox

  • number

  • password

  • radio

  • select

  • textarea

  • text

field.data [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 [String]

A description of the Form Field.

field.id [UUID]

The unique Id of the form field.

field.insertInstant [Long]

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

field.key [String]

The key is the path to the value in the user or registration object.

 

Predefined keys

Predefined keys are typed values managed by FusionAuth. When using a pre-defined key, the field data type and form control are not configurable.

  • 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.password

  • user.preferredLanguages Available since 1.20.0

  • user.timezone Available since 1.20.0

  • user.twoFactorEnabled Available since 1.20.0

  • user.username

 

Custom Keys

When defining a key to store custom data, you may use one of the following prefixes:

  • user.data.

  • registration.data.

For example, in order to store a custom value on the user object to collect the User’s favorite color, set the key value equal to user.data.favoriteColor.

A valid key name must not contain spaces or special characters. An array may be specified by using the array syntax of [0] to indicate the first position in an array. Nested objects may be specified by using the object syntax of ['foo'] to indicate the named property of the object named foo. Consider the following examples:

  • user.data.preferences[0] would store the value in the first position of an array named preferences.

  • user.data.preferences['color'] would store the value in an object named preferences with a key of color.

 

Localization

You may localize the displayed value of this key during registration by adding the key to your theme. For example, if you specify the key value of user.data.favoriteColor this key value be rendered in the UI.

If you were to add the following messages to your theme, the localized form of the value will be shown to the end user. This allows you to provide a human readable field name and optionally localize the field name as well.

user.data.favoriteColor=Favorite color
field.lastUpdateInstant [Long]

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

field.name [String]

The unique name of the Form Field.

field.options [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 [Boolean]

Determines if a value is required to complete the form.

field.type [String]

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

  • bool the value must be a boolean value, true or false

  • consent the value will be used to complete self consent

  • date the value will be stored as a date. The value must be formatted as ISO-8601 or YYY-MM-DD, you may want to use a JavaScript data picker that can convert the selected value to this format.

  • email the value will be expected to be a valid email address

  • number the value will be stored as a numerical value

  • string the value will be stored as a string

field.validator.enabled [Boolean]

Determines if user input should be validated.

field.validator.expression [String]

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

See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html 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

URI

GET /api/form/field

Retrieve a Form Field by Id

URI

GET /api/form/field/{fieldId}

Request Parameters

fieldId [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.

Table 2. Response Codes
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.

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.

Response Body

field.confirm [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 [UUID]

The Id of an existing Consent. This field will be required when the type is set to consent.

Using a form field for consent allows you to leverage a FusionAuth consent to allow your end users to self consent to terms and service, end user license agreements, or other opt-in, or opt-out agreements during registration.

field.control [String]

The Form Field control. The possible values are:

  • checkbox

  • number

  • password

  • radio

  • select

  • textarea

  • text

field.data [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 [String]

A description of the Form Field.

field.id [UUID]

The unique Id of the form field.

field.insertInstant [Long]

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

field.key [String]

The key is the path to the value in the user or registration object.

 

Predefined keys

Predefined keys are typed values managed by FusionAuth. When using a pre-defined key, the field data type and form control are not configurable.

  • 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.password

  • user.preferredLanguages Available since 1.20.0

  • user.timezone Available since 1.20.0

  • user.twoFactorEnabled Available since 1.20.0

  • user.username

 

Custom Keys

When defining a key to store custom data, you may use one of the following prefixes:

  • user.data.

  • registration.data.

For example, in order to store a custom value on the user object to collect the User’s favorite color, set the key value equal to user.data.favoriteColor.

A valid key name must not contain spaces or special characters. An array may be specified by using the array syntax of [0] to indicate the first position in an array. Nested objects may be specified by using the object syntax of ['foo'] to indicate the named property of the object named foo. Consider the following examples:

  • user.data.preferences[0] would store the value in the first position of an array named preferences.

  • user.data.preferences['color'] would store the value in an object named preferences with a key of color.

 

Localization

You may localize the displayed value of this key during registration by adding the key to your theme. For example, if you specify the key value of user.data.favoriteColor this key value be rendered in the UI.

If you were to add the following messages to your theme, the localized form of the value will be shown to the end user. This allows you to provide a human readable field name and optionally localize the field name as well.

user.data.favoriteColor=Favorite color
field.lastUpdateInstant [Long]

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

field.name [String]

The unique name of the Form Field.

field.options [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 [Boolean]

Determines if a value is required to complete the form.

field.type [String]

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

  • bool the value must be a boolean value, true or false

  • consent the value will be used to complete self consent

  • date the value will be stored as a date. The value must be formatted as ISO-8601 or YYY-MM-DD, you may want to use a JavaScript data picker that can convert the selected value to this format.

  • email the value will be expected to be a valid email address

  • number the value will be stored as a numerical value

  • string the value will be stored as a string

field.validator.enabled [Boolean]

Determines if user input should be validated.

field.validator.expression [String]

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

See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html 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 [Array]

The list of Form Field objects.

fields[x].confirm [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 [UUID]

The Id of an existing Consent. This field will be required when the type is set to consent.

Using a form field for consent allows you to leverage a FusionAuth consent to allow your end users to self consent to terms and service, end user license agreements, or other opt-in, or opt-out agreements during registration.

fields[x].control [String]

The Form Field control. The possible values are:

  • checkbox

  • number

  • password

  • radio

  • select

  • textarea

  • text

fields[x].data [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 [String]

A description of the Form Field.

fields[x].id [UUID]

The unique Id of the form field.

fields[x].insertInstant [Long]

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

fields[x].key [String]

The key is the path to the value in the user or registration object.

 

Predefined keys

Predefined keys are typed values managed by FusionAuth. When using a pre-defined key, the field data type and form control are not configurable.

  • 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.password

  • user.preferredLanguages Available since 1.20.0

  • user.timezone Available since 1.20.0

  • user.twoFactorEnabled Available since 1.20.0

  • user.username

 

Custom Keys

When defining a key to store custom data, you may use one of the following prefixes:

  • user.data.

  • registration.data.

For example, in order to store a custom value on the user object to collect the User’s favorite color, set the key value equal to user.data.favoriteColor.

A valid key name must not contain spaces or special characters. An array may be specified by using the array syntax of [0] to indicate the first position in an array. Nested objects may be specified by using the object syntax of ['foo'] to indicate the named property of the object named foo. Consider the following examples:

  • user.data.preferences[0] would store the value in the first position of an array named preferences.

  • user.data.preferences['color'] would store the value in an object named preferences with a key of color.

 

Localization

You may localize the displayed value of this key during registration by adding the key to your theme. For example, if you specify the key value of user.data.favoriteColor this key value be rendered in the UI.

If you were to add the following messages to your theme, the localized form of the value will be shown to the end user. This allows you to provide a human readable field name and optionally localize the field name as well.

user.data.favoriteColor=Favorite color
fields[x].lastUpdateInstant [Long]

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

fields[x].name [String]

The unique name of the Form Field.

fields[x].options [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 [Boolean]

Determines if a value is required to complete the form.

fields[x].type [String]

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

  • bool the value must be a boolean value, true or false

  • consent the value will be used to complete self consent

  • date the value will be stored as a date. The value must be formatted as ISO-8601 or YYY-MM-DD, you may want to use a JavaScript data picker that can convert the selected value to this format.

  • email the value will be expected to be a valid email address

  • number the value will be stored as a numerical value

  • string the value will be stored as a string

fields[x].validator.enabled [Boolean]

Determines if user input should be validated.

fields[x].validator.expression [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.

Request

Update the Form Field with the given Id

URI

PUT /api/form/field/{fieldId}

PATCH /api/form/field/{fieldId}

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 an Array 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

fieldId [UUID] Required

The Id of the Form Field to update.

Request Body

field.confirm [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 [UUID] Optional

The Id of an existing Consent. This field will be required when the type is set to consent.

Using a form field for consent allows you to leverage a FusionAuth consent to allow your end users to self consent to terms and service, end user license agreements, or other opt-in, or opt-out agreements during registration.

field.control [String] Optional defaults to text

The Form Field control. The possible values are:

  • checkbox

  • number

  • password

  • radio

  • select

  • textarea

  • text

The field control can only be set for custom fields, and if not provided the default value will be text. For all managed fields, such as user.firstName, the control will be set by FusionAuth and it may not be modified.

field.data [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 [String] Optional

A description of the Form Field.

field.key [String] Required

The key is the path to the value in the user or registration object.

 

Predefined keys

Predefined keys are typed values managed by FusionAuth. When using a pre-defined key, the field data type and form control are not configurable.

  • 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.password

  • user.preferredLanguages Available since 1.20.0

  • user.timezone Available since 1.20.0

  • user.twoFactorEnabled Available since 1.20.0

  • user.username

 

Custom Keys

When defining a key to store custom data, you may use one of the following prefixes:

  • user.data.

  • registration.data.

For example, in order to store a custom value on the user object to collect the User’s favorite color, set the key value equal to user.data.favoriteColor.

A valid key name must not contain spaces or special characters. An array may be specified by using the array syntax of [0] to indicate the first position in an array. Nested objects may be specified by using the object syntax of ['foo'] to indicate the named property of the object named foo. Consider the following examples:

  • user.data.preferences[0] would store the value in the first position of an array named preferences.

  • user.data.preferences['color'] would store the value in an object named preferences with a key of color.

 

Localization

You may localize the displayed value of this key during registration by adding the key to your theme. For example, if you specify the key value of user.data.favoriteColor this key value be rendered in the UI.

If you were to add the following messages to your theme, the localized form of the value will be shown to the end user. This allows you to provide a human readable field name and optionally localize the field name as well.

user.data.favoriteColor=Favorite color
field.name [String] Required

The unique name of the Form Field.

field.options [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 [Boolean] Optional defaults to false

Determines if a value is required to complete the form.

field.type [String] Optional defaults to string

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

  • bool the value must be a boolean value, true or false

  • consent the value will be used to complete self consent

  • date the value will be stored as a date. The value must be formatted as ISO-8601 or YYY-MM-DD, you may want to use a JavaScript data picker that can convert the selected value to this format.

  • email the value will be expected to be a valid email address

  • number the value will be stored as a numerical value

  • string the value will be stored as a string

All user provided input will be validated to ensure it can be stored in this data type. If the user input cannot be converted a validation error will be shown to the user. When providing options for this control each option must also be compatible with this data type.

When using the consent type, the field consentId is required and must be included in the request.

The data type can only be set for custom fields, and if not provided the default value will be string. For all managed fields, such as user.firstName, the data type will be set by FusionAuth and it may not be modified.

field.validator.enabled [Boolean] Optional defaults to false

Determines if user input should be validated.

field.validator.expression [String] Optional

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

See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html 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 updated.

Table 3. Response Codes
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.

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.

Response Body

field.confirm [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 [UUID]

The Id of an existing Consent. This field will be required when the type is set to consent.

Using a form field for consent allows you to leverage a FusionAuth consent to allow your end users to self consent to terms and service, end user license agreements, or other opt-in, or opt-out agreements during registration.

field.control [String]

The Form Field control. The possible values are:

  • checkbox

  • number

  • password

  • radio

  • select

  • textarea

  • text

field.data [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 [String]

A description of the Form Field.

field.id [UUID]

The unique Id of the form field.

field.insertInstant [Long]

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

field.key [String]

The key is the path to the value in the user or registration object.

 

Predefined keys

Predefined keys are typed values managed by FusionAuth. When using a pre-defined key, the field data type and form control are not configurable.

  • 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.password

  • user.preferredLanguages Available since 1.20.0

  • user.timezone Available since 1.20.0

  • user.twoFactorEnabled Available since 1.20.0

  • user.username

 

Custom Keys

When defining a key to store custom data, you may use one of the following prefixes:

  • user.data.

  • registration.data.

For example, in order to store a custom value on the user object to collect the User’s favorite color, set the key value equal to user.data.favoriteColor.

A valid key name must not contain spaces or special characters. An array may be specified by using the array syntax of [0] to indicate the first position in an array. Nested objects may be specified by using the object syntax of ['foo'] to indicate the named property of the object named foo. Consider the following examples:

  • user.data.preferences[0] would store the value in the first position of an array named preferences.

  • user.data.preferences['color'] would store the value in an object named preferences with a key of color.

 

Localization

You may localize the displayed value of this key during registration by adding the key to your theme. For example, if you specify the key value of user.data.favoriteColor this key value be rendered in the UI.

If you were to add the following messages to your theme, the localized form of the value will be shown to the end user. This allows you to provide a human readable field name and optionally localize the field name as well.

user.data.favoriteColor=Favorite color
field.lastUpdateInstant [Long]

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

field.name [String]

The unique name of the Form Field.

field.options [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 [Boolean]

Determines if a value is required to complete the form.

field.type [String]

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

  • bool the value must be a boolean value, true or false

  • consent the value will be used to complete self consent

  • date the value will be stored as a date. The value must be formatted as ISO-8601 or YYY-MM-DD, you may want to use a JavaScript data picker that can convert the selected value to this format.

  • email the value will be expected to be a valid email address

  • number the value will be stored as a numerical value

  • string the value will be stored as a string

field.validator.enabled [Boolean]

Determines if user input should be validated.

field.validator.expression [String]

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

See https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html 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 Id

URI

DELETE /api/form/field/{fieldId}

Request Parameters

fieldId [UUID] Required

The unique Id of the Form Field to delete.

Response

This API does not return a JSON response body.

Table 4. Response Codes
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.

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.

Quick Links

  • Download
  • Pricing
  • Enterprise Sales FAQ
  • Contact Us
  • Jobs (come work with us)
  • My Account

Resources

  • Docs
  • Blog
  • Community & Support
  • Upgrade from SaaS
  • Upgrade from Homegrown
  • Upgrade from Open Source

Everything Else

  • Privacy Policy
  • Product Privacy Policy
  • License
  • License FAQ
  • Security (contact, bug bounty, etc)
  • Technical Support

Connect with Us

logo
Subscribe for Updates
We only send dev friendly newsletters. No marketing fluff!
© 2020 FusionAuth