(phone_numbers)
- 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
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as s:
res = s.phone_numbers.create(request={
"user_id": "usr_12345",
"phone_number": "+11234567890",
"verified": True,
"primary": False,
"reserved_for_second_factor": False,
})
if res is not None:
# handle response
pass
models.PhoneNumber
Error Type |
Status Code |
Content Type |
models.ClerkErrors |
400, 401, 403, 404, 422 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
Returns the details of a phone number
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as s:
res = s.phone_numbers.get(phone_number_id="phone_12345")
if res is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
phone_number_id |
str |
✔️ |
The ID of the phone number to retrieve |
phone_12345 |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
|
models.PhoneNumber
Error Type |
Status Code |
Content Type |
models.ClerkErrors |
400, 401, 403, 404 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
Delete the phone number with the given ID
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as s:
res = s.phone_numbers.delete(phone_number_id="phone_12345")
if res is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
phone_number_id |
str |
✔️ |
The ID of the phone number to delete |
phone_12345 |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
|
models.DeletedObject
Error Type |
Status Code |
Content Type |
models.ClerkErrors |
400, 401, 403, 404 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
Updates a phone number
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as s:
res = s.phone_numbers.update(phone_number_id="phone_12345", verified=False, primary=True, reserved_for_second_factor=True)
if res is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
phone_number_id |
str |
✔️ |
The ID of the phone number to update |
phone_12345 |
verified |
OptionalNullable[bool] |
➖ |
The phone number will be marked as verified. |
false |
primary |
OptionalNullable[bool] |
➖ |
Set this phone number as the primary phone number for the user. |
true |
reserved_for_second_factor |
OptionalNullable[bool] |
➖ |
Set this phone number as reserved for multi-factor authentication. The phone number must also be verified. If there are no other reserved second factors, the phone number will be set as the default second factor. |
true |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
|
models.PhoneNumber
Error Type |
Status Code |
Content Type |
models.ClerkErrors |
400, 401, 403, 404 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |