Update a User Action API

On this page

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#

Send the full User Action with your changes applied.

API Key Authentication
Update a User Action by Id
PUT/api/user-action/{userActionId}
OpenAPI Spec
PATCH/api/user-action/{userActionId}
OpenAPI Spec
Note

For backward compatibility, a PATCH request with a Content-Type of application/json accepts the same body as the PUT request. FusionAuth merges the request into the existing object:

  • FusionAuth keeps every field that the request leaves out, so send only the fields you want to change.
  • FusionAuth merges a map, such as data, by key. To remove a key, set the key to null.
  • FusionAuth appends the values in a request array to the existing array, unless this API documents otherwise. An empty array leaves the existing array unchanged, so you can't remove values from an appending array.
  • FusionAuth adds each object in an array of objects as a new element. FusionAuth doesn't match the object to an existing element by Id or by position.
  • Don't send a value that an array of Ids already contains, such as a key Id or a Tenant Id. Some of these arrays then return a 500 status code.
  • Don't set an array to null. Depending on the field, FusionAuth clears the array or returns a 500 status code.

To remove values from an array, PUT the full object, or set the Content-Type to one of the following media types:

For more information, see The PATCH HTTP Method.

Path Parameters#

userActionId
  • Type: UUID
  • Required

The Id of the User Action to update.

Request Body#

userAction.cancelEmailTemplateId
  • Type: UUID
  • Optional

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

userAction.endEmailTemplateId
  • Type: UUID
  • Optional

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

userAction.includeEmailInEventJSON
  • Type: Boolean
  • Optional

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

userAction.localizedNames
  • Type: Map<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.modifyEmailTemplateId
  • Type: UUID
  • Optional

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

userAction.name
  • Type: String
  • Required

The name of this User Action.

userAction.options
  • Type: Array
  • Optional

The list of User Action Options.

userAction.options[x].localizedNames
  • Type: Map<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].name
  • Type: String
  • Optional

The name of this User Action Option.

userAction.preventLogin
  • Type: Boolean
  • Optional
  • Defaults 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.sendEndEvent
  • Type: Boolean
  • Optional
  • Defaults 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.startEmailTemplateId
  • Type: UUID
  • Optional

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

userAction.temporal
  • Type: Boolean
  • Optional
  • Defaults 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.userEmailingEnabled
  • Type: Boolean
  • Optional
  • Defaults 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.userNotificationsEnabled
  • Type: Boolean
  • Optional
  • Defaults 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 new information for the User Action that was updated.

Response Codes
CodeDescription
200The request succeeded. The response contains a JSON body.
400The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present.
401FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses.
404The object you're updating doesn't exist. The response is empty.
500FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes.
503The search index is unavailable or returned an error, so FusionAuth can't complete the request. The response contains a JSON body.

Response Body#

userAction.active
  • Type: Boolean

Whether or not this User Action is active.

userAction.cancelEmailTemplateId
  • Type: UUID

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

userAction.endEmailTemplateId
  • Type: UUID

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

userAction.id
  • Type: UUID

The Id of the User Action.

userAction.insertInstant
  • Type: Long

The instant when the User Action was created.

userAction.includeEmailInEventJSON
  • Type: Boolean

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

userAction.lastUpdateInstant
  • Type: Long

The instant when the User Action was last updated.

userAction.localizedNames
  • Type: Map<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.modifyEmailTemplateId
  • Type: UUID

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

userAction.modifyEmailTemplateId
  • Type: String

The name of this User Action.

userAction.options
  • Type: Array

The list of User Action Options.

userAction.options[x].localizedNames
  • Type: Map<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].name
  • Type: String

The name of this User Action Option.

userAction.preventLogin
  • Type: Boolean

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

userAction.sendEndEvent
  • Type: Boolean

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

userAction.startEmailTemplateId
  • Type: UUID

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

userAction.temporal
  • Type: Boolean

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.userEmailingEnabled
  • Type: Boolean

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.userNotificationsEnabled
  • Type: Boolean

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