User Invites
API

User Invites API

Introduction

The user invite API is used directly by the UI components (e.g. The <UserInvitesTable/>). However, you can also use it programmatically.

Mutations

sendUserInvites()

The sendUserInvites API is used to invite users and automatically also create a user invite. You can find the full API doc of this mutation here (opens in a new tab).

const status = await roqClient.asUser('530c9a92-71c5-4dce-a6e3-c638c2d0b1bc').sendUserInvites({
	userInvites: {
		tenantId: 'ee764883-f2c3-4486-9de6-070345e350af',
		userInvites: [{
			createdByUserId: '530c9a92-71c5-4dce-a6e3-c638c2d0b1bc',
			email: "wick.john@gmail.com",
			locale: "en-US",
			roles: ["content-creator"]
		}]
	}
})
ParameterTypeDescription
userInvitesobjectUser invites data
userInvites:tenantIduuidID of the tenant (organization)
userInvites:userInvitesarrayArray of invitees
userInvites:userInvites:emailstringEmail of the invitee
userInvites:userInvites:firstNamestringFirst name of the invitee
userInvites:userInvites:lastNamestringLast name of the invitee
userInvites:userInvites:localestringLanguage of the invitee (used for the email)
userInvites:userInvites:dataarrayAdditional custom data
userInvites:userInvites:createdByUserIduuidID of the inviting user
userInvites:userInvites:rolesarrayArray of IDs of roles for the invitee

resendUserInvite()

The resendUserInvite API will resend the invitation to the invitee. The full API documentation for this method is here (opens in a new tab).

const userInviteModel = await roqClient.asUser("530c9a92-71c5-4dce-a6e3-c638c2d0b1bc").resendUserInvite("d1459a92-71c5-4edc-a6a1-c638c2d0d34c")
ParameterTypeDescription
iduuidThe invitee ID

cancelUserInvite()

The cancelUserInvite API will cancel a user invitation. The documentation for this API is here (opens in a new tab).

const userInviteModel = await roqClient.asUser("530c9a92-71c5-4dce-a6e3-c638c2d0b1bc").cancelUserInvite("d1459a92-71c5-4edc-a6a1-c638c2d0d34c")
ParameterTypeDescription
iduuidThe invitee ID

acceptUserInvite()

The acceptUserInvite API is the ROQ's validation if the invitee accepts the invitation. For the full API documentation, please look into this link (opens in a new tab).

const acceptInviteData = await roqClient.asSuperAdmin().acceptUserInvite({
	acceptUserInvite: {
		token: "oneTimeToken"
	}
})
ParameterTypeDescription
tokenstringThe invitee accept token

updateUserInvite()

The updateUserInvite() (opens in a new tab) method API will update the data for the specific invitee ID.

const updateUserInvite = await roqClient.asSuperAdmin().updateUserInvite({
  id: "3f6f6373-f05e-45be-b0bf-e03dea172881",
  userInvite: {
     acceptedByUserId: null,
     firstName: "Fast",
     lastName: "Ninja",
     locale: "id-ID",
     data: { address: "Brosot ST." }
  }
})
ParameterTypeDescription
iduuidThe invitee ID
userInviteobjectThe user invitee data. Please look into this (opens in a new tab) API documentation for input fields detail.

Queries

You can fetch invites using the userInvites and userInvite queries.

userInvites()

You can get all the user invites list using this userInvites() (opens in a new tab) method API. You can limit the results and search the invitee by email, name, or keywords, etc.

const userInvitesData = await roqClient.asSuperAdmin().userInvites({
  limit: 10
})
ParameterTypeDescription
limitintegerLimit the results
searchobjectSearch parameter. Look into this here (opens in a new tab)
filterobjectFilter parameter. Look into this here (opens in a new tab)

userInvite()

Get the data of the invitee. The documentation for the userInvite API is in the GraphQL API reference (opens in a new tab).

const userInvite = await roqClient.asSuperAdmin().userInvite({
	id: "78f665fb-61ab-4931-a565-3136e6d01553"
})
ParameterTypeDescription
iduuidThe invitee ID