Form API
On this page
This feature requires at least a Starter plan.
A FusionAuth Form is a customizable object that contains one-to-many ordered steps. Each step is comprised of one or more Form Fields.
The following APIs are provided to manage Forms.
Create a Form#
This API is used to create a new Form.
Request#
Create a Form with either a randomly generated Id or one you provide on the URI.
OpenAPI Spec
OpenAPI Spec
Path Parameters#
formIdThe Id to use for the new Form. If not specified a secure random UUID will be generated.
Request Body#
form.data An object that can hold any information about the Form that should be persisted.
form.name The unique name of the Form.
form.steps An ordered list of objects containing one or more Form Fields. A Form must have at least one step defined.
Steps manifest in two different ways. When the form type is adminRegistration or adminUser steps will be rendered as sections because there are no multi-step forms within the Admin UI. For registration each step will be considered a step within a multi-step form.
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-form-section}1 this key value be rendered in the UI, where 1 specifies the section number to adjust the value of.
Adding the following message to your theme will cause the first section of the User add or edit form to be rendered as "Optionally name me!". This feature allows you to customize and optionally localize each section heading within the User form.
{user-form-section}1=Optionally name me!
You may optionally provide a specific label per tenant by prefixing the value the with the tenant Id as follows:
[cbeaf8fe-f4a7-4a27-9f77-c609f1b01856]{user-form-section}2=Tenant specific label for section 2
You may also optionally provide a specific label per application for a registration form by prefixing the value the with the application Id as follows:
[cfb5fab7-b3b6-41bb-adfa-d23ac83a96e5]{registration-form-section}2=Application specific label for section 2
form.steps[x].fields An ordered list of Form Field Ids assigned to this step.
form.steps[x].type The type of step being created.
The possible values are:
collectData- Standard form step type that collects fields from the user.verifyEmail- Perform verification on user.email before user creation.verifyPhoneNumber- Perform verification on user.phoneNumber before user creation.
verifyEmailandverifyPhoneNumberare only valid when form.type isregistration.- When using the
verify*step types, if the form includes auser.passwordfield, that field must be AFTER the lastverify*step. - If
verifyEmailis used, user.email must be included on a step prior to theverifyEmailstep. - If
verifyPhoneNumberis used, user.phoneNumber must be included on a step prior to theverifyPhoneNumberstep.
form.type The type of form being created, a form type cannot be changed after the form has been created. This type will be used to identify how this form can be utilized by FusionAuth.
adminRegistration- This form can be used to customize the add and edit User Registration form in the FusionAuth Admin UI. Available since1.20.0adminUser- This form can be used to customize the add and edit User form in the FusionAuth Admin UI. Available since1.20.0registration- This form can be used for self service registration.selfServiceUser- This form can be used for Self Service Account Management. Available since1.26.0
Prior to version 1.20.0, the default form type was registration.
{
"form": {
"data": {
"description": "This form customizes the registration experience."
},
"name": "Custom Registration Form",
"steps": [
{
"fields": [
"68259c40-0b4e-4245-8956-7e5af0959c2b",
"00f24e72-52e2-4f55-8ea1-6a06bfe10df5"
],
"type": "collectData"
},
{
"fields": [],
"type": "verifyEmail"
},
{
"fields": [
"11a5b1b8-7ef5-476f-af7d-69e19796fa8b"
]
}
]
}
}Response#
The response for this API contains the Form 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#
form.data An object that can hold any information about the Form that should be persisted.
form.id The unique Id of the Form.
form.insertInstant The instant that the Form was added to the FusionAuth database.
form.lastUpdateInstant The instant that the Form was last updated in the FusionAuth database.
form.name The unique name of the Form.
form.steps An ordered list of objects containing one or more Form Fields.
form.steps[x].fields An ordered list of Form Field Ids assigned to this step.
form.steps[x].type The type of step being created.
collectData- Standard form step type that collects fields from the user.verifyEmail- Perform verification on user.email before user creation.verifyPhoneNumber- Perform verification on user.phoneNumber before user creation.
form.steps[x].type The type of step being created.
The possible values are:
collectData- Standard form step type that collects fields from the user.verifyEmail- Perform verification on user.email before user creation.verifyPhoneNumber- Perform verification on user.phoneNumber before user creation.
form.type The form type.
The possible values are:
adminRegistration- This form can be used to customize the add and edit User Registration form in the FusionAuth Admin UI. Available since1.20.0adminUser- This form can be used to customize the add and edit User form in the FusionAuth Admin UI. Available since1.20.0registration- This form can be used for self service registration.selfServiceUser- This form can be used for Self Service Account Management. Available since1.26.0
{
"form": {
"data": {
"description": "This form customizes the registration experience."
},
"id": "1188edfc-cef3-4555-910e-181ddf6153c0",
"insertInstant": 1562189072183,
"lastUpdateInstant": 1562189072183,
"name": "Custom Registration Form",
"steps": [
{
"fields": [
"68259c40-0b4e-4245-8956-7e5af0959c2b",
"00f24e72-52e2-4f55-8ea1-6a06bfe10df5"
]
},
{
"fields": [
"11a5b1b8-7ef5-476f-af7d-69e19796fa8b"
]
}
],
"type": "registration"
}
}Retrieve a Form#
This API is used to retrieve a single Form by unique Id or all of the configured Forms.
Request#
Retrieve all of the Forms, or provide an Id to retrieve a single Form.
OpenAPI Spec
OpenAPI Spec
Path Parameters#
formIdThe unique Id of the Form to retrieve.
Response#
The response for this API contains either a single Form or all of the Forms. When you call this API with an Id, the response will contain a single Form. When you call this API without an Id, the response will contain all of the Forms. 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#
form.data An object that can hold any information about the Form that should be persisted.
form.id The unique Id of the Form.
form.insertInstant The instant that the Form was added to the FusionAuth database.
form.lastUpdateInstant The instant that the Form was last updated in the FusionAuth database.
form.name The unique name of the Form.
form.steps An ordered list of objects containing one or more Form Fields.
form.steps[x].fields An ordered list of Form Field Ids assigned to this step.
form.steps[x].type The type of step being created.
collectData- Standard form step type that collects fields from the user.verifyEmail- Perform verification on user.email before user creation.verifyPhoneNumber- Perform verification on user.phoneNumber before user creation.
form.steps[x].type The type of step being created.
The possible values are:
collectData- Standard form step type that collects fields from the user.verifyEmail- Perform verification on user.email before user creation.verifyPhoneNumber- Perform verification on user.phoneNumber before user creation.
form.type The form type.
The possible values are:
adminRegistration- This form can be used to customize the add and edit User Registration form in the FusionAuth Admin UI. Available since1.20.0adminUser- This form can be used to customize the add and edit User form in the FusionAuth Admin UI. Available since1.20.0registration- This form can be used for self service registration.selfServiceUser- This form can be used for Self Service Account Management. Available since1.26.0
{
"form": {
"data": {
"description": "This form customizes the registration experience."
},
"id": "1188edfc-cef3-4555-910e-181ddf6153c0",
"insertInstant": 1562189072183,
"lastUpdateInstant": 1562189072183,
"name": "Custom Registration Form",
"steps": [
{
"fields": [
"68259c40-0b4e-4245-8956-7e5af0959c2b",
"00f24e72-52e2-4f55-8ea1-6a06bfe10df5"
]
},
{
"fields": [
"11a5b1b8-7ef5-476f-af7d-69e19796fa8b"
]
}
],
"type": "registration"
}
}Response Body#
formsThe list of Form objects.
forms[x].data An object that can hold any information about the Form that should be persisted.
forms[x].id The unique Id of the Form.
forms[x].insertInstant The instant that the Form was added to the FusionAuth database.
forms[x].lastUpdateInstant The instant that the Form was last updated in the FusionAuth database.
forms[x].name The unique name of the Form.
forms[x].steps An ordered list of objects containing one or more Form Fields.
forms[x].steps[x].fields An ordered list of Form Field Id's assigned to this step.
forms[x].type The Form type. The possible values are:
adminRegistration- This form can be used to customize the add and edit User Registration form in the FusionAuth UI. Available since1.20.0adminUser- This form can be used to customize the add and edit User form in the FusionAuth UI. Available since1.20.0registration- This form can be used for self service registration.selfServiceUser- This form can be used for Self Service Account Management. Available since1.26.0
{
"forms": [
{
"data": {
"description": "This form customizes the registration experience."
},
"id": "1188edfc-cef3-4555-910e-181ddf6153c0",
"insertInstant": 1562189072183,
"lastUpdateInstant": 1562189072183,
"name": "Custom Registration Form",
"steps": [
{
"fields": [
"68259c40-0b4e-4245-8956-7e5af0959c2b",
"00f24e72-52e2-4f55-8ea1-6a06bfe10df5"
]
},
{
"fields": [
"11a5b1b8-7ef5-476f-af7d-69e19796fa8b"
]
}
],
"type": "registration"
}
]
}Update a Form#
This API is used to update an existing Form.
You must specify all of the properties of the Form when calling this API with the PUT HTTP method. When used with PUT, this API doesn't merge the existing Form and your new data. It replaces the existing Form with your new data.
Utilize the PATCH HTTP method to send specific changes to merge into an existing Form.
Request#
Send the full Form 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.
On this API,PATCH adds each object in form.steps as a new step. To change the fields of an existing step, PUT the full Form.Path Parameters#
formIdThe Id of the Form to update.
Request Body#
form.data An object that can hold any information about the Form that should be persisted.
form.name The unique name of the Form.
form.steps An ordered list of objects containing one or more Form Fields. A Form must have at least one step defined.
Steps manifest in two different ways. When the form type is adminRegistration or adminUser steps will be rendered as sections because there are no multi-step forms within the Admin UI. For registration each step will be considered a step within a multi-step form.
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-form-section}1 this key value be rendered in the UI, where 1 specifies the section number to adjust the value of.
Adding the following message to your theme will cause the first section of the User add or edit form to be rendered as "Optionally name me!". This feature allows you to customize and optionally localize each section heading within the User form.
{user-form-section}1=Optionally name me!
You may optionally provide a specific label per tenant by prefixing the value the with the tenant Id as follows:
[cbeaf8fe-f4a7-4a27-9f77-c609f1b01856]{user-form-section}2=Tenant specific label for section 2
You may also optionally provide a specific label per application for a registration form by prefixing the value the with the application Id as follows:
[cfb5fab7-b3b6-41bb-adfa-d23ac83a96e5]{registration-form-section}2=Application specific label for section 2
form.steps[x].fields An ordered list of Form Field Ids assigned to this step.
form.steps[x].type The type of step being created.
The possible values are:
collectData- Standard form step type that collects fields from the user.verifyEmail- Perform verification on user.email before user creation.verifyPhoneNumber- Perform verification on user.phoneNumber before user creation.
verifyEmailandverifyPhoneNumberare only valid when form.type isregistration.- When using the
verify*step types, if the form includes auser.passwordfield, that field must be AFTER the lastverify*step. - If
verifyEmailis used, user.email must be included on a step prior to theverifyEmailstep. - If
verifyPhoneNumberis used, user.phoneNumber must be included on a step prior to theverifyPhoneNumberstep.
form.type The type of form being created, a form type cannot be changed after the form has been created. This type will be used to identify how this form can be utilized by FusionAuth.
adminRegistration- This form can be used to customize the add and edit User Registration form in the FusionAuth Admin UI. Available since1.20.0adminUser- This form can be used to customize the add and edit User form in the FusionAuth Admin UI. Available since1.20.0registration- This form can be used for self service registration.selfServiceUser- This form can be used for Self Service Account Management. Available since1.26.0
Prior to version 1.20.0, the default form type was registration.
{
"form": {
"data": {
"description": "This form customizes the registration experience."
},
"name": "Custom Registration Form",
"steps": [
{
"fields": [
"68259c40-0b4e-4245-8956-7e5af0959c2b",
"00f24e72-52e2-4f55-8ea1-6a06bfe10df5"
],
"type": "collectData"
},
{
"fields": [],
"type": "verifyEmail"
},
{
"fields": [
"11a5b1b8-7ef5-476f-af7d-69e19796fa8b"
]
}
]
}
}Response#
The response for this API contains the Form 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#
form.data An object that can hold any information about the Form that should be persisted.
form.id The unique Id of the Form.
form.insertInstant The instant that the Form was added to the FusionAuth database.
form.lastUpdateInstant The instant that the Form was last updated in the FusionAuth database.
form.name The unique name of the Form.
form.steps An ordered list of objects containing one or more Form Fields.
form.steps[x].fields An ordered list of Form Field Ids assigned to this step.
form.steps[x].type The type of step being created.
collectData- Standard form step type that collects fields from the user.verifyEmail- Perform verification on user.email before user creation.verifyPhoneNumber- Perform verification on user.phoneNumber before user creation.
form.steps[x].type The type of step being created.
The possible values are:
collectData- Standard form step type that collects fields from the user.verifyEmail- Perform verification on user.email before user creation.verifyPhoneNumber- Perform verification on user.phoneNumber before user creation.
form.type The form type.
The possible values are:
adminRegistration- This form can be used to customize the add and edit User Registration form in the FusionAuth Admin UI. Available since1.20.0adminUser- This form can be used to customize the add and edit User form in the FusionAuth Admin UI. Available since1.20.0registration- This form can be used for self service registration.selfServiceUser- This form can be used for Self Service Account Management. Available since1.26.0
{
"form": {
"data": {
"description": "This form customizes the registration experience."
},
"id": "1188edfc-cef3-4555-910e-181ddf6153c0",
"insertInstant": 1562189072183,
"lastUpdateInstant": 1562189072183,
"name": "Custom Registration Form",
"steps": [
{
"fields": [
"68259c40-0b4e-4245-8956-7e5af0959c2b",
"00f24e72-52e2-4f55-8ea1-6a06bfe10df5"
]
},
{
"fields": [
"11a5b1b8-7ef5-476f-af7d-69e19796fa8b"
]
}
],
"type": "registration"
}
}Delete a Form#
This API is used to permanently delete a Form. A form cannot be deleted when in use by one or more applications.
Request#
Delete a Form by its Id.
OpenAPI Spec
Path Parameters#
formIdThe unique Id of the Form 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 form fields.
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.