(invitations)
Invitations allow you to invite someone to sign up to your application, via email. https://clerk.com/docs/authentication/invitations
- createBulkInvitations - Create multiple invitations
- create - Create an invitation
- list - List all invitations
- revoke - Revokes an invitation
Use this API operation to create multiple invitations for the provided email addresses. You can choose to send the
invitations as emails by setting the notify
parameter to true
. There cannot be an existing invitation for any
of the email addresses you provide unless you set ignore_existing
to true
for specific email addresses. Please
note that there must be no existing user for any of the email addresses you provide, and this rule cannot be bypassed.
declare(strict_types=1);
require 'vendor/autoload.php';
use Clerk\Backend;
use Clerk\Backend\Models\Operations;
$sdk = Backend\ClerkBackend::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$request = [
new Operations\RequestBody(
emailAddress: '[email protected]',
),
];
$response = $sdk->invitations->createBulkInvitations(
request: $request
);
if ($response->invitationList !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
array<Operations\RequestBody> | ✔️ | The request object to use for the request. |
?Operations\CreateBulkInvitationsResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors | 400, 422 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
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;
$sdk = Backend\ClerkBackend::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->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\ClerkErrors | 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;
$sdk = Backend\ClerkBackend::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->build();
$response = $sdk->invitations->list(
limit: 10,
offset: 0,
status: Operations\ListInvitationsQueryParamStatus::Expired,
query: '<value>'
);
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 |
query |
?string | ➖ | Filter invitations based on their email_address or id |
?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;
$sdk = Backend\ClerkBackend::builder()
->setSecurity(
'<YOUR_BEARER_TOKEN_HERE>'
)
->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\ClerkErrors | 400, 404 | application/json |
Errors\SDKException | 4XX, 5XX | */* |