Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

Create an action to remove a user

Create an action to deactivate or delete a user account in the SaaS application.

Before you begin

If you're using an existing ServiceNow® Integration Hub spoke, find out if it has an action to remove a user that you can use instead of creating one.

Role required: flow_designer

About this task

This action is used to reclaim unused subscriptions to reduce your company's software expenses.

Procedure

  1. Navigate to All > Flow Designer > Designer.

  2. Click New and then select Action.

  3. On the form, fill in the fields.

    FieldValue
    NameName of your choice. For example, Remove User.
    Accessible FromAll application scopes.
    CategoryLeave this field empty.
    ProtectionNone.
    ApplicationSpoke app to integrate with the SaaS application. This can be an existing Integration Hub spoke or a new spoke that you created.
    In-Flow AnnotationLeave this field empty.
    DescriptionDescription of your choice.
  4. Click Submit.

  5. In the Inputs section of the Action Outline, click Create Input.

  6. Add a user ID input.

    This is how the action gets the user ID of the user to delete.

    LabelNameTypeMandatory
    User IDuserIDStringYes
  7. If the API that you're working with requires user authentication for requests, add inputs for authentication.

    Examples of common user authentication inputs are admin user id and site name. See the documentation for your chosen API to learn about the requirements for user authentication in your specific case. If the API requires an access token, a Credential Value variable is automatically created later so you don't need to add it as an input.

    When you use your completed action in a subflow, you define what values to pass as these inputs.

  8. Add a SOAP step or REST step to the action outline.

    Your choice will depend on the API for the SaaS application that you're integrating with.

  9. If you selected SOAP, fill in the form as shown.

FieldValue
Connection Details
ConnectionUse Connection Alias.
Connection AliasConnection alias that you created when you created the integration profile. If you have not yet created an integration profile, follow the steps to create a custom integration profile with a connection alias.
EndpointThis value is automatically populated when you select the connection alias. It's set to the Connection URL from the HTTP\(s\) Connection record linked to the alias.
Request Details
Build EnvelopeManually.
SOAP ActionAPI request to delete or deactivate a user. See the documentation for your chosen API to select the appropriate request.
SOAP EnvelopeXML request message to delete a user. See the documentation for your chosen API to learn how to write an XML request message. In general, the header should have your input variables for user authentication as well as the Credential Value variable as the access token. The body should include the request to delete a user and the user ID input. Note: For an example of a SOAP envelope, see the Remove User action used in the Webex Reclaim Subscription subflow.
  1. If you selected REST, fill in the form as shown.

    FieldValue
    Connection Details
    ConnectionUse Connection Alias.
    Connection AliasConnection alias that you created when you created the integration profile. If you have not yet created an integration profile, follow the steps to create a custom integration profile with a connection alias.
    Base URLThis value is automatically populated when you select the connection alias. It's set to the Connection URL from the HTTP(s) Connection record linked to the alias.
    Request Details
    Build RequestManually.
    Resource PathPath to the resource. This value gets appended to the Base URL. See the documentation for the API that you're working with to learn how to construct the resource path.
    HTTP MethodDELETE.
    Query ParametersAdd a parameter for user ID. Set the value as the user ID input.
  2. Add a Script step to the Action Outline for error handling.

    1. For Required Runtime, select Instance.

    2. Create input variables.

      NameValue
      responseResponse Body output from the SOAP or REST step
      status_codeStatus Code output from the SOAP or REST step
    3. Create output variables.

      LabelNameTypeMandatory
      statusstatusChoiceYes
      error_messageerror_messageStringYes
    4. In the Script field, write a script to assign values to the status and error message outputs.

      • Use the status_code input to check if there is an error. Set the status output equal to Error if there is an error and Success if there is no error.
      • In cases where there is an error, use the response input to get information about the kind of error. Set the error message output to a description of the error so that a user can understand what went wrong.
      • In the Action Outline, click Outputs.
  3. Create output variables.

    LabelNameTypeMandatory
    StatusstatusChoiceNo
    Error messageerror_messageStringNo
  4. Assign values to the output variables.

    LabelValue
    Statusstatus output variable from the script step
    Error messageerror_message output variable from the script step
  5. To test your action, click Test.

    1. View the test results and system logs for details about any errors.

      To view system logs, navigate to System Logs > System Log > All.

    2. If your action has errors, make sure that you're using the correct endpoints and that the API request is structured as expected.

    Note: When testing, remember that this action deactivates a user. Test this action in a sub-production environment. If only a production environment is available, you can create fake users for testing.

  6. After verifying that the action is working as expected, click Publish.