.. _how-to-register-an-user: How to Register a User and Log in --------------------------------- In order to have the rights to register a new user account, you need a pre-shared key (PSK), which can be created for your client in our be.ENERGISED backend. After you have received a PSK, you can use this as an authorization token to register a user account via the `registerContact`_ API call. Here is an example of the minimum payload for registering a contact: .. code-block:: javascript mutation registerContact { registerContact( contactProfile: { name: "Demo User" email: "demo-user" password: "demo-user-password" } ) { profile { id name email } } } After a successful user registration, you are able to log in via the `initSession`_ API call. As a result of the login, you gain a session token that has to be used as the authorization token for other API requests. Here is an example for this login process: .. code-block:: javascript mutation{ initSession(username: "demo-user",password:"demo-user-password") { sessionToken refreshToken } } .. _registerContact: https://graphql.docs.htb.services/api-reference/#mutation-registerContact .. _initSession: https://graphql.docs.htb.services/api-reference/#mutation-initSession