Skip to content

Inviting Users

Admins can invite users to the service by using the inviteUser() method.

When a user is invited, an invitation email is sent to the user with a link to accept the invitation.

In the invitation email, the user will see the login email and randomly generated password, and a link to accept the invitation.

User should click on the link to accept the invitation within 7 days and they will be able to login to the service using the email and password provided in the invitation email.

This example demonstrates using the inviteUser() method to invite a user to the service. When the request is successful, the string "SUCCESS: Invitation has been sent." is returned.

html
<form onsubmit="skapi.inviteUser(event).then(user => console.log(user))">
    <input name="email" placeholder="Email" required/>
    <input type="submit" value="Invite" />
</form>
js
skapi.inviteUser(
    { 
        email: 'user@email'
    },
).then(user => {
    console.log(user);
    /*
    Returns:
    "SUCCESS: Invitation has been sent. (User ID: xxx...)"
    */
});

TIP

The user will be able to login to the service using the email and password provided in the invitation email. It is recommended to change the password after the first login.

For more detailed information on all the parameters and options available with the inviteUser() method,

Resending Invitations

Admins can resend invitations to users who have not accepted the invitation by using the resendInvitation() method.

This example demonstrates using the resendInvitation() method to resend an invitation to a user. When the request is successful, the string "SUCCESS: Invitation has been re-sent." is returned.

html
<form onsubmit="skapi.resendInvitation(event).then(user => console.log(user))">
    <input name="email" placeholder="Email" required/>
    <input type="submit" value="Resend Invitation" />
</form>
js
skapi.resendInvitation(
    { 
        email: 'user@email'
    },
).then(user => {
    console.log(user);
    /*
    Returns:
    "SUCCESS: Invitation has been re-sent. (User ID: xxx...)"
    */
});

Getting Sent Invitations

Admins can get a list of invitations that have been sent by using the getInvitations() method.

This example demonstrates using the getInvitations() method to get a list of invitations that have been sent. When the request is successful, the DatabaseResponse containing the list of invitations is returned.

The email parameter can be used to filter the invitations by email. When the email parameter is set, only invitations with the email starting with the given string will be returned.

html
<form onsubmit="skapi.getInvitations(event).then(invitations => console.log(invitations))">
    <input name="email" placeholder="Search for email"/>
    <input type="submit" value="Get Invitations" />
</form>
js
skapi.getInvitations(
    { 
        email: 'user@email'
    },
).then(invitations => {
    console.log(invitations);
    /*
    Returns:
    {
        list: [
            {
                email: 'user@email',
                ...
            },
            ...
        ],
        ...
    }
    */
});

For more detailed information on all the parameters and options available with the getInvitations() method,

Cancelling Invitations

Admins can cancel invitations that have been sent by using the cancelInvitation() method.

This example demonstrates using the cancelInvitation() method to cancel an invitation that has been sent. When the request is successful, the string "SUCCESS: Invitation has been cancelled." is returned.

html
<form onsubmit="skapi.cancelInvitation(event).then(response => console.log(response))">
    <input name="email" placeholder="Email" required/>
    <input type="submit" value="Cancel Invitation" />
</form>
js
skapi.cancelInvitation(
    { 
        email: 'user@email'
    },
).then(response => {
    console.log(response);
    /*
    Returns:
    "SUCCESS: Invitation has been cancelled."
    */
});