mirror of
https://github.com/LukeHagar/clerk-sdk-java.git
synced 2025-12-06 04:19:25 +00:00
233 lines
12 KiB
Markdown
233 lines
12 KiB
Markdown
# Invitations
|
|
(*invitations()*)
|
|
|
|
### Available Operations
|
|
|
|
* [create](#create) - Create an invitation
|
|
* [list](#list) - List all invitations
|
|
* [revoke](#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
|
|
|
|
```java
|
|
package hello.world;
|
|
|
|
import com.clerk.backend_api.Clerk;
|
|
import com.clerk.backend_api.models.components.*;
|
|
import com.clerk.backend_api.models.components.Security;
|
|
import com.clerk.backend_api.models.operations.*;
|
|
import com.clerk.backend_api.utils.EventStream;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.time.LocalDate;
|
|
import java.time.OffsetDateTime;
|
|
import java.util.Optional;
|
|
import org.openapitools.jackson.nullable.JsonNullable;
|
|
import static java.util.Map.entry;
|
|
|
|
public class Application {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
try {
|
|
Clerk sdk = Clerk.builder()
|
|
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
|
|
.build();
|
|
|
|
CreateInvitationRequestBody req = CreateInvitationRequestBody.builder()
|
|
.emailAddress("<value>")
|
|
.build();
|
|
|
|
CreateInvitationResponse res = sdk.invitations().create()
|
|
.request(req)
|
|
.call();
|
|
|
|
if (res.invitation().isPresent()) {
|
|
// handle response
|
|
}
|
|
} catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (com.clerk.backend_api.models.errors.SDKError e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (Exception e) {
|
|
// handle exception
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
| `request` | [com.clerk.backend_api.models.operations.CreateInvitationRequestBody](../../models/operations/CreateInvitationRequestBody.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
|
|
|
|
### Response
|
|
|
|
**[Optional<? extends com.clerk.backend_api.models.operations.CreateInvitationResponse>](../../models/operations/CreateInvitationResponse.md)**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ------------------------- | ------------------------- | ------------------------- |
|
|
| models/errors/ClerkErrors | 400,422 | application/json |
|
|
| models/errors/SDKError | 4xx-5xx | */* |
|
|
|
|
## list
|
|
|
|
Returns all non-revoked invitations for your application, sorted by creation date
|
|
|
|
### Example Usage
|
|
|
|
```java
|
|
package hello.world;
|
|
|
|
import com.clerk.backend_api.Clerk;
|
|
import com.clerk.backend_api.models.components.*;
|
|
import com.clerk.backend_api.models.components.Security;
|
|
import com.clerk.backend_api.models.operations.*;
|
|
import com.clerk.backend_api.utils.EventStream;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.time.LocalDate;
|
|
import java.time.OffsetDateTime;
|
|
import java.util.Optional;
|
|
import org.openapitools.jackson.nullable.JsonNullable;
|
|
import static java.util.Map.entry;
|
|
|
|
public class Application {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
try {
|
|
Clerk sdk = Clerk.builder()
|
|
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
|
|
.build();
|
|
|
|
ListInvitationsResponse res = sdk.invitations().list()
|
|
.limit(10L)
|
|
.offset(0L)
|
|
.status(QueryParamStatus.REVOKED)
|
|
.call();
|
|
|
|
while (true) {
|
|
if (res.invitationList().isPresent()) {
|
|
// handle response
|
|
Optional<ListInvitationsResponse> nextRes = res.next();
|
|
if (nextRes.isPresent()) {
|
|
res = nextRes.get();
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} catch (com.clerk.backend_api.models.errors.SDKError e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (Exception e) {
|
|
// handle exception
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| `limit` | *Optional<? extends Long>* | :heavy_minus_sign: | Applies a limit to the number of results returned.<br/>Can be used for paginating the results together with `offset`. |
|
|
| `offset` | *Optional<? extends Long>* | :heavy_minus_sign: | Skip the first `offset` results when paginating.<br/>Needs to be an integer greater or equal to zero.<br/>To be used in conjunction with `limit`. |
|
|
| `status` | [Optional<? extends com.clerk.backend_api.models.operations.QueryParamStatus>](../../models/operations/QueryParamStatus.md) | :heavy_minus_sign: | Filter invitations based on their status |
|
|
|
|
|
|
### Response
|
|
|
|
**[Optional<? extends com.clerk.backend_api.models.operations.ListInvitationsResponse>](../../models/operations/ListInvitationsResponse.md)**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ---------------------- | ---------------------- | ---------------------- |
|
|
| 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
|
|
|
|
```java
|
|
package hello.world;
|
|
|
|
import com.clerk.backend_api.Clerk;
|
|
import com.clerk.backend_api.models.components.*;
|
|
import com.clerk.backend_api.models.components.Security;
|
|
import com.clerk.backend_api.models.operations.*;
|
|
import com.clerk.backend_api.utils.EventStream;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.time.LocalDate;
|
|
import java.time.OffsetDateTime;
|
|
import java.util.Optional;
|
|
import org.openapitools.jackson.nullable.JsonNullable;
|
|
import static java.util.Map.entry;
|
|
|
|
public class Application {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
try {
|
|
Clerk sdk = Clerk.builder()
|
|
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
|
|
.build();
|
|
|
|
RevokeInvitationResponse res = sdk.invitations().revoke()
|
|
.invitationId("<value>")
|
|
.call();
|
|
|
|
if (res.invitationRevoked().isPresent()) {
|
|
// handle response
|
|
}
|
|
} catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (com.clerk.backend_api.models.errors.SDKError e) {
|
|
// handle exception
|
|
throw e;
|
|
} catch (Exception e) {
|
|
// handle exception
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Type | Required | Description |
|
|
| -------------------------------------- | -------------------------------------- | -------------------------------------- | -------------------------------------- |
|
|
| `invitationId` | *String* | :heavy_check_mark: | The ID of the invitation to be revoked |
|
|
|
|
|
|
### Response
|
|
|
|
**[Optional<? extends com.clerk.backend_api.models.operations.RevokeInvitationResponse>](../../models/operations/RevokeInvitationResponse.md)**
|
|
### Errors
|
|
|
|
| Error Object | Status Code | Content Type |
|
|
| ------------------------- | ------------------------- | ------------------------- |
|
|
| models/errors/ClerkErrors | 400,404 | application/json |
|
|
| models/errors/SDKError | 4xx-5xx | */* |
|