Post
Deprecated/api/v1/users.createToken
This endpoint has been deprecated and is scheduled for removal in the 8.0.0 release.
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
Version | Description |
---|---|
2.1.0 | Added ENV VAR to be able to use this endpoint (process.env.CREATE_TOKENS_FOR_USERS). |
0.56.0 | Added |
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
}
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