Skip to content

Latest commit

 

History

History
372 lines (270 loc) · 29.4 KB

File metadata and controls

372 lines (270 loc) · 29.4 KB

OrganizationInvitations

(OrganizationInvitations)

Overview

Available Operations

  • ListForInstance - Get a list of organization invitations for the current instance
  • Create - Create and send an organization invitation
  • List - Get a list of organization invitations
  • CreateBulk - Bulk create and send organization invitations
  • ListPending - Get a list of pending organization invitations ⚠️ Deprecated
  • Get - Retrieve an organization invitation by ID
  • Revoke - Revoke a pending organization invitation

ListForInstance

This request returns the list of organization invitations for the instance. Results can be paginated using the optional limit and offset query parameters. You can filter them by providing the 'status' query parameter, that accepts multiple values. You can change the order by providing the 'order' query parameter, that accepts multiple values. You can filter by the invited user email address providing the query query parameter. The organization invitations are ordered by descending creation date by default.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

ListInstanceOrganizationInvitationsRequest req = new ListInstanceOrganizationInvitationsRequest() {
    Limit = 20,
    Offset = 10,
};

var res = await sdk.OrganizationInvitations.ListForInstanceAsync(req);

// handle response

Parameters

Parameter Type Required Description
request ListInstanceOrganizationInvitationsRequest ✔️ The request object to use for the request.

Response

ListInstanceOrganizationInvitationsResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 404, 422, 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

Create

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.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using System.Collections.Generic;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.OrganizationInvitations.CreateAsync(
    organizationId: "org_12345",
    requestBody: new CreateOrganizationInvitationRequestBody() {
        EmailAddress = "[email protected]",
        InviterUserId = "user_67890",
        Role = "admin",
        PublicMetadata = new Dictionary<string, object>() {
            { "key", "value" },
        },
        PrivateMetadata = new Dictionary<string, object>() {
            { "private_key", "secret_value" },
        },
        RedirectUrl = "https://example.com/welcome",
    }
);

// handle response

Parameters

Parameter Type Required Description Example
OrganizationId string ✔️ The ID of the organization for which to send the invitation org_12345
RequestBody CreateOrganizationInvitationRequestBody ✔️ N/A

Response

CreateOrganizationInvitationResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 403, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

List

This request returns the list of organization invitations. Results can be paginated using the optional limit and offset query parameters. You can filter them by providing the 'status' query parameter, that accepts multiple values. The organization invitations are ordered by descending creation date. Most recent invitations will be returned first. Any invitations created as a result of an Organization Domain are not included in the results.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.OrganizationInvitations.ListAsync(
    organizationId: "org_12345",
    limit: 20,
    offset: 10,
    status: Clerk.BackendAPI.Models.Operations.ListOrganizationInvitationsQueryParamStatus.Pending
);

// handle response

Parameters

Parameter Type Required Description Example
OrganizationId string ✔️ The organization ID. org_12345
Limit long Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
20
Offset long Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.
10
Status ListOrganizationInvitationsQueryParamStatus Filter organization invitations based on their status pending

Response

ListOrganizationInvitationsResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 404 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

CreateBulk

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.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using System.Collections.Generic;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.OrganizationInvitations.CreateBulkAsync(
    organizationId: "org_12345",
    requestBody: new List<RequestBody>() {
        new RequestBody() {
            EmailAddress = "[email protected]",
            InviterUserId = "user_67890",
            Role = "admin",
            PublicMetadata = new Dictionary<string, object>() {

            },
            PrivateMetadata = new Dictionary<string, object>() {

            },
            RedirectUrl = "https://example.com/welcome",
        },
    }
);

// handle response

Parameters

Parameter Type Required Description Example
OrganizationId string ✔️ The organization ID. org_12345
RequestBody List<RequestBody> ✔️ N/A

Response

CreateOrganizationInvitationBulkResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 403, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

ListPending

This request returns the list of organization invitations with "pending" status. These are the organization invitations that can still be used to join the organization, but have not been accepted by the invited user yet. Results can be paginated using the optional limit and offset query parameters. The organization invitations are ordered by descending creation date. Most recent invitations will be returned first. Any invitations created as a result of an Organization Domain are not included in the results.

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.OrganizationInvitations.ListPendingAsync(
    organizationId: "org_12345",
    limit: 20,
    offset: 10
);

// handle response

Parameters

Parameter Type Required Description Example
OrganizationId string ✔️ The organization ID. org_12345
Limit long Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
20
Offset long Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.
10

Response

ListPendingOrganizationInvitationsResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 404 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

Get

Use this request to get an existing organization invitation by ID.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.OrganizationInvitations.GetAsync(
    organizationId: "org_123456789",
    invitationId: "inv_987654321"
);

// handle response

Parameters

Parameter Type Required Description Example
OrganizationId string ✔️ The organization ID. org_123456789
InvitationId string ✔️ The organization invitation ID. inv_987654321

Response

GetOrganizationInvitationResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 403, 404 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

Revoke

Use this request to revoke a previously issued organization invitation. Revoking an organization invitation makes it invalid; the invited user will no longer be able to join the organization with the revoked invitation. Only organization invitations with "pending" status can be revoked. The request accepts the requesting_user_id parameter to specify the user which revokes the invitation. Only users with "admin" role can revoke invitations.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.OrganizationInvitations.RevokeAsync(
    organizationId: "org_123456",
    invitationId: "inv_123456",
    requestBody: new RevokeOrganizationInvitationRequestBody() {
        RequestingUserId = "usr_12345",
    }
);

// handle response

Parameters

Parameter Type Required Description Example
OrganizationId string ✔️ The organization ID. org_123456
InvitationId string ✔️ The organization invitation ID. inv_123456
RequestBody RevokeOrganizationInvitationRequestBody N/A

Response

RevokeOrganizationInvitationResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 403, 404 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*