Skip to content

Latest commit

 

History

History
161 lines (103 loc) · 7.86 KB

README.md

File metadata and controls

161 lines (103 loc) · 7.86 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

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;
use Clerk\Backend\Models\Operations;

$security = '<YOUR_BEARER_TOKEN_HERE>';

$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();

$request = new Operations\CreateInvitationRequestBody(
    emailAddress: '[email protected]',
);

$response = $sdk->invitations->create(
    request: $request
);

if ($response->invitation !== null) {
    // handle response
}

Parameters

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

Response

?Operations\CreateInvitationResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors42 400, 422 application/json
Errors\SDKException 4XX, 5XX */*

list

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

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;
use Clerk\Backend\Models\Operations;

$security = '<YOUR_BEARER_TOKEN_HERE>';

$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();



$response = $sdk->invitations->list(
    limit: 10,
    offset: 0,
    status: Operations\ListInvitationsQueryParamStatus::Expired

);

if ($response->invitationList !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
limit ?int Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
offset ?int Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.
status ?Operations\ListInvitationsQueryParamStatus Filter invitations based on their status

Response

?Operations\ListInvitationsResponse

Errors

Error Type Status Code Content Type
Errors\SDKException 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

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$security = '<YOUR_BEARER_TOKEN_HERE>';

$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();



$response = $sdk->invitations->revoke(
    invitationId: '<id>'
);

if ($response->invitationRevoked !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
invitationId string ✔️ The ID of the invitation to be revoked

Response

?Operations\RevokeInvitationResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors43 400, 404 application/json
Errors\SDKException 4XX, 5XX */*