---
title: "Automate user management"
slug: "automate-user-management"
abstract: "How to automate user account management using REST API, Scripting API, or Web SDK."
---
# Automate user management

Content Hub tracks and records all user actions, logging activities that can be matched with concurrent events for detailed tracking. This is especially important during onboarding and offboarding, where controlling user permissions is vital. It also supports GDPR compliance by tracking data access and user actions, via [logs that provide a record of activities](https://doc.sitecore.com/ch/en/users/content-hub/user-logs.html) for auditing and security purposes.

> [!note]
> In Sitecore Content Hub, each user is uniquely identified with a username, a password, and a profile. Together with other settings, the profile determines which tasks the user can perform, what data the user can see, and what the user can do with the data.

To make it easier to work with multiple user accounts at the same time, you can automate user account management using any of the following options.

## REST API

You can automate user management [using the REST API](https://doc.sitecore.com/ch/en/developers/cloud-dev/user-1523369.html "User").

- Add a user with username *SampleUser*:
    - **Method:** `POST`
    - **URL:** `https://my-instance.com/api/entitydefinitions/User/entities`
    - **Request body:**

        ```csharp
        {
         "properties":{
          "Username":"SampleUser",
          "UserGroupConfiguration":null,
          "HasToken":null,
          "EmailConfirmationPending":null,
          "LockoutEndDate":null,
          "AccessFailedCount":null,
          "IsRestricted":null,
          "LastLoginDateTime":null,
          "LastPasswordChangeDateTime":null
         },
         "entitydefinition":{
          "href":"https://my-instance.com/api/entitydefinitions/User"
         },
        }
        ```

    - **Example response:**

        ```csharp
        201 created
        Content-Length: content length
        Location : https://my-instance.com/api/entities/10657
        ```

- Delete a user with ID `10657`:
    - **Method:** `DELETE`
    - **URL:** `https://my-instance.com/api/entities/10657`
    - **No request body.**

## Scripting SDK

You can automate user management using the *Users* client [in the Scripting SDK](https://doc.sitecore.com/ch/en/developers/cloud-dev/clients-1523440.html "Clients").

- Add a user:

    ```csharp
    IEntity user = await MClient.EntityFactory.CreateAsync(Constants.User.DefinitionName);
    //Add code to configure the user parameters
    await MClient.Entities.SaveAsync(user);
    ```

- Delete a user:

    ```csharp
    IEntity user = await MClient.Users.GetUserAsync("username");
    await MClient.Entities.DeleteAsync(user.Id);
    ```

## Web SDK

You can automate user management using the *User* client [in the Web Client SDK](https://doc.sitecore.com/ch/en/developers/cloud-dev/web-client-sdk.html "Web Client SDK").

- Add a user:

    ```csharp
    IEntity user = await MClient.EntityFactory.CreateAsync(Constants.User.DefinitionName);
    //Add code to configure the user parameters
    await MClient.Entities.SaveAsync(user);
    ```

- Delete a user:

    ```csharp
    IEntity user = await MClient.Users.GetUserAsync("username");
    await MClient.Entities.DeleteAsync(user.Id);
    ```