Polar::Api::Customers
API client for customers operations
Constants
Constructors
Creates a new Customers instance
@param client [Client] The Polar API client instance
Instance methods
Create Customer
Create a customer.
Scopes: customers:write
Endpoint: POST /v1/customers/
Parameters:
body(required): Request body as Polar::Models::CustomerCreate
Returns: Polar::Models::Customer
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Delete Customer
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.
Scopes: customers:write
Endpoint: DELETE /v1/customers/{id}
Parameters:
id(required): The customer ID.
Returns: JSON response string
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Delete Customer by External ID
Delete a customer by external ID.
Immediately cancels any active subscriptions and revokes any active benefits.
Scopes: customers:write
Endpoint: DELETE /v1/customers/external/{external_id}
Parameters:
external_id(required): The customer external ID.
Returns: JSON response string
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Export Customers
Export customers as a CSV file.
Scopes: customers:read customers:write
Endpoint: GET /v1/customers/export
Parameters:
organization_id(optional): Filter by organization ID.
Returns: JSON response string
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Get Customer
Get a customer by ID.
Scopes: customers:read customers:write
Endpoint: GET /v1/customers/{id}
Parameters:
id(required): The customer ID.
Returns: Polar::Models::Customer
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Get Customer Balance
Get customer balance information.
Scopes: customers:read customers:write
Endpoint: GET /v1/customers/{id}/balance
Parameters:
id(required): The customer ID.
Returns: Polar::Models::CustomerBalance
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Get Customer by External ID
Get a customer by external ID.
Scopes: customers:read customers:write
Endpoint: GET /v1/customers/external/{external_id}
Parameters:
external_id(required): The customer external ID.
Returns: Polar::Models::Customer
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Get Customer 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
Endpoint: GET /v1/customers/{id}/state
Parameters:
id(required): The customer ID.
Returns: Polar::Models::CustomerState
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Get Customer State by External ID
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
Endpoint: GET /v1/customers/external/{external_id}/state
Parameters:
external_id(required): The customer external ID.
Returns: Polar::Models::CustomerState
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
List Customers
List customers.
Scopes: customers:read customers:write
Endpoint: GET /v1/customers/
Parameters:
organization_id(optional): Filter by organization ID.email(optional): Filter by exact email.query(optional): Filter by name, email, or external ID.page(optional): Page number, defaults to 1.limit(optional): Size of a page, defaults to 10. Maximum is 100.sorting(optional): 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.metadata(optional): Filter by metadata key-value pairs. It uses the deepObject style, e.g. ?metadata[key]=value.
Returns: Polar::Models::ListResource(Polar::Models::Customer)
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Update Customer
Update a customer.
Scopes: customers:write
Endpoint: PATCH /v1/customers/{id}
Parameters:
id(required): The customer ID.body(required): Request body as Polar::Models::CustomerUpdate
Returns: Polar::Models::Customer
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors
Update Customer by External ID
Update a customer by external ID.
Scopes: customers:write
Endpoint: PATCH /v1/customers/external/{external_id}
Parameters:
external_id(required): The customer external ID.body(required): Request body as Polar::Models::CustomerUpdateExternalID
Returns: Polar::Models::Customer
Raises:
ResourceNotFoundErroron 404NotPermittedErroron 403HTTPValidationErroron 422PolarErroron other errors