# `Polarex.Mcp`
[🔗](https://github.com/giusdp/polarex/blob/main/lib/polarex/operations/mcp.ex#L1)

Provides API endpoints related to mcp

# `customer_meters_get`

```elixir
@spec customer_meters_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerMeter.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Customer Meter

Get a customer meter by ID.

**Scopes**: `customer_meters:read`

# `customer_meters_list`

```elixir
@spec customer_meters_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceCustomerMeter.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Customer Meters

List customer meters.

**Scopes**: `customer_meters:read`

## Options

  * `organization_id`: Filter by organization ID.
  * `customer_id`: Filter by customer ID.
  * `external_customer_id`: Filter by external customer ID.
  * `meter_id`: Filter by meter ID.
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: 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.

# `customers_create`

```elixir
@spec customers_create(
  body :: Polarex.CustomerIndividualCreate.t() | Polarex.CustomerTeamCreate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

Create Customer

Create a customer.

**Scopes**: `customers:write`

## Request Body

**Content Types**: `application/json`

# `customers_delete`

```elixir
@spec customers_delete(id :: String.t(), opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.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`

## Options

  * `anonymize`: 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.

# `customers_delete_external`

```elixir
@spec customers_delete_external(external_id :: String.t(), opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.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`

## Options

  * `anonymize`: If true, also anonymize the customer's personal data for GDPR compliance.

# `customers_export`

```elixir
@spec customers_export(opts :: keyword()) ::
  {:ok, map() | String.t()} | {:error, Polarex.HTTPValidationError.t()}
```

Export Customers

Export customers as a CSV file.

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

## Options

  * `organization_id`: Filter by organization ID.

# `customers_get`

```elixir
@spec customers_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Customer

Get a customer by ID.

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

# `customers_get_external`

```elixir
@spec customers_get_external(external_id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Customer by External ID

Get a customer by external ID.

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

# `customers_get_state`

```elixir
@spec customers_get_state(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerStateIndividual.t() | Polarex.CustomerStateTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.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`

# `customers_get_state_external`

```elixir
@spec customers_get_state_external(external_id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CustomerStateIndividual.t() | Polarex.CustomerStateTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.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`

# `customers_list`

```elixir
@spec customers_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceCustomer.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Customers

List customers.

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

## Options

  * `organization_id`: Filter by organization ID.
  * `email`: Filter by exact email.
  * `query`: Filter by name, email, or external ID.
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: 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`: Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.

# `customers_update`

```elixir
@spec customers_update(
  id :: String.t(),
  body :: Polarex.CustomerUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Update Customer

Update a customer.

**Scopes**: `customers:write`

## Request Body

**Content Types**: `application/json`

# `customers_update_external`

```elixir
@spec customers_update_external(
  external_id :: String.t(),
  body :: Polarex.CustomerUpdateExternalID.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.CustomerIndividual.t() | Polarex.CustomerTeam.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Update Customer by External ID

Update a customer by external ID.

**Scopes**: `customers:write`

## Request Body

**Content Types**: `application/json`

# `members_create_member`

```elixir
@spec members_create_member(body :: Polarex.MemberCreate.t(), opts :: keyword()) ::
  {:ok, Polarex.Member.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Create Member

Create a new member for a customer.

Only B2B customers with the member management feature enabled can add members.
The authenticated user or organization must have access to the customer's organization.

**Scopes**: `members:write`

## Request Body

**Content Types**: `application/json`

# `members_delete_member`

```elixir
@spec members_delete_member(id :: String.t(), opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Delete Member

Delete a member.

The authenticated user or organization must have access to the member's organization.

**Scopes**: `members:write`

# `members_delete_member_by_external_id`

```elixir
@spec members_delete_member_by_external_id(
  external_id :: String.t(),
  opts :: keyword()
) ::
  :ok | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Delete Member by External ID

Delete a member by external ID. One of customer_id or external_customer_id must be specified.

**Scopes**: `members:write`

## Options

  * `customer_id`: The customer ID.
  * `external_customer_id`: The customer external ID.

# `members_get_member`

```elixir
@spec members_get_member(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.Member.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Member

Get a member by ID.

The authenticated user or organization must have access to the member's organization.

**Scopes**: `members:read` `members:write`

# `members_get_member_by_external_id`

```elixir
@spec members_get_member_by_external_id(external_id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.Member.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Member by External ID

Get a member by external ID. One of customer_id or external_customer_id must be specified.

**Scopes**: `members:read` `members:write`

## Options

  * `customer_id`: The customer ID.
  * `external_customer_id`: The customer external ID.

# `members_list_members`

```elixir
@spec members_list_members(opts :: keyword()) ::
  {:ok, Polarex.ListResourceMember.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Members

List members with optional customer ID filter.

**Scopes**: `members:read` `members:write`

## Options

  * `customer_id`: Filter by customer ID.
  * `external_customer_id`: Filter by customer external ID.
  * `role`: Filter by member role.
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: 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.

# `members_update_member`

```elixir
@spec members_update_member(
  id :: String.t(),
  body :: Polarex.MemberUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Member.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Update Member

Update a member.

Only name and role can be updated.
The authenticated user or organization must have access to the member's organization.

**Scopes**: `members:write`

## Request Body

**Content Types**: `application/json`

# `members_update_member_by_external_id`

```elixir
@spec members_update_member_by_external_id(
  external_id :: String.t(),
  body :: Polarex.MemberUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Member.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Update Member by External ID

Update a member by external ID. One of customer_id or external_customer_id must be specified.

**Scopes**: `members:write`

## Options

  * `customer_id`: The customer ID.
  * `external_customer_id`: The customer external ID.

## Request Body

**Content Types**: `application/json`

# `metrics_create_dashboard`

```elixir
@spec metrics_create_dashboard(
  body :: Polarex.MetricDashboardCreate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.MetricDashboardSchema.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

Create Metric Dashboard

Create a user-defined metric dashboard.

**Scopes**: `metrics:write`

## Request Body

**Content Types**: `application/json`

# `metrics_delete_dashboard`

```elixir
@spec metrics_delete_dashboard(id :: String.t(), opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t()}
```

Delete Metric Dashboard

Delete a user-defined metric dashboard.

**Scopes**: `metrics:write`

# `metrics_export`

```elixir
@spec metrics_export(opts :: keyword()) ::
  {:ok, map() | String.t()} | {:error, Polarex.HTTPValidationError.t()}
```

Export Metrics

Export metrics as a CSV file.

**Scopes**: `metrics:read`

## Options

  * `start_date`: Start date.
  * `end_date`: End date.
  * `timezone`: Timezone to use for the timestamps. Default is UTC.
  * `interval`: Interval between two timestamps.
  * `organization_id`: Filter by organization ID.
  * `product_id`: Filter by product ID.
  * `billing_type`: Filter by billing type. `recurring` will filter data corresponding to subscriptions creations or renewals. `one_time` will filter data corresponding to one-time purchases.
  * `customer_id`: Filter by customer ID.
  * `metrics`: List of metric slugs to include in the export. If not provided, all metrics are exported.

# `metrics_get`

```elixir
@spec metrics_get(opts :: keyword()) ::
  {:ok, Polarex.MetricsResponse.t()} | {:error, Polarex.HTTPValidationError.t()}
```

Get Metrics

Get metrics about your orders and subscriptions.

Currency values are output in cents.

**Scopes**: `metrics:read`

## Options

  * `start_date`: Start date.
  * `end_date`: End date.
  * `timezone`: Timezone to use for the timestamps. Default is UTC.
  * `interval`: Interval between two timestamps.
  * `organization_id`: Filter by organization ID.
  * `product_id`: Filter by product ID.
  * `billing_type`: Filter by billing type. `recurring` will filter data corresponding to subscriptions creations or renewals. `one_time` will filter data corresponding to one-time purchases.
  * `customer_id`: Filter by customer ID.
  * `metrics`: List of metric slugs to focus on. When provided, only the queries needed for these metrics will be executed, improving performance. If not provided, all metrics are returned.

# `metrics_get_dashboard`

```elixir
@spec metrics_get_dashboard(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.MetricDashboardSchema.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

Get Metric Dashboard

Get a user-defined metric dashboard by ID.

**Scopes**: `metrics:read`

# `metrics_limits`

```elixir
@spec metrics_limits(opts :: keyword()) :: {:ok, Polarex.MetricsLimits.t()} | :error
```

Get Metrics Limits

Get the interval limits for the metrics endpoint.

**Scopes**: `metrics:read`

# `metrics_list_dashboards`

```elixir
@spec metrics_list_dashboards(opts :: keyword()) ::
  {:ok, [Polarex.MetricDashboardSchema.t()]}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Metric Dashboards

List user-defined metric dashboards.

**Scopes**: `metrics:read`

## Options

  * `organization_id`: Filter by organization ID.

# `metrics_update_dashboard`

```elixir
@spec metrics_update_dashboard(
  id :: String.t(),
  body :: Polarex.MetricDashboardUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.MetricDashboardSchema.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

Update Metric Dashboard

Update a user-defined metric dashboard.

**Scopes**: `metrics:write`

## Request Body

**Content Types**: `application/json`

# `orders_export`

```elixir
@spec orders_export(opts :: keyword()) ::
  {:ok, map() | String.t()} | {:error, Polarex.HTTPValidationError.t()}
```

Export Orders

Export orders as a CSV file.

**Scopes**: `orders:read`

## Options

  * `organization_id`: Filter by organization ID.
  * `product_id`: Filter by product ID.

# `orders_generate_invoice`

```elixir
@spec orders_generate_invoice(id :: String.t(), opts :: keyword()) ::
  {:ok, map()}
  | {:error,
     Polarex.MissingInvoiceBillingDetails.t() | Polarex.NotPaidOrder.t()}
```

Generate Order Invoice

Trigger generation of an order's invoice.

**Scopes**: `orders:read`

# `orders_get`

```elixir
@spec orders_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.Order.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Order

Get an order by ID.

**Scopes**: `orders:read`

# `orders_invoice`

```elixir
@spec orders_invoice(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.OrderInvoice.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Order Invoice

Get an order's invoice data.

**Scopes**: `orders:read`

# `orders_list`

```elixir
@spec orders_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceOrder.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Orders

List orders.

**Scopes**: `orders:read`

## Options

  * `organization_id`: Filter by organization ID.
  * `product_id`: Filter by product ID.
  * `product_billing_type`: Filter by product billing type. `recurring` will filter data corresponding to subscriptions creations or renewals. `one_time` will filter data corresponding to one-time purchases.
  * `discount_id`: Filter by discount ID.
  * `customer_id`: Filter by customer ID.
  * `external_customer_id`: Filter by customer external ID.
  * `checkout_id`: Filter by checkout ID.
  * `subscription_id`: Filter by subscription ID.
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: 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`: Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.

# `orders_receipt`

```elixir
@spec orders_receipt(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.OrderReceipt.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Order Receipt

Get a presigned URL to download an order's receipt PDF.

**Scopes**: `orders:read`

# `orders_update`

```elixir
@spec orders_update(
  id :: String.t(),
  body :: Polarex.OrderUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Order.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Update Order

Update an order.

**Scopes**: `orders:write`

## Request Body

**Content Types**: `application/json`

# `organization_access_tokens_create`

```elixir
@spec organization_access_tokens_create(
  body :: Polarex.OrganizationAccessTokenCreate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.OrganizationAccessTokenCreateResponse.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

Create

**Scopes**: `organization_access_tokens:write`

## Request Body

**Content Types**: `application/json`

# `organization_access_tokens_delete`

```elixir
@spec organization_access_tokens_delete(id :: String.t(), opts :: keyword()) ::
  :ok | {:error, Polarex.HTTPValidationError.t()}
```

Delete

**Scopes**: `organization_access_tokens:write`

# `organization_access_tokens_list`

```elixir
@spec organization_access_tokens_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceOrganizationAccessToken.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List

List organization access tokens.

**Scopes**: `organization_access_tokens:read` `organization_access_tokens:write`

## Options

  * `organization_id`: Filter by organization ID.
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: 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.

# `organization_access_tokens_update`

```elixir
@spec organization_access_tokens_update(
  id :: String.t(),
  body :: Polarex.OrganizationAccessTokenUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.OrganizationAccessToken.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

Update

**Scopes**: `organization_access_tokens:write`

## Request Body

**Content Types**: `application/json`

# `payments_get`

```elixir
@spec payments_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.CardPayment.t() | Polarex.GenericPayment.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Payment

Get a payment by ID.

**Scopes**: `payments:read`

# `payments_list`

```elixir
@spec payments_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourcePayment.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Payments

List payments.

**Scopes**: `payments:read`

## Options

  * `organization_id`: Filter by organization ID.
  * `checkout_id`: Filter by checkout ID.
  * `order_id`: Filter by order ID.
  * `status`: Filter by payment status.
  * `method`: Filter by payment method.
  * `customer_email`: Filter by customer email.
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: 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.

# `products_create`

```elixir
@spec products_create(
  body :: Polarex.ProductCreateOneTime.t() | Polarex.ProductCreateRecurring.t(),
  opts :: keyword()
) :: {:ok, Polarex.Product.t()} | {:error, Polarex.HTTPValidationError.t()}
```

Create Product

Create a product.

**Scopes**: `products:write`

## Request Body

**Content Types**: `application/json`

# `products_get`

```elixir
@spec products_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.Product.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Product

Get a product by ID.

**Scopes**: `products:read` `products:write`

# `products_list`

```elixir
@spec products_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceProduct.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Products

List products.

**Scopes**: `products:read` `products:write`

## Options

  * `id`: Filter by product ID.
  * `organization_id`: Filter by organization ID.
  * `query`: Filter by product name.
  * `is_archived`: Filter on archived products.
  * `is_recurring`: Filter on recurring products. If `true`, only subscriptions tiers are returned. If `false`, only one-time purchase products are returned. 
  * `benefit_id`: Filter products granting specific benefit.
  * `visibility`: Filter by visibility.
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: 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`: Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.

# `products_update`

```elixir
@spec products_update(
  id :: String.t(),
  body :: Polarex.ProductUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Product.t()}
  | {:error,
     Polarex.HTTPValidationError.t()
     | Polarex.NotPermitted.t()
     | Polarex.ResourceNotFound.t()}
```

Update Product

Update a product.

**Scopes**: `products:write`

## Request Body

**Content Types**: `application/json`

# `products_update_benefits`

```elixir
@spec products_update_benefits(
  id :: String.t(),
  body :: Polarex.ProductBenefitsUpdate.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Product.t()}
  | {:error,
     Polarex.HTTPValidationError.t()
     | Polarex.NotPermitted.t()
     | Polarex.ResourceNotFound.t()}
```

Update Product Benefits

Update benefits granted by a product.

**Scopes**: `products:write`

## Request Body

**Content Types**: `application/json`

# `subscriptions_create`

```elixir
@spec subscriptions_create(
  body ::
    Polarex.SubscriptionCreateCustomer.t()
    | Polarex.SubscriptionCreateExternalCustomer.t(),
  opts :: keyword()
) :: {:ok, Polarex.Subscription.t()} | {:error, Polarex.HTTPValidationError.t()}
```

Create Subscription

Create a subscription programmatically.

This endpoint only allows to create subscription on free products.
For paid products, use the checkout flow.

No initial order will be created and no confirmation email will be sent.

**Scopes**: `subscriptions:write`

## Request Body

**Content Types**: `application/json`

# `subscriptions_export`

```elixir
@spec subscriptions_export(opts :: keyword()) ::
  {:ok, map() | String.t()} | {:error, Polarex.HTTPValidationError.t()}
```

Export Subscriptions

Export subscriptions as a CSV file.

**Scopes**: `subscriptions:read` `subscriptions:write`

## Options

  * `organization_id`: Filter by organization ID.

# `subscriptions_get`

```elixir
@spec subscriptions_get(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.Subscription.t()}
  | {:error, Polarex.HTTPValidationError.t() | Polarex.ResourceNotFound.t()}
```

Get Subscription

Get a subscription by ID.

**Scopes**: `subscriptions:read` `subscriptions:write`

# `subscriptions_list`

```elixir
@spec subscriptions_list(opts :: keyword()) ::
  {:ok, Polarex.ListResourceSubscription.t()}
  | {:error, Polarex.HTTPValidationError.t()}
```

List Subscriptions

List subscriptions.

**Scopes**: `subscriptions:read` `subscriptions:write`

## Options

  * `organization_id`: Filter by organization ID.
  * `product_id`: Filter by product ID.
  * `customer_id`: Filter by customer ID.
  * `external_customer_id`: Filter by customer external ID.
  * `discount_id`: Filter by discount ID.
  * `active`: Filter by active or inactive subscription.
  * `cancel_at_period_end`: Filter by subscriptions that are set to cancel at period end.
  * `customer_cancellation_reason`: Filter by customer cancellation reason.
  * `canceled_at_after`: Filter by cancellation date (after or equal to).
  * `canceled_at_before`: Filter by cancellation date (before or equal to).
  * `page`: Page number, defaults to 1.
  * `limit`: Size of a page, defaults to 10. Maximum is 100.
  * `sorting`: 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`: Filter by metadata key-value pairs. It uses the `deepObject` style, e.g. `?metadata[key]=value`.

# `subscriptions_revoke`

```elixir
@spec subscriptions_revoke(id :: String.t(), opts :: keyword()) ::
  {:ok, Polarex.Subscription.t()}
  | {:error,
     Polarex.AlreadyCanceledSubscription.t()
     | Polarex.HTTPValidationError.t()
     | Polarex.ResourceNotFound.t()
     | Polarex.SubscriptionLocked.t()}
```

Revoke Subscription

Revoke a subscription, i.e cancel immediately.

**Scopes**: `subscriptions:write`

# `subscriptions_update`

```elixir
@spec subscriptions_update(
  id :: String.t(),
  body ::
    Polarex.SubscriptionCancel.t()
    | Polarex.SubscriptionRevoke.t()
    | Polarex.SubscriptionUpdateBillingPeriod.t()
    | Polarex.SubscriptionUpdateClear.t()
    | Polarex.SubscriptionUpdateDiscount.t()
    | Polarex.SubscriptionUpdateProduct.t()
    | Polarex.SubscriptionUpdateSeats.t()
    | Polarex.SubscriptionUpdateTrial.t(),
  opts :: keyword()
) ::
  {:ok, Polarex.Subscription.t()}
  | {:error,
     Polarex.AlreadyCanceledSubscription.t()
     | Polarex.HTTPValidationError.t()
     | Polarex.PaymentFailed.t()
     | Polarex.ResourceNotFound.t()
     | Polarex.SubscriptionLocked.t()}
```

Update Subscription

Update a subscription.

**Scopes**: `subscriptions:write`

## Request Body

**Content Types**: `application/json`

---

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