A brief introduction in how the FlowAPI works.
state
in the authentication flow, and each state defines available actions
that users can perform.
Your frontend implementation requires a handler function for each possible state. When you receive a new response from the backend, the corresponding handler processes it and renders the UI based on the available actions.
Each action includes:
payload
with additional data specific to that state, such as user information or configuration details needed for UI rendering.
The diagram shows the structure of a flow response:
POST
request:
/login
- User authentication flow/registration
- User registration flow/profile
- User profile management flow/example-flow
endpoint to demonstrate the concepts. Here’s how to initialize and work with any flow:
Initialize a New Flow
POST
request to the the flow URL, /example-flow
in this example.Obtain the Response Body
Generate the Request Object
csrf_token
from the previous state must be included in each request.Execute the Action
POST
request to the href
provided by the action. In this case, the href
is
/example-flow?action=example-action@example-flow-id
.Obtain the Response Body
min_length
and max_length
). While you can implement client-side validation using this metadata, the backend always performs final validation and returns detailed error information when validation fails:
Send Invalid Input Values
Execute the Action
POST
request to the href
provided by the action. Again, the href
would be
/example-flow?action=example-action@example-flow-id
.Obtain the Response Body
status
field has changed to ‘400’ (Bad Request), indicating that the request was invalid. A
global error object has been added with the code
‘form_data_invalid_error’ and the message
‘Form data invalid’. Additionally, the invalid input field now includes an error object with the code
‘value_too_short_error’, and the message
‘The value is too short’.