# `PolarExpress.Services.CustomersService`
[🔗](https://github.com/jeffhuen/polar_express/blob/main/lib/polar_express/services/customers_service.ex#L2)

Customers

Customers API operations.

# `create_customer`

```elixir
@spec create_customer(PolarExpress.Client.t(), map(), keyword()) ::
  {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
  | {:error, PolarExpress.Error.t()}
```

Create Customer

Create a customer.

**Scopes**: `customers:write`

See `PolarExpress.Params.CustomersCreateCustomerParams` for parameter details.

# `delete_customer`

```elixir
@spec delete_customer(PolarExpress.Client.t(), String.t(), map(), keyword()) ::
  {:ok, term()} | {:error, PolarExpress.Error.t()}
```

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.

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

**Scopes**: `customers:write`

See `PolarExpress.Params.CustomersDeleteCustomerParams` for parameter details.

# `delete_customer_by_external_id`

```elixir
@spec delete_customer_by_external_id(
  PolarExpress.Client.t(),
  String.t(),
  map(),
  keyword()
) ::
  {:ok, term()} | {:error, PolarExpress.Error.t()}
```

Delete Customer by External ID

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`

See `PolarExpress.Params.CustomersDeleteCustomerByExternalIdParams` for parameter details.

# `export_customers`

```elixir
@spec export_customers(PolarExpress.Client.t(), map(), keyword()) ::
  {:ok, term()} | {:error, PolarExpress.Error.t()}
```

Export Customers

Export customers as a CSV file.

**Scopes**: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersExportCustomersParams` for parameter details.

# `get_customer`

```elixir
@spec get_customer(PolarExpress.Client.t(), String.t(), map(), keyword()) ::
  {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
  | {:error, PolarExpress.Error.t()}
```

Get Customer

Get a customer by ID.

**Scopes**: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersGetCustomerParams` for parameter details.

# `get_customer_by_external_id`

```elixir
@spec get_customer_by_external_id(
  PolarExpress.Client.t(),
  String.t(),
  map(),
  keyword()
) ::
  {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
  | {:error, PolarExpress.Error.t()}
```

Get Customer by External ID

Get a customer by external ID.

**Scopes**: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersGetCustomerByExternalIdParams` for parameter details.

# `get_customer_state`

```elixir
@spec get_customer_state(PolarExpress.Client.t(), String.t(), map(), keyword()) ::
  {:ok, PolarExpress.Schemas.CustomerState.t()}
  | {:error, PolarExpress.Error.t()}
```

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`

See `PolarExpress.Params.CustomersGetCustomerStateParams` for parameter details.

# `get_customer_state_by_external_id`

```elixir
@spec get_customer_state_by_external_id(
  PolarExpress.Client.t(),
  String.t(),
  map(),
  keyword()
) ::
  {:ok, PolarExpress.Schemas.CustomerState.t()}
  | {:error, PolarExpress.Error.t()}
```

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`

See `PolarExpress.Params.CustomersGetCustomerStateByExternalIdParams` for parameter details.

# `list_customers`

```elixir
@spec list_customers(PolarExpress.Client.t(), map(), keyword()) ::
  {:ok, PolarExpress.ListObject.t()} | {:error, PolarExpress.Error.t()}
```

List Customers

List customers.

**Scopes**: `customers:read` `customers:write`

See `PolarExpress.Params.CustomersListCustomersParams` for parameter details.

# `update_customer`

```elixir
@spec update_customer(PolarExpress.Client.t(), String.t(), map(), keyword()) ::
  {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
  | {:error, PolarExpress.Error.t()}
```

Update Customer

Update a customer.

**Scopes**: `customers:write`

See `PolarExpress.Params.CustomersUpdateCustomerParams` for parameter details.

# `update_customer_by_external_id`

```elixir
@spec update_customer_by_external_id(
  PolarExpress.Client.t(),
  String.t(),
  map(),
  keyword()
) ::
  {:ok, PolarExpress.Schemas.CustomerWithMembers.t()}
  | {:error, PolarExpress.Error.t()}
```

Update Customer by External ID

Update a customer by external ID.

**Scopes**: `customers:write`

See `PolarExpress.Params.CustomersUpdateCustomerByExternalIdParams` for parameter details.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
