User Management
API

Users API

Introduction

Most of ROQ's features use user-related data like the user`s first name or email. Before you can use these features, they need to be pushed to ROQ Platform. Please refer to the users feature guide for more information and instructions.

Mutations

createUser()

The createUser API is used to synchronize user data to ROQ.

You can find the full API doc of this mutation here (opens in a new tab).

💡

It's important to save the returned user ID in your database because the API needs it for other functionalities.

mutation {
  createUser(
    user: {
      reference: "abc123"
      email: "xyz789"
      phone: "xyz789"
      firstName: "xyz789"
      lastName: "abc123"
      locale: "xyz789"
      timezone: "xyz789"
      isOptedIn: false
      active: true
      tenantId: "7c15cbe7-21f1-4ff7-b742-ec8604682772"
    }
  ) {
    id
  }
}
ParameterTypeDescription
referencestringHere you can set your identifier (e.g. the UUID of the user entity in your database). This way you can filter users by your own identifier.
emailstringEmail of the user
firstNamestringFirst name of the user
lastNamestringLast name of the user
isOptedInbooleanSet to true after the user confirm the email.
activebooleanSet to true if the user is activate and able to login to your application.
localestringThe locale represents the language and the country of the user, e.g. en-US means “english in US”. The locale is used for translations of all UI components as well as for sending notifications.
activebooleanSet to true if the user is activate and able to login to your application.
tenantIdUUIDID of the tenant which you created using the createTenant() API

updateUser()

You can change the synchronized user data using the updateUser() API. The mutation is working the same way as the createUser() mutation described above.

Deactivating a user

To deactivate a user, just use the updateUser mutation as below:

ℹ️

This is only possible from the server side of your application

mutation {
  updateUser(
    id: "4c94b763-9021-499f-8ea3-b01adcdafe57"
    user: { active: false }
  ) {
    id
    active
  }
}

Queries

users()

You can fetch all users using the users() query. All query parameters can be applied here to narrow down the results.

query {
  users {
    data {
      email
    }
  }
}

user()

You can fetch a specific user using the user() query. You need to use the ID which was returned by the createUser() mutation

query {
  user(id: "123") {
    email
  }
}