Skip to content

Latest commit

 

History

History
139 lines (94 loc) · 9.17 KB

README.md

File metadata and controls

139 lines (94 loc) · 9.17 KB

Invitations

(Invitations)

Overview

Invitations allow you to invite someone to sign up to your application, via email. https://clerk.com/docs/authentication/invitations

Available Operations

  • Create - Create an invitation
  • List - List all invitations
  • Revoke - Revokes an invitation

Create

Creates a new invitation for the given email address and sends the invitation email. Keep in mind that you cannot create an invitation if there is already one for the given email address. Also, trying to create an invitation for an email address that already exists in your application will result to an error.

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>");

CreateInvitationRequestBody req = new CreateInvitationRequestBody() {
    EmailAddress = "[email protected]",
    PublicMetadata = new Dictionary<string, object>() {

    },
    RedirectUrl = "https://example.com/welcome",
    Notify = true,
    IgnoreExisting = true,
};

var res = await sdk.Invitations.CreateAsync(req);

// handle response

Parameters

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

Response

CreateInvitationResponse

Errors

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

List

Returns all non-revoked invitations for your application, sorted by creation date

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.Invitations.ListAsync(
    limit: 20,
    offset: 10,
    status: Clerk.BackendAPI.Models.Operations.ListInvitationsQueryParamStatus.Pending
);

// handle response

Parameters

Parameter Type Required Description Example
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 ListInvitationsQueryParamStatus Filter invitations based on their status pending

Response

ListInvitationsResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

Revoke

Revokes the given invitation. Revoking an invitation will prevent the user from using the invitation link that was sent to them. However, it doesn't prevent the user from signing up if they follow the sign up flow. Only active (i.e. non-revoked) invitations can be revoked.

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.Invitations.RevokeAsync(invitationId: "inv_123");

// handle response

Parameters

Parameter Type Required Description Example
InvitationId string ✔️ The ID of the invitation to be revoked inv_123

Response

RevokeInvitationResponse

Errors

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