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

# Check Active Subscription

> Check if a customer has an active subscription



## OpenAPI

````yaml GET /api/v1/customers/{customer_key}/check-active-subscription
openapi: 3.0.1
info:
  title: Metrifox API Documentation
  version: v1
  description: >-
    Welcome to Metrifox Platform's API documentation. This comprehensive API
    suite enables seamless integration with our platform, providing secure and
    efficient access to our services.
servers:
  - url: https://{defaultHost}
    variables:
      defaultHost:
        default: api.metrifox.com
security:
  - api_key: []
paths:
  /api/v1/customers/{customer_key}/check-active-subscription:
    get:
      tags:
        - Customers
      summary: Check active subscription
      description: >
        Checks whether a customer has an active subscription in Metrifox.


        **Returns:**

        - A boolean indicating if the customer has at least one active
        subscription


        **Active Subscription States:**

        - Paid subscriptions in good standing

        - Trial period subscriptions

        - Grace period subscriptions


        **Not Considered Active:**

        - Cancelled subscriptions

        - Expired subscriptions

        - Failed payment subscriptions
      operationId: checkActiveSubscription
      parameters:
        - name: customer_key
          in: path
          required: true
          description: The unique identifier for the customer
          schema:
            type: string
          example: test-customer-key
      responses:
        '200':
          description: Active subscription status checked successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 200
                  message:
                    type: string
                    example: ''
                  data:
                    type: object
                    properties:
                      has_active_subscription:
                        type: boolean
                        description: Whether the customer has an active subscription
                        example: true
              examples:
                active_subscription:
                  summary: Customer has active subscription
                  value:
                    statusCode: 200
                    message: ''
                    data:
                      has_active_subscription: true
                no_active_subscription:
                  summary: Customer has no active subscription
                  value:
                    statusCode: 200
                    message: ''
                    data:
                      has_active_subscription: false
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 401
                  message:
                    type: string
                    example: Unauthorized
                  data:
                    type: object
                    example: {}
                  meta:
                    type: object
                    example: {}
                  errors:
                    type: object
                    example: {}
        '404':
          description: Customer not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 404
                  message:
                    type: string
                    example: Customer not found
                  data:
                    type: object
                    example: {}
                  meta:
                    type: object
                    example: {}
                  errors:
                    type: object
                    example: {}
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: >
            from metrifox_sdk import MetrifoxClient


            client = MetrifoxClient(api_key="your_api_key")


            # Check if customer has an active subscription

            has_active_subscription =
            client.customers.has_active_subscription("test-customer-key")


            print(has_active_subscription)  # True or False


            if has_active_subscription:
                print("Customer has an active subscription")
            else:
                print("Customer does not have an active subscription")
        - lang: javascript
          label: Javascript SDK
          source: >
            import { init } from "metrifox-js";


            const metrifoxClient = init({
              apiKey: process.env.METRIFOX_API_KEY
            });


            // Check if customer has an active subscription

            const hasActiveSubscription = await
            metrifoxClient.customers.checkActiveSubscription("test-customer-key");


            console.log(hasActiveSubscription); // true or false


            if (hasActiveSubscription) {
              console.log("Customer has an active subscription");
            } else {
              console.log("Customer does not have an active subscription");
            }
        - lang: ruby
          label: Ruby SDK
          source: >
            require 'metrifox-sdk'


            # Initialize with configuration

            METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })


            # Check if customer has an active subscription

            has_active_subscription =
            MetrifoxSDK.customers.has_active_subscription?(customer_key:
            "test-customer-key")


            puts has_active_subscription # true or false


            if has_active_subscription
              puts "Customer has an active subscription"
            else
              puts "Customer does not have an active subscription"
            end
        - lang: curl
          label: cURL
          source: >
            curl -X GET
            "https://api.metrifox.com/api/v1/customers/test-customer-key/check-active-subscription"
            \
              -H "x-api-key: your-api-key"
components:
  securitySchemes:
    api_key:
      type: apiKey
      name: x-api-key
      in: header

````