Skip to content

Latest commit

 

History

History
1859 lines (1312 loc) · 91.4 KB

File metadata and controls

1859 lines (1312 loc) · 91.4 KB

Users

Overview

Available Operations

list

Returns a list of all users. The users are returned sorted by creation date, with the newest users appearing first.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetUserListRequest;
import com.clerk.backend_api.models.operations.GetUserListResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        GetUserListRequest req = GetUserListRequest.builder()
                .lastActiveAtBefore(1700690400000L)
                .lastActiveAtAfter(1700690400000L)
                .lastActiveAtSince(1700690400000L)
                .createdAtBefore(1730160000000L)
                .createdAtAfter(1730160000000L)
                .lastSignInAtBefore(1700690400000L)
                .lastSignInAtAfter(1700690400000L)
                .build();

        GetUserListResponse res = sdk.users().list()
                .request(req)
                .call();

        if (res.userList().isPresent()) {
            System.out.println(res.userList().get());
        }
    }
}

Parameters

Parameter Type Required Description
request GetUserListRequest ✔️ The request object to use for the request.

Response

GetUserListResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 422 application/json
models/errors/SDKError 4XX, 5XX */*

create

Creates a new user. Your user management settings determine how you should setup your user model.

By default, any email address and phone number created using this method is marked as verified. Use the email_address_identification_status and phone_number_identification_status arrays to instead create some or all of them as reserved (unverified but usable for sign-in and locked so no other user can claim them).

Note: If you are performing a migration, check out our guide on zero downtime migrations.

The following rate limit rules apply to this endpoint: 1000 requests per 10 seconds for production instances and 100 requests per 10 seconds for development instances

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.CreateUserRequestBody;
import com.clerk.backend_api.models.operations.CreateUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        CreateUserRequestBody req = CreateUserRequestBody.builder()
                .build();

        CreateUserResponse res = sdk.users().create()
                .request(req)
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
request CreateUserRequestBody ✔️ The request object to use for the request.

Response

CreateUserResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 402, 403, 422 application/json
models/errors/SDKError 4XX, 5XX */*

count

Returns a total count of all users that match the given filtering criteria.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetUsersCountRequest;
import com.clerk.backend_api.models.operations.GetUsersCountResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        GetUsersCountRequest req = GetUsersCountRequest.builder()
                .lastActiveAtBefore(1700690400000L)
                .lastActiveAtAfter(1700690400000L)
                .lastActiveAtSince(1700690400000L)
                .createdAtBefore(1730160000000L)
                .createdAtAfter(1730160000000L)
                .lastSignInAtBefore(1700690400000L)
                .lastSignInAtAfter(1700690400000L)
                .build();

        GetUsersCountResponse res = sdk.users().count()
                .request(req)
                .call();

        if (res.totalCount().isPresent()) {
            System.out.println(res.totalCount().get());
        }
    }
}

Parameters

Parameter Type Required Description
request GetUsersCountRequest ✔️ The request object to use for the request.

Response

GetUsersCountResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 422 application/json
models/errors/SDKError 4XX, 5XX */*

get

Retrieve the details of a user

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        GetUserResponse res = sdk.users().get()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to retrieve

Response

GetUserResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 404 application/json
models/errors/SDKError 4XX, 5XX */*

update

Update a user's attributes.

You can set the user's primary contact identifiers (email address and phone numbers) by updating the primary_email_address_id and primary_phone_number_id attributes respectively. Both IDs should correspond to verified identifications that belong to the user.

You can remove a user's username by setting the username attribute to null or the blank string "".

As of API version 2026-05-12, this endpoint no longer accepts public_metadata, private_metadata, or unsafe_metadata. Use PATCH /v1/users/{user_id}/metadata to merge updates into existing metadata, or PUT /v1/users/{user_id}/metadata to replace a metadata field entirely.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UpdateUserRequestBody;
import com.clerk.backend_api.models.operations.UpdateUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UpdateUserResponse res = sdk.users().update()
                .userId("<id>")
                .requestBody(UpdateUserRequestBody.builder()
                    .build())
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to update
requestBody UpdateUserRequestBody ✔️ N/A

