Customers

June 8, 2026 ยท View on GitHub

(customers)

Overview

Available Operations

list

List customers.

Scopes: customers:read customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.list(organization_id="1dbfc517-0bbf-4301-9ba8-555ca42b9737", page=1, limit=10)

    while res is not None:
        # Handle items

        res = res.next()

Parameters

ParameterTypeRequiredDescription
organization_idOptionalNullable[models.CustomersListQueryParamOrganizationIDFilter]:heavy_minus_sign:Filter by organization ID.
emailOptionalNullable[str]:heavy_minus_sign:Filter by exact email.
queryOptionalNullable[str]:heavy_minus_sign:Filter by name, email, or external ID.
activeOptionalNullable[bool]:heavy_minus_sign:Filter by active customers, i.e. customers with at least one trialing, active or past_due subscription.
pageOptional[int]:heavy_minus_sign:Page number, defaults to 1.
limitOptional[int]:heavy_minus_sign:Size of a page, defaults to 10. Maximum is 100.
sortingList[models.CustomerSortProperty]:heavy_minus_sign:Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order.
metadataDict[str, models.MetadataQuery]:heavy_minus_sign:Filter by metadata key-value pairs. It uses the deepObject style, e.g. ?metadata[key]=value.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.CustomersListResponse

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

create

Create a customer.

Scopes: customers:write

Example Usage

import polar_sdk
from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.create(request={
        "external_id": "usr_1337",
        "name": "John Doe",
        "billing_address": {
            "country": polar_sdk.AddressInputCountryAlpha2Input.US,
        },
        "locale": "en",
        "organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
        "owner": {
            "email": "member@example.com",
            "name": "Jane Doe",
            "external_id": "usr_1337",
        },
        "type": "individual",
        "email": "customer@example.com",
    })

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
requestmodels.CustomerCreate:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Customer

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

export

Export customers as a CSV file.

Scopes: customers:read customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.export(organization_id="1dbfc517-0bbf-4301-9ba8-555ca42b9737")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
organization_idOptionalNullable[models.CustomersExportQueryParamOrganizationID]:heavy_minus_sign:Filter by organization ID.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.CustomersExportResponse

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

get

Get a customer by ID.

Scopes: customers:read customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.get(id="<value>")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
idstr:heavy_check_mark:The customer ID.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Customer

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

update

Update a customer.

Scopes: customers:write

Example Usage

import polar_sdk
from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.update(id="<value>", customer_update={
        "email": "customer@example.com",
        "name": "John Doe",
        "billing_address": {
            "country": polar_sdk.AddressInputCountryAlpha2Input.US,
        },
        "locale": "en",
        "external_id": "usr_1337",
    })

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
idstr:heavy_check_mark:The customer ID.
customer_updatemodels.CustomerUpdate:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Customer

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

delete

Delete a customer.

This action cannot be undone and will immediately:

  • Cancel any active subscriptions for the customer
  • Revoke all their benefits
  • Clear any external_id

Use it only in the context of deleting a user within your own service. Otherwise, use more granular API endpoints to cancel a specific subscription or revoke certain benefits.

Note: The customers information will nonetheless be retained for historic orders and subscriptions.

Set anonymize=true to also anonymize PII for GDPR compliance.

Scopes: customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    polar.customers.delete(id="<value>", anonymize=False)

    # Use the SDK ...

Parameters

ParameterTypeRequiredDescription
idstr:heavy_check_mark:The customer ID.
anonymizeOptional[bool]:heavy_minus_sign:If true, also anonymize the customer's personal data for GDPR compliance. This replaces email with a hashed version, hashes name and billing name (name preserved for businesses with tax_id), clears billing address, and removes OAuth account data.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

get_external

Get a customer by external ID.

Scopes: customers:read customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.get_external(external_id="<id>")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
external_idstr:heavy_check_mark:The customer external ID.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Customer

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

update_external

Update a customer by external ID.

Scopes: customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.update_external(external_id="<id>", customer_update_external_id={
        "email": "customer@example.com",
        "name": "John Doe",
        "billing_address": None,
        "locale": "en",
    })

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
external_idstr:heavy_check_mark:The customer external ID.
customer_update_external_idmodels.CustomerUpdateExternalID:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Customer

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

delete_external

Delete a customer by external ID.

Immediately cancels any active subscriptions and revokes any active benefits.

Set anonymize=true to also anonymize PII for GDPR compliance.

Scopes: customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    polar.customers.delete_external(external_id="<id>", anonymize=False)

    # Use the SDK ...

Parameters

ParameterTypeRequiredDescription
external_idstr:heavy_check_mark:The customer external ID.
anonymizeOptional[bool]:heavy_minus_sign:If true, also anonymize the customer's personal data for GDPR compliance.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

get_state

Get a customer state by ID.

The customer state includes information about the customer's active subscriptions and benefits.

It's the ideal endpoint to use when you need to get a full overview of a customer's status.

Scopes: customers:read customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.get_state(id="<value>")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
idstr:heavy_check_mark:The customer ID.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.CustomerState

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

get_state_external

Get a customer state by external ID.

The customer state includes information about the customer's active subscriptions and benefits.

It's the ideal endpoint to use when you need to get a full overview of a customer's status.

Scopes: customers:read customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.get_state_external(external_id="<id>")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
external_idstr:heavy_check_mark:The customer external ID.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.CustomerState

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

list_payment_methods

Get saved payment methods of a customer.

Scopes: customers:read customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.list_payment_methods(id="<value>", page=1, limit=10)

    while res is not None:
        # Handle items

        res = res.next()

Parameters

ParameterTypeRequiredDescription
idstr:heavy_check_mark:The customer ID.
pageOptional[int]:heavy_minus_sign:Page number, defaults to 1.
limitOptional[int]:heavy_minus_sign:Size of a page, defaults to 10. Maximum is 100.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.CustomersListPaymentMethodsResponse

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

list_payment_methods_external

Get saved payment methods of a customer by external ID.

Scopes: customers:read customers:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.customers.list_payment_methods_external(external_id="<id>", page=1, limit=10)

    while res is not None:
        # Handle items

        res = res.next()

Parameters

ParameterTypeRequiredDescription
external_idstr:heavy_check_mark:The customer external ID.
pageOptional[int]:heavy_minus_sign:Page number, defaults to 1.
limitOptional[int]:heavy_minus_sign:Size of a page, defaults to 10. Maximum is 100.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.CustomersListPaymentMethodsExternalResponse

Errors

Error TypeStatus CodeContent Type
models.ResourceNotFound404application/json
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*