User Action APIs
Overview
This page contains the APIs for managing user actions. This API does not cover actually actioning users. Instead, this is the CRUD API to manage the user action definitions.
If you want to apply an existing user action to a user, see the Actioning Users API and the guide on how to use User Actions.
Here are the APIs:
Create a User Action
This API is used to create an User Action. Specifying an Id on the URI will instruct FusionAuth to use that Id when creating the User Action. Otherwise, FusionAuth will generate an Id for the User Action.
Request
URI
URI
{userActionId}
Request Parameters
The Id to use for the new User Action. If not specified a secure random UUID will be generated.
Request Body
The Id of the Email Template that is used when User Actions are canceled.
The Id of the Email Template that is used when User Actions expired automatically (end).
Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.
A mapping of localized names for this User Action. The key is the Locale and the value is the name of the User Action for that language.
The Id of the Email Template that is used when User Actions are modified.
The name of this User Action.
The list of User Action Options.
A mapping of localized names for this User Action Option. The key is the Locale and the value is the name of the User Action Option for that language.
The name of this User Action Option.
Whether or not this User Action will prevent user login. When this value is set to true
the action must also be marked as a time based action. See temporal
.
Whether or not FusionAuth will send events to any registered Webhooks when this User Action expires.
Prior to version 1.36.7
this value defaulted to false
. The default value was modified to be true
by default to reduce confusion because in most cases when utilizing User Action events, the end event is desired.
The Id of the Email Template that is used when User Actions are started (created).
Whether or not this User Action is time-based (temporal). Time based actions are temporary and once expired the action will no longer be considered active and will not affect the user.
An action that prevents login must be time based.
Time based actions can still be applied to a user for an indefinite amount of time. A time based action is one that may be canceled or modified. A non time-based action may not be modified or canceled.
An example of a non time-based action would be a reward, such as sending a user a coupon. This action cannot be canceled, or modified. When a non time-based action is taken, it is immediately complete and will show up in the user action history.
Whether or not email is enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to email the User.
Whether or not user notifications are enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to “notify users”. What this does is send an additional flag named notifyUser in the event JSON that is sent to any registered Webhooks.
Example Request JSON
{
"userAction": {
"cancelEmailTemplateId": "00000000-0000-0000-0000-000000000001",
"endEmailTemplateId": "00000000-0000-0000-0000-000000000002",
"includeEmailInEventJSON": true,
"localizedNames": {
"de": "Dauerhaft Verbieten"
},
"modifyEmailTemplateId": "00000000-0000-0000-0000-000000000003",
"name": "Permanently Ban",
"options": [
{
"name": "Nicely",
"localizedNames": {
"de": "Schön"
}
},
{
"name": "Meanly",
"localizedNames": {
"de": "Bedeuten"
}
}
],
"preventLogin": true,
"sendEndEvent": true,
"startEmailTemplateId": "00000000-0000-0000-0000-000000000004",
"temporal": true,
"userEmailingEnabled": true,
"userNotificationsEnabled": true
}
}
Response
The response for this API contains the information for the User Action that was created.
Response CodesCode | 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. This status will also be returned if a paid FusionAuth license is required and is not present. |
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. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
Whether or not this User Action is active.
The Id of the Email Template that is used when User Actions are canceled.
The Id of the Email Template that is used when User Actions expired automatically (end).
The Id of the User Action.
The instant when the User Action was created.
Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.
The instant when the User Action was last updated.
A mapping of localized names for this User Action. The key is the Locale and the value is the name of the User Action for that language.
The Id of the Email Template that is used when User Actions are modified.
The name of this User Action.
The list of User Action Options.
A mapping of localized names for this User Action Option. The key is the Locale and the value is the name of the User Action Option for that language.
The name of this User Action Option.
Whether or not this User Action will prevent the User from logging in.
Whether or not FusionAuth will send events to any registered Webhooks when this User Action expires.
The Id of the Email Template that is used when User Actions are started (created).
Whether or not this User Action is time-based (temporal). Time based actions are temporary and once expired the action will no longer be considered active and will not affect the user.
Whether or not email is enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to email the User.
Whether or not user notifications are enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to “notify users”. What is does is send an additional flag named notifyUser in the event JSON that is sent to any registered Webhooks.
Example Response JSON for a Single User Action
{
"userAction": {
"active": true,
"cancelEmailTemplateId": "00000000-0000-0000-0000-000000000001",
"endEmailTemplateId": "00000000-0000-0000-0000-000000000002",
"id": "00000000-0000-0000-0000-000000000042",
"includeEmailInEventJSON": true,
"localizedNames": {
"de": "Dauerhaft Verbieten"
},
"modifyEmailTemplateId": "00000000-0000-0000-0000-000000000003",
"name": "Permanently Ban",
"options": [
{
"name": "Nicely",
"localizedNames": {
"de": "Schön"
}
},
{
"name": "Meanly",
"localizedNames": {
"de": "Bedeuten"
}
}
],
"preventLogin": true,
"sendEndEvent": true,
"startEmailTemplateId": "00000000-0000-0000-0000-000000000004",
"temporal": true,
"userEmailingEnabled": true,
"userNotificationsEnabled": true
}
}
Retrieve a User Action
This API is used to retrieve one or all of the configured User Actions. Specifying an Id on the URI will retrieve a single User Action. Leaving off the Id will retrieve all of the User Actions.
Request
URI
URI
{userActionId}
Request Parameters
The Id of the User Action to retrieve.
Response
The response for this API contains either a single User Action or all of the User Actions. When you call this API with an Id the response will contain just that User Action. When you call this API without an Id the response will contain all of the User Actions. Both response types are defined below along with an example JSON response.
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. This status will also be returned if a paid FusionAuth license is required and is not present. |
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. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
Whether or not this User Action is active.
The Id of the Email Template that is used when User Actions are canceled.
The Id of the Email Template that is used when User Actions expired automatically (end).
The Id of the User Action.
The instant when the User Action was created.
Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.
The instant when the User Action was last updated.
A mapping of localized names for this User Action. The key is the Locale and the value is the name of the User Action for that language.
The Id of the Email Template that is used when User Actions are modified.
The name of this User Action.
The list of User Action Options.
A mapping of localized names for this User Action Option. The key is the Locale and the value is the name of the User Action Option for that language.
The name of this User Action Option.
Whether or not this User Action will prevent the User from logging in.
Whether or not FusionAuth will send events to any registered Webhooks when this User Action expires.
The Id of the Email Template that is used when User Actions are started (created).
Whether or not this User Action is time-based (temporal). Time based actions are temporary and once expired the action will no longer be considered active and will not affect the user.
Whether or not email is enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to email the User.
Whether or not user notifications are enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to “notify users”. What is does is send an additional flag named notifyUser in the event JSON that is sent to any registered Webhooks.
Example Response JSON for a Single User Action
{
"userAction": {
"active": true,
"cancelEmailTemplateId": "00000000-0000-0000-0000-000000000001",
"endEmailTemplateId": "00000000-0000-0000-0000-000000000002",
"id": "00000000-0000-0000-0000-000000000042",
"includeEmailInEventJSON": true,
"localizedNames": {
"de": "Dauerhaft Verbieten"
},
"modifyEmailTemplateId": "00000000-0000-0000-0000-000000000003",
"name": "Permanently Ban",
"options": [
{
"name": "Nicely",
"localizedNames": {
"de": "Schön"
}
},
{
"name": "Meanly",
"localizedNames": {
"de": "Bedeuten"
}
}
],
"preventLogin": true,
"sendEndEvent": true,
"startEmailTemplateId": "00000000-0000-0000-0000-000000000004",
"temporal": true,
"userEmailingEnabled": true,
"userNotificationsEnabled": true
}
}
Response Body
The list of User Action objects.
Whether or not this User Action is active.
The Id of the Email Template that is used when User Actions are canceled.
The Id of the Email Template that is used when User Actions expired automatically (end).
The Id of the User Action.
Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.
A mapping of localized names for this User Action. The key is the Locale and the value is the name of the User Action for that language.
The Id of the Email Template that is used when User Actions are modified.
The name of this User Action.
The list of User Action Options.
A mapping of localized names for this User Action Option. The key is the Locale and the value is the name of the User Action Option for that language.
The name of this User Action Option.
Whether or not this User Action will prevent the User from logging in.
Whether or not FusionAuth will send events to any registered Webhooks when this User Action expires.
The Id of the Email Template that is used when User Actions are started (created).
Whether or not this User Action is time-based (temporal). Time based actions are temporary and once expired the action will no longer be considered active and will not affect the user.
Whether or not email is enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to email the User.
Whether or not user notifications are enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to “notify users”. What is does is send an additional flag named notifyUser in the event JSON that is sent to any registered Webhooks.
Example Response JSON for all the User Actions
{
"userActions": [
{
"active": true,
"cancelEmailTemplateId": "00000000-0000-0000-0000-000000000001",
"endEmailTemplateId": "00000000-0000-0000-0000-000000000002",
"id": "00000000-0000-0000-0000-000000000042",
"includeEmailInEventJSON": true,
"localizedNames": {
"de": "Dauerhaft Verbieten"
},
"modifyEmailTemplateId": "00000000-0000-0000-0000-000000000003",
"name": "Permanently Ban",
"options": [
{
"name": "Nicely",
"localizedNames": {
"de": "Schön"
}
},
{
"name": "Meanly",
"localizedNames": {
"de": "Bedeuten"
}
}
],
"preventLogin": true,
"sendEndEvent": true,
"startEmailTemplateId": "00000000-0000-0000-0000-000000000004",
"temporal": true,
"userEmailingEnabled": true,
"userNotificationsEnabled": true
}
]
}
Update a User Action
This API is used to update an existing User Action.
You must specify all of the properties of the User Action when calling this API with the PUT
HTTP method. When used with PUT
, this API doesn’t merge the existing User Action and your new data. It replaces the existing User Action with your new data.
Utilize the PATCH
HTTP method to send specific changes to merge into an existing User Action.
Request
URI
{userActionId}
URI
{userActionId}
Available since 1.39.0
When using the PATCH method, you can either use the same request body documentation that is provided for the PUT request for backward compatibility. Or you may use either JSON Patch/RFC 6902] or JSON Merge Patch/RFC 7396. See the PATCH
documentation for more information.
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
The Id of the User Action to update.
Request Body
The Id of the Email Template that is used when User Actions are canceled.
The Id of the Email Template that is used when User Actions expired automatically (end).
Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.
A mapping of localized names for this User Action. The key is the Locale and the value is the name of the User Action for that language.
The Id of the Email Template that is used when User Actions are modified.
The name of this User Action.
The list of User Action Options.
A mapping of localized names for this User Action Option. The key is the Locale and the value is the name of the User Action Option for that language.
The name of this User Action Option.
Whether or not this User Action will prevent user login. When this value is set to true
the action must also be marked as a time based action. See temporal
.
Whether or not FusionAuth will send events to any registered Webhooks when this User Action expires.
Prior to version 1.36.7
this value defaulted to false
. The default value was modified to be true
by default to reduce confusion because in most cases when utilizing User Action events, the end event is desired.
The Id of the Email Template that is used when User Actions are started (created).
Whether or not this User Action is time-based (temporal). Time based actions are temporary and once expired the action will no longer be considered active and will not affect the user.
An action that prevents login must be time based.
Time based actions can still be applied to a user for an indefinite amount of time. A time based action is one that may be canceled or modified. A non time-based action may not be modified or canceled.
An example of a non time-based action would be a reward, such as sending a user a coupon. This action cannot be canceled, or modified. When a non time-based action is taken, it is immediately complete and will show up in the user action history.
Whether or not email is enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to email the User.
Whether or not user notifications are enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to “notify users”. What this does is send an additional flag named notifyUser in the event JSON that is sent to any registered Webhooks.
Example Request JSON
{
"userAction": {
"cancelEmailTemplateId": "00000000-0000-0000-0000-000000000001",
"endEmailTemplateId": "00000000-0000-0000-0000-000000000002",
"includeEmailInEventJSON": true,
"localizedNames": {
"de": "Dauerhaft Verbieten"
},
"modifyEmailTemplateId": "00000000-0000-0000-0000-000000000003",
"name": "Permanently Ban",
"options": [
{
"name": "Nicely",
"localizedNames": {
"de": "Schön"
}
},
{
"name": "Meanly",
"localizedNames": {
"de": "Bedeuten"
}
}
],
"preventLogin": true,
"sendEndEvent": true,
"startEmailTemplateId": "00000000-0000-0000-0000-000000000004",
"temporal": true,
"userEmailingEnabled": true,
"userNotificationsEnabled": true
}
}
Response
The response for this API contains the new information for the User Action that was updated.
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. This status will also be returned if a paid FusionAuth license is required and is not present. |
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 update 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. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
Whether or not this User Action is active.
The Id of the Email Template that is used when User Actions are canceled.
The Id of the Email Template that is used when User Actions expired automatically (end).
The Id of the User Action.
The instant when the User Action was created.
Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.
The instant when the User Action was last updated.
A mapping of localized names for this User Action. The key is the Locale and the value is the name of the User Action for that language.
The Id of the Email Template that is used when User Actions are modified.
The name of this User Action.
The list of User Action Options.
A mapping of localized names for this User Action Option. The key is the Locale and the value is the name of the User Action Option for that language.
The name of this User Action Option.
Whether or not this User Action will prevent the User from logging in.
Whether or not FusionAuth will send events to any registered Webhooks when this User Action expires.
The Id of the Email Template that is used when User Actions are started (created).
Whether or not this User Action is time-based (temporal). Time based actions are temporary and once expired the action will no longer be considered active and will not affect the user.
Whether or not email is enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to email the User.
Whether or not user notifications are enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to “notify users”. What is does is send an additional flag named notifyUser in the event JSON that is sent to any registered Webhooks.
Example Response JSON for a Single User Action
{
"userAction": {
"active": true,
"cancelEmailTemplateId": "00000000-0000-0000-0000-000000000001",
"endEmailTemplateId": "00000000-0000-0000-0000-000000000002",
"id": "00000000-0000-0000-0000-000000000042",
"includeEmailInEventJSON": true,
"localizedNames": {
"de": "Dauerhaft Verbieten"
},
"modifyEmailTemplateId": "00000000-0000-0000-0000-000000000003",
"name": "Permanently Ban",
"options": [
{
"name": "Nicely",
"localizedNames": {
"de": "Schön"
}
},
{
"name": "Meanly",
"localizedNames": {
"de": "Bedeuten"
}
}
],
"preventLogin": true,
"sendEndEvent": true,
"startEmailTemplateId": "00000000-0000-0000-0000-000000000004",
"temporal": true,
"userEmailingEnabled": true,
"userNotificationsEnabled": true
}
}
Delete a User Action
This API is used to delete an User Action. You must specify the Id of the User Action on the URI.
Request
URI
{userActionId}
URI
{userActionId}&hardDelete=true
Request Parameters
The Id of the User Action to delete.
Whether or not the User Action is soft or hard deleted.
Response
This API does not return a JSON response body.
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. This status will also be returned if a paid FusionAuth license is required and is not present. |
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. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Reactivate a User Action
This API is used to reactivate an inactive User Action. You must specify the Id of the Application on the URI.
Request
URI
{userActionId}?reactivate=true
Request Parameters
The Id of the User Action to reactivate.
Response
The response for this API contains the information for the User Action that was reactivated.
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. This status will also be returned if a paid FusionAuth license is required and is not present. |
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. |
503 | The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body. |
Response Body
Whether or not this User Action is active.
The Id of the Email Template that is used when User Actions are canceled.
The Id of the Email Template that is used when User Actions expired automatically (end).
The Id of the User Action.
The instant when the User Action was created.
Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.
The instant when the User Action was last updated.
A mapping of localized names for this User Action. The key is the Locale and the value is the name of the User Action for that language.
The Id of the Email Template that is used when User Actions are modified.
The name of this User Action.
The list of User Action Options.
A mapping of localized names for this User Action Option. The key is the Locale and the value is the name of the User Action Option for that language.
The name of this User Action Option.
Whether or not this User Action will prevent the User from logging in.
Whether or not FusionAuth will send events to any registered Webhooks when this User Action expires.
The Id of the Email Template that is used when User Actions are started (created).
Whether or not this User Action is time-based (temporal). Time based actions are temporary and once expired the action will no longer be considered active and will not affect the user.
Whether or not email is enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to email the User.
Whether or not user notifications are enabled for this User Action. If this is true, a checkbox will appear in the FusionAuth UI for this User Action that allows admins to specify that they want to “notify users”. What is does is send an additional flag named notifyUser in the event JSON that is sent to any registered Webhooks.
Example Response JSON for a Single User Action
{
"userAction": {
"active": true,
"cancelEmailTemplateId": "00000000-0000-0000-0000-000000000001",
"endEmailTemplateId": "00000000-0000-0000-0000-000000000002",
"id": "00000000-0000-0000-0000-000000000042",
"includeEmailInEventJSON": true,
"localizedNames": {
"de": "Dauerhaft Verbieten"
},
"modifyEmailTemplateId": "00000000-0000-0000-0000-000000000003",
"name": "Permanently Ban",
"options": [
{
"name": "Nicely",
"localizedNames": {
"de": "Schön"
}
},
{
"name": "Meanly",
"localizedNames": {
"de": "Bedeuten"
}
}
],
"preventLogin": true,
"sendEndEvent": true,
"startEmailTemplateId": "00000000-0000-0000-0000-000000000004",
"temporal": true,
"userEmailingEnabled": true,
"userNotificationsEnabled": true
}
}