Invite

How to invite a user to an app through the Cosync REST API

Invite a handle into the app. This function is used by a user who is logged into the app to invite another outside user into the app. The login used to restrict which users are allowed to invite other users into the app, should be implemented by the app itself. The header of this function call must include the access-token of the logged in user who does the invite. The inviting user can also pass a JSON string of metaData that is passed to the invited user at the time or registration into the app. This meta data gets set in the invited user JWT meta data section. This meta data will combine with the users meta data at the time of registration. The call must include the senderUserId, which is the MongoDB Realm user id of the sending user - this is different from the email handle of the sending user.

This function will cause the CosyncJWT service to send a six digit verification code to the email/phone handle for verification.

URL
    /api/appuser/invite
Method
    POST
Headers
    access-token: "<Access Token>"
Data Parameter
    {
        handle: "<user handle being invited into app>",
        metaData: "<JSON string of invited user meta data>",
        senderUserId: "<sender Realm user id>"
    }

Response:

Success:

StatusCode:
    200 (OK)
Contents:
    true

Error:

StatusCode:
    400 (BAD REQUEST)
    500 (INTERNAL SERVER ERROR)
Content:
    {
        code: "<internal error code>",
        message: "<readable error description>"
    }

The internal codes are integers:

  • 401 - app no longer exists
  • 402 - app is suspended
  • 403 - missing parameter
  • 404 - user account is suspended
  • 405 - invalid access token
  • 406 - app does not support invite
  • 500 - internal server error
  • 601 - user already exists
  • 602 - invalid data