Create a reusable invitation link

POST https://chat.zulip.org/api/v1/invites/multiuse

Create a reusable invitation link which can be used to invite new users to the organization.

Changes: In Zulip 8.0 (feature level 209), added support for non-admin users with permission to use this endpoint. Previously, it was restricted to administrators only.

In Zulip 6.0 (feature level 126), the invite_expires_in_days parameter was removed and replaced by invite_expires_in_minutes.

In Zulip 5.0 (feature level 117), added support for passing null as the invite_expires_in_days parameter to request an invitation that never expires.

In Zulip 5.0 (feature level 96), the invite_expires_in_days parameter was added which specified the number of days before the invitation would expire.

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

# Create reusable invitation link
request = {
    "invite_expires_in_minutes": 60 * 24 * 10,  # 10 days
    "invite_as": 400,
    "stream_ids": [1, 8, 9],
}
result = client.call_endpoint(url="/invites/multiuse", method="POST", request=request)
print(result)

curl -sSX POST https://chat.zulip.org/api/v1/invites/multiuse \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY \
    --data-urlencode invite_expires_in_minutes=14400 \
    --data-urlencode invite_as=600 \
    --data-urlencode 'stream_ids=[1, 2]'

Parameters

invite_expires_in_minutes integer | null optional

Example: 14400

The number of minutes before the invitation will expire. If null, the invitation will never expire. If unspecified, the server will use a default value (based on the INVITATION_LINK_VALIDITY_MINUTES server setting, which defaults to 14400, i.e. 10 days) for when the invitation will expire.

Changes: New in Zulip 6.0 (feature level 126). Previously, there was an invite_expires_in_days parameter, which specified the duration in days instead of minutes.


invite_as integer optional

Example: 600

The organization-level role of the user that is created when the invitation is accepted. Possible values are:

  • 100 = Organization owner
  • 200 = Organization administrator
  • 300 = Organization moderator
  • 400 = Member
  • 600 = Guest

Users can only create invitation links for roles with equal or stricter restrictions as their own. For example, a moderator cannot invite someone to be an owner or administrator, but they can invite them to be a moderator or member.

Changes: In Zulip 4.0 (feature level 61), added support for inviting users as moderators.

Must be one of: 100, 200, 300, 400, 600. Defaults to 400.


stream_ids (integer)[] optional

Example: [1, 2]

A list containing the IDs of the streams that the newly created user will be automatically subscribed to if the invitation is accepted. If unspecified, it will be set to empty list. If the list is empty, then the new user will not be subscribed to any streams.

Defaults to [].


Response

Return values

Example response(s)

Changes: As of Zulip 7.0 (feature level 167), if any parameters sent in the request are not supported by this endpoint, a successful JSON response will include an ignored_parameters_unsupported array.

A typical successful JSON response may look like:

{
    "invite_link": "https://example.zulipchat.com/join/yddhtzk4jgl7rsmazc5fyyyy/",
    "msg": "",
    "result": "success"
}

An example JSON error response for when the user doesn't have permission to send invitations.

{
    "code": "BAD_REQUEST",
    "msg": "Insufficient permission",
    "result": "error"
}

An example JSON error response for when any of the specified streams does not exist or the user does not have permission to access one of the targeted streams.

{
    "code": "BAD_REQUEST",
    "msg": "Invalid channel ID 11. No invites were sent.",
    "result": "error"
}

An example JSON error response for when the user doesn't have permission to subscribe other users to streams and stream_ids is not empty.

{
    "code": "BAD_REQUEST",
    "msg": "You do not have permission to subscribe other users to channels.",
    "result": "error"
}