In the Matrix instant messaging protocol, when using the reference implementation of the Matrix server (called synapse), there is an admin API with functions like resetting a password for a user etc..

Accessing this requires an access_token "API key" of a server admin user.

How do I get one?

3 Answers 3


Solution to find your access token:

  1. Log in to the account you want to get the access token for. Click on the name in the top left corner, then "Settings".
  2. Click the "Help & About" tab (left side of the dialog).
  3. Scroll to the bottom and click on <click to reveal> part of Access Token.
  4. Copy your access token to a safe place.
  • 1
    In Element, Help & About was all the way at the bottom of settings. And then Access Token was at the bottom of the Help & About pane, under the Advanced heading.
    – Cobertos
    Commented Aug 26, 2021 at 5:30

These access_token API keys were listed in the Riot web application until not too long ago, somewhere under the account settings. In the newest version, I could no longer find them there.

So instead, I use a technique I found here, which is basically a login procedure done with curl. The server's answer will contain the access_token.

  1. Find out the Matrix user ID and password of a server admin user. The username has to be in the fully qualified form, for example @user:example.com.

  2. Execute the following command on a Linux-based system that has curl installed. Of course, supply the address of you Matrix server for example.com, and also your Matrix user ID and password.

    curl -XPOST \
      -d '{"type":"m.login.password", "user":"<userid>", "password":"<password>"}' \

With the current version of the Matrix protocol, getting an access_token programmatically works slightly different:

To find out the endpoint, e.g., for matrix.org, you need to check a .well-known file for the API URL (Documentation): https://matrix.org/.well-known/matrix/client:

$ curl https://matrix.org/.well-known/matrix/client
    "m.homeserver": {
        "base_url": "https://matrix-client.matrix.org"
    "m.identity_server": {
        "base_url": "https://vector.im"

Afterwards, the homeserver base url can be used for the curl call (See Documentation for the /login endpoint):

$ curl '{"type":"m.login.password", "user":"'$username'", "password":"'$password'"} \ 

  "well_known": { 
    "m.homeserver": {
  • Of course this method only works if the Matrix home server allows the m.login.password Authentication type... matrix.org does, but e.g. gitter.im does not. In that case, you get {"errcode":"M_UNKNOWN","error":"Password login has been disabled."}
    – dregad
    Commented Mar 5, 2023 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.