---
title: "setUserId Method"
canonical: https://customerscanvas.com/docs/cc6/customerscanvas.iframeapi.runtimeconfiguration.setuserid.htm
archived: true
applies_to:
  - product: "Customer's Canvas On-Premises"
  - product: "Design Editor"
    versions: ["6.15.0", "6.x (may differ)"]
---

**You’re viewing outdated documentation.** [View the latest Customer’s Canvas On-Premises documentation](https://customerscanvas.com/docs/on-premises/).

# setUserId Method

**Applies to:** Customer's Canvas On-Premises; Design Editor 6.15.0, 6.x (may differ) · **Archived documentation**
 
### Callable
 
- setUserId(userId:  string ) :  Promise &lt; void &gt;

- Sets a new user identifier and moves user files to this user's folders.
  
    Before using this method, you must enable the [secure mode](https://customerscanvas.com/docs/cc6/appsettings-config.htm.md) and [update an authentication token](https://customerscanvas.com/docs/cc6/authentication.htm.md) by using the **additionalUserId** parameter with the new user identifier.
 
 - example
     - ```
    <html>
    <head>
        <title>Setting a new user ID</title>
        <!-- The IFrame API script. IMPORTANT! Do not remove or change the ID. -->
        <script id="CcIframeApiScript" type="text/javascript" src="https://example.com/Resources/Generated/IframeApi.js">
        </script>
    </head>
    <body>
        <!-- The iframe to display the editor in. -->
        <iframe id="editorFrame" width="100%" height="800px"></iframe>
        <input type="button" value="Set User ID" onclick="setUserID()" />
    
        <script>
            var editor = null;
    
            document.addEventListener('DOMContentLoaded', async () => {
                // Initialize product with an Invitation template.
                const productDefinition = { surfaces: ["invitation"] };
                // Get the iframe element to display the editor in.
                const iframe = document.getElementById("editorFrame");
                // Load the editor.
                editor = await CustomersCanvas.IframeApi.loadEditor(iframe, productDefinition)
                    // If there was an error thrown when loading the editor.
                    .catch(e => console.log(e));
            });
    
            // Set JohnWood as a new user ID.
            async function setUserID() {
                var userId = await editor.configuration.getUserId();
                // Get an active token for the current user.
                var token = (await (await fetch("https://example.com/api/Auth/Users/" + userId + "/Tokens",
                    {
                        method: "GET",
                        headers: { "X-CustomersCanvasAPIKey": "UniqueSecurityKey" }
                    })).json()).tokens[0].tokenId;
    
                // Update the token for another user.
                await fetch("https://example.com/api/Auth/Tokens/" + token + "?AdditionalUserId=JohnWood", {
                    method: "PUT",
                    headers: { "X-CustomersCanvasAPIKey": "UniqueSecurityKey" }
                });
    
                // Copy user files.
                editor.configuration.setUserId("JohnWood")
                    .catch(e => console.log(e));
            }
        </script>
    </body>
    </html>
    ```

#### Parameters

    - ##### userId: string 
  
        The new user identifier that needs to be set for the product.

#### Returns Promise &lt; void &gt;
