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:

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:

mutation{
  initSession(username: "demo-user",password:"demo-user-password")
  {
    sessionToken
    refreshToken
  }
}