(invitations)
Invitations allow you to invite someone to sign up to your application, via email. https://clerk.com/docs/authentication/invitations
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.
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
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\CreateInvitationRequestBody | ✔️ | The request object to use for the request. |
?Operations\CreateInvitationResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors42 | 400, 422 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
Returns all non-revoked invitations for your application, sorted by creation date
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
}
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 |
?Operations\ListInvitationsResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\SDKException | 4XX, 5XX | */* |
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.
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
}
Parameter | Type | Required | Description |
---|---|---|---|
invitationId |
string | ✔️ | The ID of the invitation to be revoked |
?Operations\RevokeInvitationResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors43 | 400, 404 | application/json |
Errors\SDKException | 4XX, 5XX | */* |