(invitations)
- create - Create an invitation
- list - List all invitations
- bulk_create - Create multiple invitations
- revoke - Revokes an invitation
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.
import clerk_backend_api
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.invitations.create(request={
"email_address": "[email protected]",
"public_metadata": {
},
"redirect_url": "https://example.com/welcome",
"expires_in_days": 486589,
"template_slug": clerk_backend_api.TemplateSlug.WAITLIST_INVITATION,
})
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.CreateInvitationRequestBody | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 400, 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Returns all non-revoked invitations for your application, sorted by creation date
import clerk_backend_api
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.invitations.list(status=clerk_backend_api.ListInvitationsQueryParamStatus.PENDING, query="<value>", order_by="pending", paginated=False)
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
status |
Optional[models.ListInvitationsQueryParamStatus] | ➖ | Filter invitations based on their status | |
query |
Optional[str] | ➖ | Filter invitations based on their email_address or id |
|
order_by |
Optional[str] | ➖ | Allows to return organizations in a particular order. At the moment, you can order the returned organizations either by their name , created_at or members_count .In order to specify the direction, you can use the +/- symbols prepended in the property to order by.For example, if you want organizations to be returned in descending order according to their created_at property, you can use -created_at .If you don't use + or - , then + is implied. |
pending |
paginated |
Optional[bool] | ➖ | Whether to paginate the results. If true, the results will be paginated. If false, the results will not be paginated. |
|
limit |
Optional[int] | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
20 |
offset |
Optional[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 . |
10 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.SDKError | 4XX, 5XX | */* |
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.
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.invitations.bulk_create(request=[
{
"email_address": "[email protected]",
"public_metadata": {
"key": "<value>",
},
"redirect_url": "https://dreary-advancement.net/",
"expires_in_days": 123536,
},
{
"email_address": "[email protected]",
"public_metadata": {
"key": "<value>",
},
"redirect_url": "https://shrill-jet.net/",
"expires_in_days": 665767,
},
])
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
request |
List[models.RequestBody] | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 400, 422 | application/json |
models.SDKError | 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.
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.invitations.revoke(invitation_id="inv_123")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
invitation_id |
str | ✔️ | The ID of the invitation to be revoked | inv_123 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 400, 404 | application/json |
models.SDKError | 4XX, 5XX | */* |