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

# Métricas de Cartão

> Métricas de performance de programas de fidelidade

# Métricas de Cartão

Retorna métricas de cartões de fidelidade por programa ou no agregado da empresa.

## Filtros

* `program_id` opcional para visão de programa específico
* `days` para janela temporal
* `group_by`: `day`, `week` ou `month`

## Status comuns

* `200` métricas retornadas
* `401` API Key inválida ou revogada
* `403` plano sem `api_access`
* `422` parâmetro inválido


## OpenAPI

````yaml GET /api/v1/public/loyalty-cards/metrics
openapi: 3.1.0
info:
  contact:
    email: support@indiqai.com
    name: IndiqAI Support
    url: https://indiqai.com/
  description: Especificação OpenAPI da API Pública IndiqAI.
  license:
    name: Proprietary
    url: https://indiqai.com/license
  title: IndiqAI API Pública
  version: 1.5.0
servers:
  - description: Produção
    url: https://api.indiqai.com
security: []
paths:
  /api/v1/public/loyalty-cards/metrics:
    get:
      tags:
        - API Pública
      summary: Métricas de cartão de fidelidade
      description: Métricas de performance de programas de cartão de fidelidade.
      operationId: get_loyalty_card_metrics_api_v1_public_loyalty_cards_metrics_get
      parameters:
        - description: ID do programa (null agrega todos)
          in: query
          name: program_id
          required: false
          schema:
            anyOf:
              - format: uuid
                type: string
              - type: 'null'
            description: ID do programa (null agrega todos)
            title: Program Id
        - in: query
          name: days
          required: false
          schema:
            default: 30
            maximum: 365
            minimum: 1
            title: Days
            type: integer
        - description: '"day", "week" ou "month"'
          in: query
          name: group_by
          required: false
          schema:
            default: day
            description: '"day", "week" ou "month"'
            title: Group By
            type: string
        - description: Chave de API
          in: header
          name: X-API-Key
          required: true
          schema:
            description: Chave de API
            title: X-Api-Key
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoyaltyCardMetricsResponse'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  schemas:
    LoyaltyCardMetricsResponse:
      description: Métricas de performance de programas de cartão de fidelidade.
      properties:
        avg_days_to_complete:
          anyOf:
            - type: number
            - type: 'null'
          title: Avg Days To Complete
        avg_stamps_per_active_card:
          default: 0
          title: Avg Stamps Per Active Card
          type: number
        cards_active:
          default: 0
          title: Cards Active
          type: integer
        cards_completed:
          default: 0
          title: Cards Completed
          type: integer
        cards_issued:
          default: 0
          title: Cards Issued
          type: integer
        cards_near_completion:
          default: 0
          title: Cards Near Completion
          type: integer
        clients_with_card:
          default: 0
          title: Clients With Card
          type: integer
        clients_without_card:
          default: 0
          title: Clients Without Card
          type: integer
        completion_rate:
          default: 0
          title: Completion Rate
          type: number
        period_days:
          default: 30
          title: Period Days
          type: integer
        program_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Program Id
        program_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Program Name
        stamps_by_period:
          items:
            $ref: '#/components/schemas/LoyaltyStampsByPeriod'
          title: Stamps By Period
          type: array
        top_clients:
          items:
            $ref: '#/components/schemas/LoyaltyTopClient'
          title: Top Clients
          type: array
      title: LoyaltyCardMetricsResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    LoyaltyStampsByPeriod:
      properties:
        completions:
          default: 0
          title: Completions
          type: integer
        period:
          title: Period
          type: string
        stamps:
          default: 0
          title: Stamps
          type: integer
      required:
        - period
      title: LoyaltyStampsByPeriod
      type: object
    LoyaltyTopClient:
      properties:
        cards_completed:
          default: 0
          title: Cards Completed
          type: integer
        client_id:
          title: Client Id
          type: string
        name:
          title: Name
          type: string
        stamps_total:
          default: 0
          title: Stamps Total
          type: integer
      required:
        - client_id
        - name
      title: LoyaltyTopClient
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object

````