createOrganizationInvitation method
- String organizationId, {
- CreateOrganizationInvitationRequest? createOrganizationInvitationRequest,
Create and send an organization invitation
Creates a new organization invitation and sends an email to the provided email_address
with a link to accept the invitation and join the organization. You can specify the role
for the 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. When the invited user clicks the link to accept the invitation, they will be redirected to the URL provided. 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. That user must be a member with administrator privileges in the organization. Only "admin" members can create organization invitations. You can optionally provide public and private metadata for the organization invitation. The public metadata are visible by both the Frontend and the Backend whereas the private ones only by the Backend. When the organization invitation is accepted, the metadata will be transferred to the newly created organization membership.
Parameters:
-
String organizationId (required): The ID of the organization for which to send the invitation
-
CreateOrganizationInvitationRequest createOrganizationInvitationRequest:
Implementation
Future<OrganizationInvitation?> createOrganizationInvitation(
String organizationId, {
CreateOrganizationInvitationRequest? createOrganizationInvitationRequest,
}) async {
final response = await createOrganizationInvitationWithHttpInfo(
organizationId,
createOrganizationInvitationRequest: 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),
'OrganizationInvitation',
) as OrganizationInvitation;
}
return null;
}