### SDK Installation Source: https://github.com/clerk/clerk-sdk-python/blob/main/README-PYPI.md Instructions on how to install and run the Clerk SDK for Python. ```APIDOC ## SDK Installation Once that is saved to a file, you can run it with `uv run script.py` where `script.py` can be replaced with the actual file name. ``` -------------------------------- ### Install Clerk SDK with uv Source: https://github.com/clerk/clerk-sdk-python/blob/main/README.md Install the clerk-backend-api package using the uv package manager. ```bash uv add clerk-backend-api ``` -------------------------------- ### Install Clerk SDK with pip Source: https://github.com/clerk/clerk-sdk-python/blob/main/README.md Install the clerk-backend-api package using pip, the standard Python package installer. ```bash pip install clerk-backend-api ``` -------------------------------- ### User Parameters Example Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Illustrates the JSON structure for user parameters, specifically showing an example with an age field. ```json { "age": 30 } ``` -------------------------------- ### User Passkeys Example Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/user.md Example of the `passkeys` field, which is a list of Passkey objects. Each passkey includes its ID, object type, name, last used timestamp, and verification details. ```json [ { "id": "passkey_id_123", "object": "passkey", "name": "My Passkey", "last_used_at": 1615852800, "verification": { "status": "verified", "strategy": "passkey" } } ] ``` -------------------------------- ### User Password Enabled Example Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/user.md Example of the `password_enabled` field, a boolean indicating if password authentication is enabled for the user. ```json true ``` -------------------------------- ### Error Handling Example Source: https://github.com/clerk/clerk-sdk-python/blob/main/README.md Provides an example of how to catch and handle `ClerkBaseError` and its subclasses, accessing properties like message, status code, headers, and body. ```APIDOC ## Error Handling [`ClerkBaseError`](./src/clerk_backend_api/models/clerkbaseerror.py) is the base class for all HTTP error responses. It has the following properties: | Property | Type | Description | | ------------------ | ---------------- | --------------------------------------------------------------------------------------- | | `err.message` | `str` | Error message | | `err.status_code` | `int` | HTTP response status code eg `404` | | `err.headers` | `httpx.Headers` | HTTP response headers | | `err.body` | `str` | HTTP body. Can be empty string if no body is returned. | | `err.raw_response` | `httpx.Response` | Raw HTTP response | | `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). | ### Example ```python import clerk_backend_api from clerk_backend_api import Clerk, models with Clerk( bearer_auth="", ) as clerk: res = None try: res = clerk.clients.verify(request={ "token": "jwt_token_example", }) # Handle response print(res) except models.ClerkBaseError as e: # The base class for HTTP error responses print(e.message) print(e.status_code) print(e.body) print(e.headers) print(e.raw_response) # Depending on the method different errors may be thrown if isinstance(e, models.ClerkErrors): print(e.data.errors) # List[clerk_backend_api.ClerkError] print(e.data.meta) # Optional[clerk_backend_api.ClerkErrorsMeta] ``` ``` -------------------------------- ### Public Metadata Example Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/updateuserrequestbody.md Example of public metadata that can be saved on a user. This data is visible to both your Frontend and Backend APIs. ```json { "theme": "dark" } ``` -------------------------------- ### Get User Organization Invitations (Python) Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Use this snippet to retrieve a list of pending organization invitations for a given user. Ensure you have the Clerk SDK installed and replace placeholders with your actual bearer token and user ID. ```python import clerk_backend_api from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.get_organization_invitations(user_id="", limit=20, offset=10, status=clerk_backend_api.UsersGetOrganizationInvitationsQueryParamStatus.PENDING) # Handle response print(res) ``` -------------------------------- ### GET /instance_settings Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/instancesettings.md Retrieves the current configuration settings for the Clerk instance. ```APIDOC ## GET /instance_settings ### Description Retrieves the current settings for the Clerk instance, including email configurations and sign-up policies. ### Method GET ### Endpoint /instance_settings ### Parameters None ### Response #### Success Response (200) - **object** (string) - String representing the object's type (instance_settings) - **id** (string) - The unique identifier for the instance settings - **restricted_to_allowlist** (boolean) - Whether the instance is restricted to an allowlist - **from_email_address** (string) - The email address used for outgoing emails - **progressive_sign_up** (boolean) - Whether progressive sign-up is enabled - **enhanced_email_deliverability** (boolean) - Whether enhanced email deliverability is enabled #### Response Example { "object": "instance_settings", "id": "inst_123456789", "restricted_to_allowlist": false, "from_email_address": "noreply@clerk.dev", "progressive_sign_up": true, "enhanced_email_deliverability": true } ``` -------------------------------- ### Get Instance Protect Settings Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/instancesettingssdk/README.md Retrieves the current instance protect settings. ```APIDOC ## get_instance_protect ### Description Get instance protect settings ### Method GET ### Endpoint /instance/protect ### Parameters #### Query Parameters - `retries` (Optional[utils.RetryConfig]) - Optional - Configuration to override the default retry behavior of the client. ### Response #### Success Response (200) - **body** (models.InstanceProtect) - The instance protect settings. ### Errors - **models.SDKError** - 4XX, 5XX - */* ``` -------------------------------- ### get Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/instancesettingssdk/README.md Fetches the current instance settings. This operation retrieves all configuration details for your Clerk instance. ```APIDOC ## GET /instance ### Description Fetches the current instance settings. This operation retrieves all configuration details for your Clerk instance. ### Method GET ### Endpoint /instance ### Parameters #### Query Parameters - **retries** (Optional[utils.RetryConfig]) - Optional - Configuration to override the default retry behavior of the client. ### Response #### Success Response (200) - **Instance** (models.Instance) - The current instance settings. ### Errors - **models.SDKError** (4XX, 5XX) - An error occurred during the request. ``` -------------------------------- ### Get Instance Settings Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/instancesettingssdk/README.md Fetches the current instance settings. Requires a bearer token for authentication. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.instance_settings.get() # Handle response print(res) ``` -------------------------------- ### GET /clients Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/getclientlistrequest.md Retrieves a list of clients with optional pagination support. ```APIDOC ## GET /clients ### Description Retrieves a list of clients. Supports pagination through limit and offset parameters. ### Method GET ### Endpoint /clients ### Parameters #### Query Parameters - **paginated** (bool) - Optional - Whether to paginate the results. - **limit** (int) - Optional - Applies a limit to the number of results returned. - **offset** (int) - Optional - Skip the first offset results when paginating. ### Request Example GET /clients?limit=20&offset=10 ### Response #### Success Response (200) - **clients** (array) - List of client objects. #### Response Example { "clients": [ { "id": "client_123", "name": "Example Client" } ] } ``` -------------------------------- ### get Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/oauthapplicationssdk/README.md Fetches the OAuth application whose ID matches the provided `id` in the path. ```APIDOC ## GET /oauth_applications/{oauth_application_id} ### Description Fetches the OAuth application whose ID matches the provided `id`. ### Method GET ### Endpoint /oauth_applications/{oauth_application_id} ### Parameters #### Path Parameters - **oauth_application_id** (string) - Required - The ID of the OAuth application. ### Response #### Success Response (200) - **OAuthApplication** (object) - The requested OAuth application. ### Errors - **models.ClerkErrors** (400, 403, 422) - application/json - **models.SDKError** (4XX, 5XX) - */* ``` -------------------------------- ### GET /sign_ups/{id} Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/getsignuprequest.md Retrieves the details of a specific sign-up request using its unique ID. ```APIDOC ## GET /sign_ups/{id} ### Description Retrieves the details of a specific sign-up request by its unique identifier. ### Method GET ### Endpoint /sign_ups/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The ID of the sign-up to retrieve ### Request Example GET /sign_ups/sign_up_12345 ### Response #### Success Response (200) - **id** (str) - The ID of the sign-up - **status** (str) - The current status of the sign-up #### Response Example { "id": "sign_up_12345", "status": "complete" } ``` -------------------------------- ### InstanceSettings SDK Methods Source: https://github.com/clerk/clerk-sdk-python/blob/main/README.md Methods for managing instance settings, including fetching, updating, and retrieving communication, OAuth, organization, and protect settings. ```APIDOC ## InstanceSettings ### Description Provides methods to manage various settings for a Clerk instance. ### Methods * **get()**: Fetch the current instance settings. * **update(settings)**: Update instance settings. * **update_restrictions(restrictions)**: Update instance restrictions. * **get_communication()**: Get instance communication settings. * **update_communication(communication_settings)**: Update instance communication settings. * **get_o_auth_application_settings()**: Get OAuth application settings. * **update_o_auth_application_settings(oauth_settings)**: Update OAuth application settings. * **change_domain(domain_details)**: Update the production instance domain. * **get_organization_settings()**: Get instance organization settings. * **update_organization_settings(org_settings)**: Update instance organization settings. * **get_instance_protect()**: Get instance protect settings. * **update_instance_protect(protect_settings)**: Update instance protect settings. ``` -------------------------------- ### Install Clerk SDK with Poetry Source: https://github.com/clerk/clerk-sdk-python/blob/main/README.md Add the clerk-backend-api package to your project using Poetry for dependency management. ```bash poetry add clerk-backend-api ``` -------------------------------- ### Get Instance Organization Memberships Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Retrieves all organization user memberships for the given instance. Requires bearer token authentication. You can specify ordering and pagination parameters. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.get_instance_organization_memberships(order_by="", limit=20, offset=10) # Handle response print(res) ``` -------------------------------- ### Update User Metadata Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Example of updating user metadata with preferences. Note that this data can be modified from the frontend and is not guaranteed to be safe. ```python user.update(metadata={"preferences": {"theme": "dark"}}) ``` -------------------------------- ### Initialize SDK with Custom HTTP Client Source: https://github.com/clerk/clerk-sdk-python/blob/main/README.md Configure the SDK client with a custom httpx.Client instance to set default headers for all requests. This allows for centralized configuration of request-level settings. ```python from clerk_backend_api import Clerk import httpx http_client = httpx.Client(headers={"x-custom-header": "someValue"}) s = Clerk(client=http_client) ``` -------------------------------- ### GET /api/keys (Error Response) Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/getapikeysapikeysresponseresponsebody.md Details the 404 Not Found error response structure for the Get API Keys endpoint. ```APIDOC ## GET /api/keys ### Description Retrieves API keys. This documentation covers the 404 Not Found error response structure. ### Method GET ### Endpoint /api/keys ### Response #### Error Response (404) - **errors** (List[models.GetAPIKeysAPIKeysErrors]) - Required - A list of error objects returned when the resource is not found. ``` -------------------------------- ### Get User Billing Credit Balance - Python Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Retrieves the current credit balance for a specific user. Credits can be applied to reduce charges. Requires the user's ID and a bearer token for authentication. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.get_billing_credit_balance(user_id="") # Handle response print(res) ``` -------------------------------- ### Asynchronous SDK Example Usage Source: https://github.com/clerk/clerk-sdk-python/blob/main/README-PYPI.md Demonstrates how to use the Clerk SDK for Python to make asynchronous API requests using asyncio. ```APIDOC The same SDK client can also be used to make asynchronous requests by importing asyncio. ```python # Asynchronous Example import asyncio from clerk_backend_api import Clerk async def main(): async with Clerk( bearer_auth="", ) as clerk: res = await clerk.email_addresses.get_async(email_address_id="email_address_id_example") # Handle response print(res) asyncio.run(main()) ``` ``` -------------------------------- ### Get User Billing Subscription - Python Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Retrieves the billing subscription for a specific user. Use this to access subscription details, active plans, and payment status. Requires the user's ID and a bearer token for authentication. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.get_billing_subscription(user_id="") # Handle response print(res) ``` -------------------------------- ### Get User Organization Memberships Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Retrieves a paginated list of organization memberships for a given user. Ensure you have your bearer token and the correct user ID. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.get_organization_memberships(user_id="usr_1234567890", limit=20, offset=10) # Handle response print(res) ``` -------------------------------- ### Count Users with Filters Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Use this snippet to get a total count of users matching specific criteria such as email, phone number, external ID, or ban status. Ensure you have your bearer token configured. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.count(request={ "email_address": [ "user@example.com", ], "phone_number": [ "+1234567890", ], "external_id": [ "external-id-123", ], "username": [ "username123", ], "web3_wallet": [ "0x123456789abcdef", ], "user_id": [ "user-id-123", ], "organization_id": [ "John Doe", ], "query": "", "email_address_query": "", "phone_number_query": "", "username_query": "", "name_query": "", "banned": True, "last_active_at_before": 1700690400000, "last_active_at_after": 1700690400000, "last_active_at_since": 1700690400000, "created_at_before": 1730160000000, "created_at_after": 1730160000000, "last_sign_in_at_before": 1700690400000, "last_sign_in_at_after": 1700690400000, "provider": "", "provider_user_id": [ "", "", ], }) # Handle response print(res) ``` -------------------------------- ### Get User Source: https://github.com/clerk/clerk-sdk-python/blob/main/README-PYPI.md Retrieves a specific user by their ID. ```APIDOC ## Get User ### Description Retrieves a user. ### Method GET ### Endpoint /v1/users/{userId} ### Parameters #### Path Parameters - **userId** (string) - Required - The ID of the user to retrieve. ### Response #### Success Response (200) - **id** (string) - The ID of the user. - **email_addresses** (array) - Array of email addresses. - **phone_numbers** (array) - Array of phone numbers. - **web3_wallets** (array) - Array of web3 wallets. - **username** (string) - The username of the user. - **first_name** (string) - The first name of the user. - **last_name** (string) - The last name of the user. - **created_at** (integer) - Timestamp of creation. - **updated_at** (integer) - Timestamp of last update. - **last_active_at** (integer) - Timestamp of last activity. - **profile_image_url** (string) - URL of the profile image. - **primary_email_address_id** (string) - ID of the primary email address. - **primary_phone_number_id** (string) - ID of the primary phone number. - **primary_web3_wallet_id** (string) - ID of the primary web3 wallet. - **password_enabled** (boolean) - Whether password authentication is enabled. - **two_factor_enabled** (boolean) - Whether two-factor authentication is enabled. - **totp_enabled** (boolean) - Whether TOTP is enabled. - **backup_code_enabled** (boolean) - Whether backup codes are enabled. - **unsafe_metadata** (object) - User metadata. - **public_metadata** (object) - Public user metadata. - **private_metadata** (object) - Private user metadata. - **banned** (boolean) - Whether the user is banned. - **external_id** (string) - The external ID of the user. - **passkeys** (array) - Array of passkeys associated with the user. #### Response Example { "id": "user_abc123", "email_addresses": [ { "email_address": "test@example.com", "verification": { "status": "verified", "nonce": "" } } ], "phone_numbers": [], "web3_wallets": [], "username": "testuser", "first_name": "Test", "last_name": "User", "created_at": 1678886400, "updated_at": 1678886400, "last_active_at": 1678886400, "profile_image_url": "https://example.com/image.png", "primary_email_address_id": "ema_abc123", "primary_phone_number_id": null, "primary_web3_wallet_id": null, "password_enabled": true, "two_factor_enabled": false, "totp_enabled": false, "backup_code_enabled": false, "unsafe_metadata": {}, "public_metadata": {}, "private_metadata": {}, "banned": false, "external_id": null, "passkeys": [] } ``` -------------------------------- ### Synchronous SDK Example Usage Source: https://github.com/clerk/clerk-sdk-python/blob/main/README-PYPI.md Demonstrates how to use the Clerk SDK for Python to make synchronous API requests. ```APIDOC ## SDK Example Usage ### Example ```python # Synchronous Example from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.email_addresses.get(email_address_id="email_address_id_example") # Handle response print(res) ``` ``` -------------------------------- ### Get OAuth Access Token Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Fetches the OAuth access token for a user. If the token has expired and a refresh token is available, it will be refreshed automatically. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.get_o_auth_access_token(user_id="user_123", provider="oauth_google", paginated=True, limit=20, offset=10) # Handle response print(res) ``` -------------------------------- ### Adjust User Billing Credit Balance Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Use this snippet to increase or decrease a user's credit balance. Ensure you have the Clerk SDK installed and your bearer token configured. The idempotency key prevents duplicate requests. ```python import clerk_backend_api from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.adjust_billing_credit_balance(user_id="", amount=562473, action=clerk_backend_api.Action.DECREASE, idempotency_key="", currency="New Israeli Sheqel", note="") # Handle response print(res) ``` -------------------------------- ### models.Two Type Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/samlconnection.md Example of how to declare a variable of type models.Two. ```python value: models.Two = /* values here */ ``` -------------------------------- ### Delete User Profile Image with Python SDK Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md This code example demonstrates how to delete a user's profile image using the Clerk Python SDK. You need to provide the user ID for the operation. Authentication is handled via a bearer token. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.delete_profile_image(user_id="usr_test123") # Handle response print(res) ``` -------------------------------- ### models.One Type Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/samlconnection.md Example of how to declare a variable of type models.One. ```python value: models.One = /* values here */ ``` -------------------------------- ### create Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/oauthapplicationssdk/README.md Creates a new OAuth application with the given name and callback URL for an instance. The callback URL must be a valid URL. All URL schemes are allowed such as `http://`, `https://`, `myapp://`, etc... ```APIDOC ## POST /oauth_applications ### Description Creates a new OAuth application with the given name and callback URL. ### Method POST ### Endpoint /oauth_applications ### Parameters #### Request Body - **name** (string) - Required - The name of the OAuth application. - **redirect_uris** (array of strings) - Required - A list of valid redirect URIs for the OAuth application. - **scopes** (string) - Optional - A space-separated string of scopes to grant to the OAuth application. - **public** (boolean) - Optional - Whether the OAuth application is public. ### Request Example ```json { "name": "Example App", "redirect_uris": [ "" ], "scopes": "profile email public_metadata", "public": true } ``` ### Response #### Success Response (200) - **OAuthApplicationWithSecret** (object) - The created OAuth application with its secret. ### Errors - **models.ClerkErrors** (400, 403, 422) - application/json - **models.SDKError** (4XX, 5XX) - */* ``` -------------------------------- ### Upload File Stream Source: https://github.com/clerk/clerk-sdk-python/blob/main/README-PYPI.md Demonstrates how to upload a file as a stream to an endpoint, recommended for large files to conserve memory. Ensure the file is opened in binary read mode. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.set_profile_image(user_id="usr_test123", file={ "file_name": "example.file", "content": open("example.file", "rb"), }) # Handle response print(res) ``` -------------------------------- ### Get User Organization Memberships Source: https://github.com/clerk/clerk-sdk-python/blob/main/README-PYPI.md Retrieves all organization memberships for a user. ```APIDOC ## Get User Organization Memberships ### Description Retrieves all memberships for a user. ### Method GET ### Endpoint /v1/users/{userId}/organization_memberships ### Parameters #### Path Parameters - **userId** (string) - Required - The ID of the user. ### Response #### Success Response (200) - **data** (array) - Array of organization membership objects. - **total_count** (integer) - Total number of memberships. - **object** (string) - Type of object returned, always "list". #### Response Example { "object": "list", "data": [ { "id": "orga_mem_abc123", "organization": { "id": "org_xyz789", "name": "Example Org" }, "role": "admin", "created_at": 1678886400, "updated_at": 1678886400 } ], "total_count": 1, "object": "list" } ``` -------------------------------- ### GET /organization_invitations Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/organizationinvitations.md Retrieves a list of organization invitations associated with the account. ```APIDOC ## GET /organization_invitations ### Description Retrieves a paginated list of organization invitations. ### Method GET ### Endpoint /organization_invitations ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example GET /organization_invitations ### Response #### Success Response (200) - **data** (List[OrganizationInvitation]) - A list of organization invitation objects. - **total_count** (int) - The total number of organization invitations available. #### Response Example { "data": [ { "id": "inv_12345", "object": "organization_invitation", "email_address": "user@example.com", "role": "member", "organization_id": "org_12345", "status": "pending", "created_at": 1617981379, "updated_at": 1625581379 } ], "total_count": 10 } ``` -------------------------------- ### Create Billing Price Transition Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/billing/README.md Use this snippet to create a price transition for a subscription item. Ensure you have your bearer token and the necessary IDs for the subscription item, the current price, and the new price. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.billing.create_price_transition(subscription_item_id="", from_price_id="", to_price_id="") # Handle response print(res) ``` -------------------------------- ### Standalone Python script with uv Source: https://github.com/clerk/clerk-sdk-python/blob/main/README.md A standalone Python script demonstrating how to use the Clerk SDK, including dependency declaration for uv. ```python #!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.10" # dependencies = [ # "clerk-backend-api", # ] # /// from clerk_backend_api import Clerk sdk = Clerk( # SDK arguments ) # Rest of script here... ``` -------------------------------- ### User Web3 Wallet Example Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/user.md Represents a user's Web3 wallet address, including its verification status and timestamps. Use this to display or manage user Web3 wallets. ```json { "id": "wallet_id_123", "object": "web3_wallet", "web3_wallet": "0x123456789abcdef", "verification": { "status": "verified", "strategy": "web3_metamask_signature" }, "created_at": 1609459200, "updated_at": 1609459200 } ``` -------------------------------- ### Initialize VerificationWeb3VerificationStrategy Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/verificationweb3verificationstrategy.md Demonstrates how to import and use the VerificationWeb3VerificationStrategy enumeration to select a specific Web3 signature verification method. This is typically used when configuring authentication strategies for Web3-enabled applications. ```python from clerk_backend_api.models import VerificationWeb3VerificationStrategy value = VerificationWeb3VerificationStrategy.WEB3_METAMASK_SIGNATURE ``` -------------------------------- ### GET /credits Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/credits.md Retrieves the unified credits breakdown for a subscription item. ```APIDOC ## GET /credits ### Description Retrieves the unified credits breakdown for this subscription item. ### Method GET ### Endpoint /credits ### Response #### Success Response (200) - **proration** (Nullable[Proration]) - Description: N/A - **payer** (Nullable[CommerceSubscriptionItemPayer]) - Description: N/A - **total** (CommerceMoneyResponse) - Description: N/A #### Response Example ```json { "proration": { ... }, "payer": { ... }, "total": { ... } } ``` ``` -------------------------------- ### Instance Settings Configuration Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/updatedomainrequestbody.md Configure the proxy URL and secondary domain settings for your Clerk instance. ```APIDOC ## Instance Settings Configuration ### Description Configure the proxy URL and secondary domain settings for your Clerk instance. ### Method PUT ### Endpoint /v1/instance/settings ### Parameters #### Request Body - **proxy_url** (OptionalNullable[str]) - The full URL of the proxy that will forward requests to Clerk's Frontend API. Can only be updated for production instances. - **is_secondary** (OptionalNullable[bool]) - Whether this is a domain for a secondary app, meaning that any subdomain provided is significant and will be stored as part of the domain. This is useful for supporting multiple apps (one primary and multiple secondaries) on the same root domain (eTLD+1). ### Request Example ```json { "proxy_url": "http://proxy.example.com", "is_secondary": false } ``` ### Response #### Success Response (200) - **proxy_url** (str) - The configured proxy URL. - **is_secondary** (bool) - Indicates if the domain is for a secondary app. #### Response Example ```json { "proxy_url": "http://proxy.example.com", "is_secondary": false } ``` ``` -------------------------------- ### GET /commerce/credit-balance Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/commercecreditbalanceresponse.md Retrieves the current credit balance for a specific payer. ```APIDOC ## GET /commerce/credit-balance ### Description Retrieves the credit balance details for a payer, including the current balance amount and currency. ### Method GET ### Endpoint /commerce/credit-balance ### Parameters #### Path Parameters - **None** #### Query Parameters - **payer_id** (str) - Required - The unique identifier of the payer. ### Request Example GET /commerce/credit-balance?payer_id=pyr_12345 ### Response #### Success Response (200) - **object** (str) - String representing the object's type. Always "commerce_credit_balance". - **balance** (models.Balance) - The current credit balance. Null when the payer has never had credits. #### Response Example { "object": "commerce_credit_balance", "balance": { "amount": 1000, "currency": "usd" } } ``` -------------------------------- ### CreateAdminPortalLinkTokenObject Example Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/createadminportallinktokenobject.md Demonstrates how to import and access the ADMIN_PORTAL_LINK_TOKEN value from the CreateAdminPortalLinkTokenObject class. ```python from clerk_backend_api.models import CreateAdminPortalLinkTokenObject value = CreateAdminPortalLinkTokenObject.ADMIN_PORTAL_LINK_TOKEN ``` -------------------------------- ### Get Instance Protect Settings Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/instancesettingssdk/README.md Retrieves the current instance protect settings. Ensure you have initialized the Clerk client with your bearer token. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.instance_settings.get_instance_protect() # Handle response print(res) ``` -------------------------------- ### Get User Organization Invitations Source: https://github.com/clerk/clerk-sdk-python/blob/main/README-PYPI.md Retrieves all invitations sent to a user for organizations. ```APIDOC ## Get User Organization Invitations ### Description Retrieves all invitations for a user. ### Method GET ### Endpoint /v1/users/{userId}/organization_invitations ### Parameters #### Path Parameters - **userId** (string) - Required - The ID of the user. ### Response #### Success Response (200) - **data** (array) - Array of organization invitation objects. - **total_count** (integer) - Total number of invitations. - **object** (string) - Type of object returned, always "list". #### Response Example { "object": "list", "data": [ { "id": "inv_abc123", "organization": { "id": "org_xyz789", "name": "Example Org" }, "inviter_user_id": "user_def456", "email_address": "user@example.com", "role": "member", "status": "pending", "created_at": 1678886400, "updated_at": 1678886400 } ], "total_count": 1, "object": "list" } ``` -------------------------------- ### Import and Use VerificationScimVerificationStatus Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/verificationscimverificationstatus.md Demonstrates how to import and assign a value to VerificationScimVerificationStatus. Use this when you need to represent the verification status of a SCIM user. ```python from clerk_backend_api.models import VerificationScimVerificationStatus value = VerificationScimVerificationStatus.VERIFIED ``` -------------------------------- ### Import and Access SAML_CONNECTION Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/samlconnectionobject.md Demonstrates how to import the SAMLConnectionObject and access its SAML_CONNECTION attribute. ```python from clerk_backend_api.models import SAMLConnectionObject value = SAMLConnectionObject.SAML_CONNECTION ``` -------------------------------- ### Run Python script with uv Source: https://github.com/clerk/clerk-sdk-python/blob/main/README.md Execute a Python script that requires the clerk-backend-api package using the uvx command. ```shell uvx --from clerk-backend-api python ``` -------------------------------- ### GET /templates Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/template.md Retrieves the configuration and metadata for a specific notification or email template. ```APIDOC ## GET /templates ### Description Retrieves the details of a template, including its editability, subject, and available variables for interpolation. ### Method GET ### Endpoint /templates ### Parameters #### Request Body - **can_revert** (bool) - Optional - Whether this template can be reverted to the system default. - **can_delete** (bool) - Optional - Whether this template can be deleted. - **can_edit_body** (bool) - Optional - Whether the body of this template can be edited. - **can_toggle** (bool) - Optional - Whether this template can be enabled or disabled. - **subject** (str) - Optional - Email subject line. - **markup** (str) - Optional - Editor markup used to generate the body. - **body** (str) - Optional - The template body before variable interpolation. - **available_variables** (List[str]) - Required - List of variables available for use. - **required_variables** (List[str]) - Required - List of variables that must be contained in the body. - **from_email_name** (str) - Optional - The display name for the sender. ### Request Example { "subject": "Welcome to our service!", "body": "You are now signed up. Welcome!" } ### Response #### Success Response (200) - **available_variables** (List[str]) - List of variables available for use in the template body. - **required_variables** (List[str]) - List of variables that must be contained in the template body. #### Response Example { "available_variables": ["user.name", "user.email"], "required_variables": ["user.name"] } ``` -------------------------------- ### Import and Use Provider Enum Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/provider.md Demonstrates how to import the Provider enum and assign a specific provider value to a variable. ```python from clerk_backend_api.models import Provider value = Provider.SAML_CUSTOM ``` -------------------------------- ### GET /permissions Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/permissions.md Retrieves a list of permissions and the total count of available permissions. ```APIDOC ## GET /permissions ### Description Retrieves a list of permissions and the total count of available permissions. ### Response #### Success Response (200) - **data** (List[models.Permission]) - Required - A list of permission objects. - **total_count** (int) - Required - Total number of permissions. ``` -------------------------------- ### GET /organizations Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/organizations.md Retrieves a paginated list of organizations available in the Clerk project. ```APIDOC ## GET /organizations ### Description Retrieves a list of organizations. This endpoint returns the organization objects and the total count of organizations available. ### Method GET ### Endpoint /organizations ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example GET /organizations ### Response #### Success Response (200) - **data** (List[Organization]) - A list of organization objects. - **total_count** (int) - The total number of organizations. #### Response Example { "data": [ { "id": "org_1234", "name": "Sample Organization" } ], "total_count": 1 } ``` -------------------------------- ### list_plans Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/billing/README.md Returns a list of all billing plans for the instance. The plans are returned sorted by creation date, with the newest plans appearing first. This includes both free and paid plans. Pagination is supported. ```APIDOC ## list_plans ### Description Returns a list of all billing plans for the instance. The plans are returned sorted by creation date, with the newest plans appearing first. This includes both free and paid plans. Pagination is supported. ### Method GET ### Endpoint /billing/plans ### Parameters #### Query Parameters - **paginated** (boolean) - Optional - Whether to paginate the results. - **limit** (integer) - Optional - The maximum number of plans to return. - **offset** (integer) - Optional - The number of plans to skip before returning results. - **payer_type** (PayerType) - Optional - The type of payer to filter by (e.g., ORG). ### Request Example ```python import clerk_backend_api from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.billing.list_plans(paginated=True, limit=20, offset=10, payer_type=clerk_backend_api.PayerType.ORG) # Handle response print(res) ``` ### Response #### Success Response (200) - **data** (array) - A list of billing plans. - **total_count** (integer) - The total number of billing plans available. - **next_cursor** (string) - A cursor for fetching the next page of results. ``` -------------------------------- ### GET /waitlist Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/listwaitlistentriesrequest.md Retrieve a list of waitlist entries with support for pagination and filtering. ```APIDOC ## GET /waitlist ### Description Retrieves a list of waitlist entries. Supports pagination via limit and offset, and filtering via a query string. ### Method GET ### Endpoint /waitlist ### Parameters #### Query Parameters - **limit** (int) - Optional - Applies a limit to the number of results returned. Used for pagination. - **offset** (int) - Optional - Skip the first `offset` results when paginating. Must be >= 0. - **query** (str) - Optional - Filter waitlist entries by `email_address` or `id`. ### Request Example GET /waitlist?limit=20&offset=10&query=user@example.com ### Response #### Success Response (200) - **data** (list) - List of waitlist entry objects. #### Response Example { "data": [ { "id": "wl_123", "email_address": "user@example.com" } ] } ``` -------------------------------- ### InstanceSettings SDK Source: https://github.com/clerk/clerk-sdk-python/blob/main/README-PYPI.md Provides methods to fetch and update various settings for a Clerk instance, including general settings, restrictions, communication preferences, OAuth applications, domain, organization settings, and protect settings. ```APIDOC ## InstanceSettings SDK ### Description Provides methods to fetch and update various settings for a Clerk instance. ### Methods * **get** - Fetch the current instance * **update** - Update instance settings * **update_restrictions** - Update instance restrictions * **get_communication** - Get instance communication settings * **update_communication** - Update instance communication settings * **get_o_auth_application_settings** - Get OAuth application settings * **update_o_auth_application_settings** - Update OAuth application settings * **change_domain** - Update production instance domain * **get_organization_settings** - Get instance organization settings * **update_organization_settings** - Update instance organization settings * **get_instance_protect** - Get instance protect settings * **update_instance_protect** - Update instance protect settings ``` -------------------------------- ### GET /allowlist_identifiers Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/listallowlistidentifiersrequest.md Retrieve a list of allowlist identifiers with optional pagination support. ```APIDOC ## GET /allowlist_identifiers ### Description Retrieves a list of identifiers currently in the allowlist. Supports pagination through limit and offset parameters. ### Method GET ### Endpoint /allowlist_identifiers ### Parameters #### Query Parameters - **paginated** (bool) - Optional - Whether to paginate the results. - **limit** (int) - Optional - Applies a limit to the number of results returned. - **offset** (int) - Optional - Skip the first `offset` results when paginating. ### Request Example GET /allowlist_identifiers?limit=20&offset=10 ### Response #### Success Response (200) - **data** (array) - List of allowlist identifier objects. - **total_count** (int) - Total number of identifiers available. #### Response Example { "data": [ { "identifier": "user@example.com", "identifier_type": "email_address" } ], "total_count": 1 } ``` -------------------------------- ### GET /users Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/getuserlistrequest.md Retrieves a list of users. Supports filtering by name query. ```APIDOC ## GET /users ### Description Retrieves users with names that match the given query, via case-insensitive partial match. ### Method GET ### Endpoint /users ### Parameters #### Query Parameters - **name_query** (Optional[str]) - Optional - Returns users with names that match the given query, via case-insensitive partial match. ### Request Example ```json { "message": "No request body for GET request" } ``` ### Response #### Success Response (200) - **users** (list) - A list of user objects matching the query. #### Response Example ```json { "users": [ { "id": "user_123", "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com" } ] } ``` ``` -------------------------------- ### Create User - Python Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/sdks/users/README.md Use this snippet to create a new user with Clerk. It supports setting various user attributes like name, contact information, authentication details, metadata, and more. Ensure you replace placeholder values with your actual token and data. ```python from clerk_backend_api import Clerk with Clerk( bearer_auth="", ) as clerk: res = clerk.users.create(external_id="ext-id-001", first_name="John", last_name="Doe", locale="en", email_address=[ "john.doe@example.com", ], phone_number=[ "+12345678901", ], web3_wallet=[ "0x123456789abcdef0x123456789abcdef", ], username="johndoe123", password="Secure*Pass4", password_digest="$argon2i$v=19$m=4096,t=3,p=1$4t6CL3P7YiHBtwESXawI8Hm20zJj4cs7/4/G3c187e0$m7RQFczcKr5bIR0IIxbpO2P0tyrLjf3eUW3M3QSwnLc", password_hasher="", skip_password_checks=False, skip_password_requirement=False, totp_secret="base32totpsecretkey", backup_codes=[ "123456", "654321", ], public_metadata={ "role": "user", }, private_metadata={ "internal_id": "789", }, unsafe_metadata={ "preferences": { "theme": "dark", }, }, delete_self_enabled=True, legal_accepted_at="", skip_legal_checks=False, skip_user_requirement=True, create_organization_enabled=None, create_organizations_limit=81560, created_at="2023-03-15T07:15:20.902Z", bypass_client_trust=True, banned=True, locked=False) # Handle response print(res) ``` -------------------------------- ### Import and Access SAML_CONNECTION Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/samlconnection2object.md Demonstrates how to import the SAMLConnection2Object and access its SAML_CONNECTION attribute. ```python from clerk_backend_api.models import SAMLConnection2Object value = SAMLConnection2Object.SAML_CONNECTION ``` -------------------------------- ### GET /billing/statements/{statement_id} Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/getbillingstatementrequest.md Retrieves a specific billing statement by its unique identifier. ```APIDOC ## GET /billing/statements/{statement_id} ### Description Retrieves the details of a specific billing statement associated with the provided statement ID. ### Method GET ### Endpoint /billing/statements/{statement_id} ### Parameters #### Path Parameters - **statement_id** (str) - Required - The ID of the statement to retrieve. ### Request Example GET /billing/statements/stmt_12345 ### Response #### Success Response (200) - **statement_id** (str) - The ID of the retrieved statement. - **data** (object) - The billing statement details. #### Response Example { "statement_id": "stmt_12345", "status": "paid", "amount": 5000 } ``` -------------------------------- ### Use models.ErrorClerkError Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/error.md Example of how to use the `models.ErrorClerkError` type. Ensure the `models` module is imported. ```python value: models.ErrorClerkError = /* values here */ ``` -------------------------------- ### Using VerificationScimVerificationStrategy SCIM Source: https://github.com/clerk/clerk-sdk-python/blob/main/docs/models/verificationscimverificationstrategy.md Demonstrates how to import and use the SCIM value from the VerificationScimVerificationStrategy enum. ```python from clerk_backend_api.models import VerificationScimVerificationStrategy value = VerificationScimVerificationStrategy.SCIM ```