> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uselotus.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Metric Access

<CodeGroup>
  ```py Python theme={null}
  lotus.check_metric_access(
    customer_id="cust_0569173ee6654369",
    metric_id="metric_a47ac0bf",
  )
  ```

  ```ts Typescript theme={null}
  await lotus.checkMetricAccess({
    customerId: "cust_0569173ee6654369",
    metricId: "metric_a47ac0bf",
  });
  ```
</CodeGroup>


## OpenAPI

````yaml GET /api/metric_access/
openapi: 3.0.3
info:
  title: Lotus API
  version: 0.9.3
  description: >-
    Lotus is an open-core pricing and billing engine. We enable API companies to
    automate and optimize their custom usage-based pricing for any metric.
servers: []
security: []
paths:
  /api/metric_access/:
    get:
      tags:
        - api
      operationId: api_metric_access_retrieve
      parameters:
        - in: query
          name: customer_id
          schema:
            type: string
            nullable: true
            minLength: 1
          description: The customer_id of the customer you want to check access.
          required: true
        - in: query
          name: metric_id
          schema:
            type: string
            format: uuid
          description: The metric_id of the metric you want to check access for.
          required: true
        - in: query
          name: subscription_filters
          schema:
            type: array
            items:
              $ref: '#/components/schemas/SubscriptionFilterRequest'
          description: >-
            Used if you want to restrict the access check to only plans that
            fulfill certain subscription filter criteria. If your billing model
            does not have the ability multiple plans or subscriptions per
            customer, this is likely not relevant for you. 
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetricAccessResponse'
          description: ''
      security:
        - OrganizationApiKeyAuth: []
          TokenAuth: []
components:
  schemas:
    SubscriptionFilterRequest:
      type: object
      properties:
        value:
          type: string
          minLength: 1
        property_name:
          type: string
          minLength: 1
          description: 'The string name of the property to filter on. Example: ''product_id'''
      required:
        - property_name
        - value
    MetricAccessResponse:
      type: object
      properties:
        customer:
          $ref: '#/components/schemas/LightweightCustomer'
        access:
          type: boolean
          description: >-
            Whether or not the customer has access to this metric. The default
            behavior for this is whether all of the customer's plans (that have
            access to the metric) are below the total limit of the metric. If
            you have specified subscription filters, then this will be whether
            all of the customer's plans that match the subscription filters are
            below the total limit of the metric. You can customize the behavior
            of this flag by setting a policy in your Organization settings in
            the frontend.
        metric:
          $ref: '#/components/schemas/LightweightMetric'
        access_per_subscription:
          type: array
          items:
            $ref: '#/components/schemas/MetricAccessPerSubscription'
      required:
        - access
        - access_per_subscription
        - customer
        - metric
    LightweightCustomer:
      type: object
      properties:
        customer_name:
          type: string
          readOnly: true
          nullable: true
          description: The display name of the customer
        email:
          type: string
          format: email
          readOnly: true
          nullable: true
          description: >-
            The primary email address of the customer, must be the same as the
            email address used to create the customer in the payment provider
        customer_id:
          type: string
          readOnly: true
          nullable: true
          description: >-
            The id provided when creating the customer, we suggest matching with
            your internal customer id in your backend
      required:
        - customer_id
        - customer_name
        - email
    LightweightMetric:
      type: object
      properties:
        metric_id:
          type: string
        event_name:
          type: string
          readOnly: true
          description: Name of the event that this metric is tracking.
        metric_name:
          type: string
      required:
        - event_name
        - metric_id
        - metric_name
    MetricAccessPerSubscription:
      type: object
      properties:
        subscription:
          $ref: '#/components/schemas/AccessMethodsSubscriptionRecord'
        metric_usage:
          type: number
          format: double
          maximum: 10000000000
          minimum: 0
          exclusiveMaximum: true
          description: >-
            The current usage of the metric. Keep in mind the current usage of
            the metric can be different from the billable usage of the metric.
            For examnple, for a gauge metric, the `metric_usage` is the current
            value of the gauge, while the billable usage is the accumulated tiem
            at each gauge level at the end of the subscription.
        metric_free_limit:
          type: number
          format: double
          maximum: 10000000000
          minimum: 0
          exclusiveMaximum: true
          nullable: true
          description: >-
            If you specified a free tier of usage for this metric, this is the
            amount of usage that is free. Will be 0 if you didn't specify a free
            limit for this metric or this subscription doesn't have access to
            this metric, and null if the free tier is unlimited.
        metric_total_limit:
          type: number
          format: double
          maximum: 10000000000
          minimum: 0
          exclusiveMaximum: true
          nullable: true
          description: >-
            The total limit of the metric. Will be 0 if this subscription
            doesn't have access to this metric, and null if there is no limit to
            this metric.
      required:
        - metric_free_limit
        - metric_total_limit
        - metric_usage
        - subscription
    AccessMethodsSubscriptionRecord:
      type: object
      properties:
        start_date:
          type: string
          format: date-time
          readOnly: true
          description: >-
            The time the subscription starts. This will be a string in
            yyyy-mm-dd HH:mm:ss format in UTC time.
        end_date:
          type: string
          format: date-time
          readOnly: true
          description: >-
            The time the subscription starts. This will be a string in
            yyyy-mm-dd HH:mm:ss format in UTC time.
        subscription_filters:
          type: array
          items:
            $ref: '#/components/schemas/SubscriptionFilter'
        plan:
          $ref: '#/components/schemas/LightweightPlanVersion'
      required:
        - end_date
        - plan
        - start_date
        - subscription_filters
    SubscriptionFilter:
      type: object
      properties:
        value:
          type: string
        property_name:
          type: string
          description: 'The string name of the property to filter on. Example: ''product_id'''
      required:
        - property_name
        - value
    LightweightPlanVersion:
      type: object
      properties:
        plan_name:
          type: string
          readOnly: true
        plan_id:
          type: string
        version_id:
          type: string
          readOnly: true
        version:
          oneOf:
            - type: integer
            - enum:
                - custom_version
              type: string
          readOnly: true
      required:
        - plan_id
        - plan_name
        - version
        - version_id
  securitySchemes:
    OrganizationApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````