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.
roqClient.asSuperAdmin().createUser({
user: {
reference: 'abc123',
email: 'xyz789',
phone: 'xyz789',
firstName: 'xyz789',
lastName: 'abc123',
locale: 'xyz789',
timezone: 'xyz789',
isOptedIn: false,
active: true
},
});
Parameter | Type | Description |
---|---|---|
reference | string | Here 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. |
email | string | Email of the user |
firstName | string | First name of the user |
lastName | string | Last name of the user |
isOptedIn | boolean | Set to true after the user confirm the email. |
active | boolean | Set to true if the user is activate and able to login to your application. |
locale | string | The 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. |
active | boolean | Set to true if the user is activate and able to login to your application. |
tenantId | UUID | ID 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
roqClient.asSuperAdmin().updateUser({
id: "4c94b763-9021-499f-8ea3-b01adcdafe57"
user: {
active: false
},
});
Queries
users()
You can fetch all users using the users()
query. All query parameters can be applied
here to narrow down the results.
roqClient.asSuperAdmin().users();
user()
You can fetch a specific user using the user() query. You need to use the ID which was returned by the createUser()
mutation
roqClient.asSuperAdmin().user({ id: '123' });