Create a reusable invitation link

POST https://servo.zulipchat.com/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 a reusable invitation link.
request = {
    "invite_expires_in_minutes": 60 * 24 * 10,  # 10 days
    "invite_as": 400,
    "stream_ids": stream_ids,
}
result = client.call_endpoint(url="/invites/multiuse", method="POST", request=request)
print(result)

curl -sSX POST https://servo.zulipchat.com/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, 10]' \
    --data-urlencode include_realm_default_subscriptions=false

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, 10]

A list containing the IDs of the channels that the newly created user will be automatically subscribed to if the invitation is accepted, in addition to any default channels that the new user may be subscribed to based on the include_realm_default_subscriptions parameter.

This list must be empty if the current user has the unlikely configuration of being able to create reusable invitation links while lacking permission to subscribe other users to channels.

Defaults to [].


include_realm_default_subscriptions boolean optional

Example: false

Boolean indicating whether the newly created user should be subscribed to the default channels for the organization.

Note that this parameter can be true even if the current user does not generally have permission to subscribe other users to channels.

Changes: New in Zulip 9.0 (feature level 261). Previous versions of Zulip behaved as though this parameter was always false; clients needed to include the organization's default channels in the stream_ids parameter for a newly created user to be automatically subscribed to them.

Defaults to false.


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 channels does not exist or the user does not have permission to access one of the targeted channels.

{
    "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 channels and stream_ids is not empty.

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