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#

API Key Authentication
Create a User Action with a randomly generated Id
POST/api/user-action
OpenAPI Spec
API Key Authentication
Create a User Action with the provided unique Id
POST/api/user-action/{userActionId}
OpenAPI Spec

Request Parameters#

userActionIdUUIDoptionalDefaults to secure random UUIDImmutable

The Id to use for the new User Action. If not specified a secure random UUID will be generated.

Request Body#

userAction.cancelEmailTemplateIdUUIDoptional

The Id of the Email Template that is used when User Actions are canceled.

userAction.endEmailTemplateIdUUIDoptional

The Id of the Email Template that is used when User Actions expired automatically (end).

userAction.includeEmailInEventJSONBooleanoptional

Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.

userAction.localizedNamesMap<Locale, String>optional

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.

userAction.modifyEmailTemplateIdUUIDoptional

The Id of the Email Template that is used when User Actions are modified.

userAction.nameStringrequired

The name of this User Action.

userAction.optionsArrayoptional

The list of User Action Options.

userAction.options[x].localizedNamesMap<Locale, String>optional

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.

userAction.options[x].nameStringoptional

The name of this User Action Option.

userAction.preventLoginBooleanoptionalDefaults to false

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.

userAction.sendEndEventBooleanoptionalDefaults to true

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.

userAction.startEmailTemplateIdUUIDoptional

The Id of the Email Template that is used when User Actions are started (created).

userAction.temporalBooleanoptionalDefaults to false

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.

userAction.userEmailingEnabledBooleanoptionalDefaults to false

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.

userAction.userNotificationsEnabledBooleanoptionalDefaults to false

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 Codes
CodeDescription
200The request was successful. The response will contain a JSON body.
400The 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.
401You 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.
500There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.
503The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body.

Response Body#

userAction.activeBoolean

Whether or not this User Action is active.

userAction.cancelEmailTemplateIdUUID

The Id of the Email Template that is used when User Actions are canceled.

userAction.endEmailTemplateIdUUID

The Id of the Email Template that is used when User Actions expired automatically (end).

userAction.idUUID

The Id of the User Action.

userAction.insertInstantLong

The instant when the User Action was created.

userAction.includeEmailInEventJSONBoolean

Whether to include the email information in the JSON that is sent to the Webhook when a user action is taken.

userAction.lastUpdateInstantLong

The instant when the User Action was last updated.

userAction.localizedNamesMap<Locale, String>

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.

userAction.modifyEmailTemplateIdUUID

The Id of the Email Template that is used when User Actions are modified.

userAction.modifyEmailTemplateIdString

The name of this User Action.

userAction.optionsArray

The list of User Action Options.

userAction.options[x].localizedNamesMap<Locale, String>

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.

userAction.options[x].nameString

The name of this User Action Option.

userAction.preventLoginBoolean

Whether or not this User Action will prevent the User from logging in.

userAction.sendEndEventBoolean

Whether or not FusionAuth will send events to any registered Webhooks when this User Action expires.

userAction.startEmailTemplateIdUUID

The Id of the Email Template that is used when User Actions are started (created).

userAction.temporalBoolean

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.

userAction.userEmailingEnabledBoolean

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.

userAction.userNotificationsEnabledBoolean

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
  }
}