(phoneNumbers())
- create - Create a phone number
- get - Retrieve a phone number
- delete - Delete a phone number
- update - Update a phone number
Create a new phone number
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.CreatePhoneNumberRequestBody;
import com.clerk.backend_api.models.operations.CreatePhoneNumberResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
CreatePhoneNumberRequestBody req = CreatePhoneNumberRequestBody.builder()
.build();
CreatePhoneNumberResponse res = sdk.phoneNumbers().create()
.request(req)
.call();
if (res.phoneNumber().isPresent()) {
// handle response
}
}
}
CreatePhoneNumberResponse
Error Type |
Status Code |
Content Type |
models/errors/ClerkErrors |
400, 401, 403, 404, 422 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |
Returns the details of a phone number
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetPhoneNumberResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetPhoneNumberResponse res = sdk.phoneNumbers().get()
.phoneNumberId("<id>")
.call();
if (res.phoneNumber().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
phoneNumberId |
String |
✔️ |
The ID of the phone number to retrieve |
GetPhoneNumberResponse
Error Type |
Status Code |
Content Type |
models/errors/ClerkErrors |
400, 401, 403, 404 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |
Delete the phone number with the given ID
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeletePhoneNumberResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
DeletePhoneNumberResponse res = sdk.phoneNumbers().delete()
.phoneNumberId("<id>")
.call();
if (res.deletedObject().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
phoneNumberId |
String |
✔️ |
The ID of the phone number to delete |
DeletePhoneNumberResponse
Error Type |
Status Code |
Content Type |
models/errors/ClerkErrors |
400, 401, 403, 404 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |
Updates a phone number
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UpdatePhoneNumberRequestBody;
import com.clerk.backend_api.models.operations.UpdatePhoneNumberResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
UpdatePhoneNumberResponse res = sdk.phoneNumbers().update()
.phoneNumberId("<id>")
.requestBody(UpdatePhoneNumberRequestBody.builder()
.build())
.call();
if (res.phoneNumber().isPresent()) {
// handle response
}
}
}
UpdatePhoneNumberResponse
Error Type |
Status Code |
Content Type |
models/errors/ClerkErrors |
400, 401, 403, 404 |
application/json |
models/errors/SDKError |
4XX, 5XX |
*/* |