Skip to content

Latest commit

 

History

History
172 lines (117 loc) · 14.6 KB

README.md

File metadata and controls

172 lines (117 loc) · 14.6 KB

PhoneNumbers

(phone_numbers)

Overview

Available Operations

  • create - Create a phone number
  • get - Retrieve a phone number
  • delete - Delete a phone number
  • update - Update a phone number

create

Create a new phone number

Example Usage

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

Parameters

Parameter Type Required Description
request models.CreatePhoneNumberRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PhoneNumber

Errors

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

get

Returns the details of a phone number

Example Usage

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

Parameters

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.

Response

models.PhoneNumber

Errors

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

delete

Delete the phone number with the given ID

Example Usage

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

Parameters

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.

Response

models.DeletedObject

Errors

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

update

Updates a phone number

Example Usage

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

Parameters

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.

Response

models.PhoneNumber

Errors

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