createOrganizationInvitationBulk method

Future<OrganizationInvitations?> createOrganizationInvitationBulk(
  1. String organizationId,
  2. List<CreateOrganizationInvitationRequest> createOrganizationInvitationRequest
)

Bulk create and send organization invitations

Creates new organization invitations in bulk and sends out emails to the provided email addresses with a link to accept the invitation and join the organization. You can specify a different role for each invited organization member. New organization invitations get a "pending" status until they are revoked by an organization administrator or accepted by the invitee. The request body supports passing an optional redirect_url parameter for each invitation. When the invited user clicks the link to accept the invitation, they will be redirected to the provided URL. Use this parameter to implement a custom invitation acceptance flow. You can specify the ID of the user that will send the invitation with the inviter_user_id parameter. Each invitation can have a different inviter user. Inviter users must be members with administrator privileges in the organization. Only "admin" members can create organization invitations. You can optionally provide public and private metadata for each organization invitation. The public metadata are visible by both the Frontend and the Backend, whereas the private metadata are only visible by the Backend. When the organization invitation is accepted, the metadata will be transferred to the newly created organization membership.

Parameters:

Implementation

Future<OrganizationInvitations?> createOrganizationInvitationBulk(
  String organizationId,
  List<CreateOrganizationInvitationRequest>
      createOrganizationInvitationRequest,
) async {
  final response = await createOrganizationInvitationBulkWithHttpInfo(
    organizationId,
    createOrganizationInvitationRequest,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'OrganizationInvitations',
    ) as OrganizationInvitations;
  }
  return null;
}