Response

UpdateUserResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 404, 409, 422 application/json
models/errors/SDKError 4XX, 5XX */*

delete

Delete the specified user

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeleteUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        DeleteUserResponse res = sdk.users().delete()
                .userId("<id>")
                .call();

        if (res.deletedObject().isPresent()) {
            System.out.println(res.deletedObject().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to delete

Response

DeleteUserResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 404 application/json
models/errors/SDKError 4XX, 5XX */*

ban

Marks the given user as banned, which means that all their sessions are revoked and they are not allowed to sign in again.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.BanUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        BanUserResponse res = sdk.users().ban()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to ban

Response

BanUserResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 402 application/json
models/errors/SDKError 4XX, 5XX */*

unban

Removes the ban mark from the given user.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UnbanUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UnbanUserResponse res = sdk.users().unban()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to unban

Response

UnbanUserResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 402 application/json
models/errors/SDKError 4XX, 5XX */*

bulkBan

Marks multiple users as banned, which means that all their sessions are revoked and they are not allowed to sign in again.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UsersBanRequestBody;
import com.clerk.backend_api.models.operations.UsersBanResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UsersBanRequestBody req = UsersBanRequestBody.builder()
                .userIds(List.of(
                    "<value 1>",
                    "<value 2>",
                    "<value 3>"))
                .build();

        UsersBanResponse res = sdk.users().bulkBan()
                .request(req)
                .call();

        if (res.userList().isPresent()) {
            System.out.println(res.userList().get());
        }
    }
}

Parameters

Parameter Type Required Description
request UsersBanRequestBody ✔️ The request object to use for the request.

Response

UsersBanResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 402 application/json
models/errors/SDKError 4XX, 5XX */*

bulkUnban

Removes the ban mark from multiple users.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UsersUnbanRequestBody;
import com.clerk.backend_api.models.operations.UsersUnbanResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UsersUnbanRequestBody req = UsersUnbanRequestBody.builder()
                .userIds(List.of(
                    "<value 1>",
                    "<value 2>",
                    "<value 3>"))
                .build();

        UsersUnbanResponse res = sdk.users().bulkUnban()
                .request(req)
                .call();

        if (res.userList().isPresent()) {
            System.out.println(res.userList().get());
        }
    }
}

Parameters

Parameter Type Required Description
request UsersUnbanRequestBody ✔️ The request object to use for the request.

Response

UsersUnbanResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 402 application/json
models/errors/SDKError 4XX, 5XX */*

lock

Marks the given user as locked, which means they are not allowed to sign in again until the lock expires. Lock duration can be configured in the instance's restrictions settings.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.LockUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        LockUserResponse res = sdk.users().lock()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to lock

Response

LockUserResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 403 application/json
models/errors/SDKError 4XX, 5XX */*

unlock

Removes the lock from the given user.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UnlockUserResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UnlockUserResponse res = sdk.users().unlock()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to unlock

Response

UnlockUserResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 403 application/json
models/errors/SDKError 4XX, 5XX */*

setProfileImage

Update a user's profile image

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.SetUserProfileImageRequestBody;
import com.clerk.backend_api.models.operations.SetUserProfileImageResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        SetUserProfileImageResponse res = sdk.users().setProfileImage()
                .userId("<id>")
                .requestBody(SetUserProfileImageRequestBody.builder()
                    .build())
                .call();

    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to update the profile image for
requestBody SetUserProfileImageRequestBody ✔️ N/A

Response

SetUserProfileImageResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 404 application/json
models/errors/SDKError 4XX, 5XX */*

deleteProfileImage

Delete a user's profile image

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeleteUserProfileImageResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        DeleteUserProfileImageResponse res = sdk.users().deleteProfileImage()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to delete the profile image for

Response

DeleteUserProfileImageResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 404 application/json
models/errors/SDKError 4XX, 5XX */*

