Skip to content

sendFormSubmission

sendFormSubmission sends form data from a form brick to a React Bricks form configured in the dashboard.

Use it when your project uses Form Management and you need a frontend form to trigger the configured form actions.

const sendFormSubmission = async ({
appId,
appEnv,
token,
formId,
emailAddress,
data,
fetchOptions,
}: SendFormSubmissionParams): Promise<SendFormSubmissionResult>
interface SendFormSubmissionParams {
appId: string
appEnv: string
token: string
formId: string
emailAddress: string
data: Record<string, any>
fetchOptions: types.FetchOptions
}
ParameterDefinition
appIdThe React Bricks app ID.
appEnvThe React Bricks environment.
tokenThe form submission token.
formIdThe ID of the form configured in React Bricks.
emailAddressThe submitter email address.
dataObject containing the submitted form values.
fetchOptionsFetch options for React Bricks API calls. For example, pass { apiPrefix: rbContext.apiPrefix }.
interface SendFormSubmissionResult {
success: boolean
statusCode: number
message: string
}
PropertyDefinition
successtrue when the form submission was accepted.
statusCodeHTTP status code returned by the submission endpoint.
messageMessage describing the result of the form submission.

sendFormSubmission is typically called from a form brick submit handler. The brick should collect field values, call sendFormSubmission, and then show a success or error state to the visitor.

try {
const result = await sendFormSubmission({
appId: rbContext.appId,
appEnv: rbContext.environment,
token,
formId,
emailAddress: email,
data,
fetchOptions: { apiPrefix: rbContext.apiPrefix },
})
if (result.success) {
// Show a success state.
} else {
// Show result.message or a fallback error.
}
} catch (err) {
// Handle network or unexpected errors.
}

The function submits data to the form. The form configuration in the dashboard decides what happens next, such as:

  • saving submitted data
  • sending an email
  • subscribing the visitor to an Email Sending Provider list
  • calling a Zapier webhook