Create Users Token
    • Dark
      Light
    • PDF

    Create Users Token

    • Dark
      Light
    • PDF

    Article summary

    Post
    Deprecated
    /api/v1/users.createToken

    As a workspace admin, you can create temporary authentication tokens for users. This is the same type of session authentication token a user gets via login and expires the same way.

    • To be able to use this endpoint, you must add the environment variable CREATE_TOKENS_FOR_USERS=true in your compose file.
    • For SaaS workspaces, contact support to set this variable.
    • Permission required: user-generate-access-token
    • The maximum number of login tokens per user is 50. See this GitHub PR for details.

    For example, if you use Snaps to deploy, set the environment variable as shown below:

    echo "CREATE_TOKENS_FOR_USERS=true" > /var/snap/rocketchat-server/common/create-tokens.env
    
    sudo systemctl restart snap.rocketchat-server.rocketchat-server.service
    

    Changelog

    VersionDescription
    2.1.0Added ENV VAR to be able to use this endpoint (process.env.CREATE_TOKENS_FOR_USERS).
    0.56.0Added
    Header parameters
    X-Auth-Token
    stringRequired

    The authenticated user token.

    ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
    X-User-Id
    stringRequired

    The authenticated user ID.

    ExamplerbAXPnMktTFbNpwtJ
    Body parameters
    Example
    {
      "userId": "BsNr28znDkG8aeo7W"
    }
    object
    userId
    string Required

    The user ID. Alternatively, you can use the username parameter and enter the user name value. (For example, test.user)

    ExampleBsNr28znDkG8aeo7W
    Responses
    200
    Success Example
    {
      "data": {
        "userId": "BsNr28znDkG8aeo7W",
        "authToken": "2jdk99wuSjXPO201XlAks9sjDjAhSJmskAKW301mSuj9Sk"
      },
      "success": true
    }
    Expand All
    object
    data
    object
    userId
    string
    authToken
    string
    success
    boolean
    400

    Bad Request

    Example 1
    {
      "success": false,
      "error": "The required \"userId\" or \"username\" param was not provided [error-user-param-not-provided]",
      "errorType": "error-user-param-not-provided"
    }
    Example 2
    {
      "success": false,
      "error": "Not authorized [error-not-authorized]",
      "errorType": "error-not-authorized",
      "details": {
        "method": "createToken"
      }
    }
    object
    success
    boolean
    error
    string
    errorType
    string
    401

    Unauthorized

    Authorization Error
    {
      "status": "error",
      "message": "You must be logged in to do this."
    }
    object
    status
    string
    message
    string


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.