updateMetadata

Update a user's metadata attributes by merging existing values with the provided parameters.

This endpoint behaves differently than the Update a user endpoint. Metadata values will not be replaced entirely. Instead, a deep merge will be performed. Deep means that any nested JSON objects will be merged as well.

You can remove metadata keys at any level by setting their value to null.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UpdateUserMetadataResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UpdateUserMetadataResponse res = sdk.users().updateMetadata()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose metadata will be updated and merged
requestBody Optional<UpdateUserMetadataRequestBody> N/A

Response

UpdateUserMetadataResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 404, 422 application/json
models/errors/SDKError 4XX, 5XX */*

replaceMetadata

Replace a user's metadata attributes with the provided values.

Unlike PATCH /v1/users/{user_id}/metadata (merge semantics), this endpoint replaces the supplied metadata fields entirely — the prior contents of each supplied field are discarded. Fields omitted from the request body are left unchanged.

Prefer the PATCH endpoint for partial updates. Use PUT only when you explicitly intend to overwrite a metadata field wholesale.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.ReplaceUserMetadataResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        ReplaceUserMetadataResponse res = sdk.users().replaceMetadata()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose metadata will be replaced
requestBody Optional<ReplaceUserMetadataRequestBody> N/A

Response

ReplaceUserMetadataResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 404, 422 application/json
models/errors/SDKError 4XX, 5XX */*

getBillingSubscription

