createAction method
Creates a new action for a form.
Makes a POST /form/:formId/action request.
formId is the unique ID of the form.
action is the ActionModel containing action configuration.
Returns the created ActionModel with server-generated ID.
Example:
final emailAction = ActionModel(
title: 'Send Confirmation Email',
name: 'email',
handler: 'email',
method: ['create'],
settings: {
'to': '{{ data.email }}',
'from': 'noreply@example.com',
'subject': 'Thank you for your submission',
'message': 'We received your submission.',
},
);
final created = await actionService.createAction(formId, emailAction);
Throws DioError on failure.
Implementation
Future<ActionModel> createAction(String formId, ActionModel action) async {
final response = await client.dio.post(
ApiEndpoints.createAction(formId),
data: action.toJson(),
);
return ActionModel.fromJson(response.data as Map<String, dynamic>);
}