Retrieves the billing subscription for the specified user. This includes subscription details, active plans, billing information, and payment status. The subscription contains subscription items which represent the individual plans the user is subscribed to.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetUserBillingSubscriptionResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        GetUserBillingSubscriptionResponse res = sdk.users().getBillingSubscription()
                .userId("<id>")
                .call();

        if (res.commerceSubscription().isPresent()) {
            System.out.println(res.commerceSubscription().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose subscription to retrieve

Response

GetUserBillingSubscriptionResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404, 422 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

getBillingCreditBalance

Retrieves the current credit balance for the specified user. Credits can be applied during checkout to reduce the charge or automatically applied to upcoming recurring charges

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetUserBillingCreditBalanceResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        GetUserBillingCreditBalanceResponse res = sdk.users().getBillingCreditBalance()
                .userId("<id>")
                .call();

        if (res.commerceCreditBalanceResponse().isPresent()) {
            System.out.println(res.commerceCreditBalanceResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose credit balance to retrieve

Response

GetUserBillingCreditBalanceResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404, 422 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

adjustBillingCreditBalance

Increases or decreases the credit balance for the specified user. Each adjustment is recorded as a ledger entry. The idempotency_key parameter ensures that duplicate requests are safely handled.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.Action;
import com.clerk.backend_api.models.components.AdjustCreditBalanceRequest;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.AdjustUserBillingCreditBalanceResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        AdjustUserBillingCreditBalanceResponse res = sdk.users().adjustBillingCreditBalance()
                .userId("<id>")
                .adjustCreditBalanceRequest(AdjustCreditBalanceRequest.builder()
                    .amount(562473L)
                    .action(Action.DECREASE)
                    .idempotencyKey("<value>")
                    .build())
                .call();

        if (res.commerceCreditLedgerResponse().isPresent()) {
            System.out.println(res.commerceCreditLedgerResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose credit balance to adjust
adjustCreditBalanceRequest AdjustCreditBalanceRequest ✔️ Parameters for the credit balance adjustment

Response

AdjustUserBillingCreditBalanceResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404, 409, 422 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

getOAuthAccessToken

Fetch the corresponding OAuth access token for a user that has previously authenticated with a particular OAuth provider. For OAuth 2.0, if the access token has expired and we have a corresponding refresh token, the access token will be refreshed transparently the new one will be returned.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetOAuthAccessTokenRequest;
import com.clerk.backend_api.models.operations.GetOAuthAccessTokenResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        GetOAuthAccessTokenRequest req = GetOAuthAccessTokenRequest.builder()
                .userId("<id>")
                .provider("<value>")
                .build();

        GetOAuthAccessTokenResponse res = sdk.users().getOAuthAccessToken()
                .request(req)
                .call();

        if (res.oAuthAccessToken().isPresent()) {
            System.out.println(res.oAuthAccessToken().get());
        }
    }
}

Parameters

Parameter Type Required Description
request GetOAuthAccessTokenRequest ✔️ The request object to use for the request.

Response

GetOAuthAccessTokenResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 404, 422 application/json
models/errors/SDKError 4XX, 5XX */*

getOrganizationMemberships

Retrieve a paginated list of the user's organization memberships

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UsersGetOrganizationMembershipsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UsersGetOrganizationMembershipsResponse res = sdk.users().getOrganizationMemberships()
                .userId("<id>")
                .limit(10L)
                .offset(0L)
                .call();

        if (res.organizationMemberships().isPresent()) {
            System.out.println(res.organizationMemberships().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose organization memberships we want to retrieve
limit Optional<Long> Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
offset Optional<Long> Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.

Response

UsersGetOrganizationMembershipsResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 403 application/json
models/errors/SDKError 4XX, 5XX */*

getOrganizationInvitations

Retrieve a paginated list of the user's organization invitations

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UsersGetOrganizationInvitationsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UsersGetOrganizationInvitationsResponse res = sdk.users().getOrganizationInvitations()
                .userId("<id>")
                .limit(10L)
                .offset(0L)
                .call();

        if (res.organizationInvitationsWithPublicOrganizationData().isPresent()) {
            System.out.println(res.organizationInvitationsWithPublicOrganizationData().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose organization invitations we want to retrieve
limit Optional<Long> Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
offset Optional<Long> 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 Optional<QueryParamStatus> Filter organization invitations based on their status

Response

UsersGetOrganizationInvitationsResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 403, 404 application/json
models/errors/SDKError 4XX, 5XX */*

verifyPassword

Check that the user's password matches the supplied input. Useful for custom auth flows and re-verification.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.VerifyPasswordResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        VerifyPasswordResponse res = sdk.users().verifyPassword()
                .userId("<id>")
                .call();

        if (res.object().isPresent()) {
            System.out.println(res.object().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user for whom to verify the password
requestBody Optional<VerifyPasswordRequestBody> N/A

Response

VerifyPasswordResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

verifyTotp

Verify that the provided TOTP or backup code is valid for the user. Verifying a backup code will result it in being consumed (i.e. it will become invalid). Useful for custom auth flows and re-verification.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.VerifyTOTPResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        VerifyTOTPResponse res = sdk.users().verifyTotp()
                .userId("<id>")
                .call();

        if (res.object().isPresent()) {
            System.out.println(res.object().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user for whom to verify the TOTP
requestBody Optional<VerifyTOTPRequestBody> N/A

Response

VerifyTOTPResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

disableMfa

Disable all of a user's MFA methods (e.g. OTP sent via SMS, TOTP on their authenticator app) at once.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DisableMFAResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        DisableMFAResponse res = sdk.users().disableMfa()
                .userId("<id>")
                .call();

        if (res.object().isPresent()) {
            System.out.println(res.object().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose MFA methods are to be disabled

Response

DisableMFAResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 404 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

deleteBackupCodes

Disable all of a user's backup codes.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeleteBackupCodeResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        DeleteBackupCodeResponse res = sdk.users().deleteBackupCodes()
                .userId("<id>")
                .call();

        if (res.object().isPresent()) {
            System.out.println(res.object().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose backup codes are to be deleted.

Response

DeleteBackupCodeResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 404 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

deletePasskey

Delete the passkey identification for a given user and notify them through email.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UserPasskeyDeleteResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UserPasskeyDeleteResponse res = sdk.users().deletePasskey()
                .userId("<id>")
                .passkeyIdentificationId("<id>")
                .call();

        if (res.deletedObject().isPresent()) {
            System.out.println(res.deletedObject().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user that owns the passkey identity
passkeyIdentificationId String ✔️ The ID of the passkey identity to be deleted

Response

UserPasskeyDeleteResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 403, 404 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

deleteWeb3Wallet

Delete the web3 wallet identification for a given user.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UserWeb3WalletDeleteResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UserWeb3WalletDeleteResponse res = sdk.users().deleteWeb3Wallet()
                .userId("<id>")
                .web3WalletIdentificationId("<id>")
                .call();

        if (res.deletedObject().isPresent()) {
            System.out.println(res.deletedObject().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user that owns the web3 wallet
web3WalletIdentificationId String ✔️ The ID of the web3 wallet identity to be deleted

Response

UserWeb3WalletDeleteResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 403, 404 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

deleteTOTP

Deletes all of the user's TOTPs.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeleteTOTPResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        DeleteTOTPResponse res = sdk.users().deleteTOTP()
                .userId("<id>")
                .call();

        if (res.object().isPresent()) {
            System.out.println(res.object().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user whose TOTPs are to be deleted

Response

DeleteTOTPResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 404 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

deleteExternalAccount

Delete an external account by ID.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeleteExternalAccountResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        DeleteExternalAccountResponse res = sdk.users().deleteExternalAccount()
                .userId("<id>")
                .externalAccountId("<id>")
                .call();

        if (res.deletedObject().isPresent()) {
            System.out.println(res.deletedObject().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user's external account
externalAccountId String ✔️ The ID of the external account to delete

Response

DeleteExternalAccountResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 403, 404 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*

setPasswordCompromised

Sets the given user's password as compromised. The user will be prompted to reset their password on their next sign-in.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.SetUserPasswordCompromisedResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        SetUserPasswordCompromisedResponse res = sdk.users().setPasswordCompromised()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to set the password as compromised
requestBody Optional<SetUserPasswordCompromisedRequestBody> N/A

Response

SetUserPasswordCompromisedResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404, 422 application/json
models/errors/SDKError 4XX, 5XX */*

unsetPasswordCompromised

Sets the given user's password as no longer compromised. The user will no longer be prompted to reset their password on their next sign-in.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UnsetUserPasswordCompromisedResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        UnsetUserPasswordCompromisedResponse res = sdk.users().unsetPasswordCompromised()
                .userId("<id>")
                .call();

        if (res.user().isPresent()) {
            System.out.println(res.user().get());
        }
    }
}

Parameters

Parameter Type Required Description
userId String ✔️ The ID of the user to unset the compromised status for

Response

UnsetUserPasswordCompromisedResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 403, 404, 422 application/json
models/errors/SDKError 4XX, 5XX */*

getInstanceOrganizationMemberships

Retrieves all organization user memberships for the given instance.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.InstanceGetOrganizationMembershipsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws ClerkErrors, Exception {

        Clerk sdk = Clerk.builder()
                .bearerAuth(System.getenv().getOrDefault("BEARER_AUTH", ""))
            .build();

        InstanceGetOrganizationMembershipsResponse res = sdk.users().getInstanceOrganizationMemberships()
                .limit(10L)
                .offset(0L)
                .call();

        if (res.organizationMemberships().isPresent()) {
            System.out.println(res.organizationMemberships().get());
        }
    }
}

Parameters

Parameter Type Required Description
orderBy Optional<String> Sorts organizations memberships by phone_number, email_address, created_at, first_name, last_name or username.
By prepending one of those values with + or -,
we can choose to sort in ascending (ASC) or descending (DESC) order.
limit Optional<Long> Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
offset Optional<Long> Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.

Response

InstanceGetOrganizationMembershipsResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 401, 422 application/json
models/errors/ClerkErrors 500 application/json
models/errors/SDKError 4XX, 5XX */*