> ## Documentation Index
> Fetch the complete documentation index at: https://scaleup-c34c4386.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# GET /api/v1/metrics

> Retorna métricas e analytics da organização

Retorna métricas agregadas da organização, como receita, assinaturas ativas e churn, para um período especificado.

## Autenticação

> [!NOTE]
>
> Requer um token de acesso válido (`CHARGEFY_ACCESS_TOKEN`) no header `Authorization`.

## Parâmetros de Query

| Parâmetro | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `startDate` | `string` | Sim | Data de início no formato `YYYY-MM-DD` |
| `endDate` | `string` | Sim | Data de fim no formato `YYYY-MM-DD` |
| `interval` | `string` | Não | Intervalo de agrupamento: `day`, `week`, `month` (default: `month`) |
| `organizationId` | `string` | Não | ID da organização |

## Campos da Resposta

| Campo | Tipo | Descrição |
| - | - | - |
| `periods` | `array` | Lista de períodos com métricas |
| `periods[].date` | `string` | Data do período |
| `periods[].revenue` | `integer` | Receita em centavos |
| `periods[].activeSubscriptions` | `integer` | Assinaturas ativas |
| `periods[].newSubscriptions` | `integer` | Novas assinaturas |
| `periods[].canceledSubscriptions` | `integer` | Assinaturas canceladas |
| `periods[].churnRate` | `number` | Taxa de churn (%) |
| `periods[].mrr` | `integer` | Receita recorrente mensal em centavos |
| `totals` | `object` | Totais do período |
| `totals.totalRevenue` | `integer` | Receita total em centavos |
| `totals.totalSales` | `integer` | Total de vendas |

## Exemplo de Requisição

```bash cURL theme={null}
curl -X GET "https://api.chargefy.io/api/v1/metrics?startDate=2026-01-01&endDate=2026-03-12&interval=month" \
  -H "Authorization: Bearer $CHARGEFY_ACCESS_TOKEN"
```

```typescript SDK theme={null}
import { Chargefy } from '@chargefy/sdk';

const chargefy = new Chargefy({
  accessToken: process.env.CHARGEFY_ACCESS_TOKEN,
});

const metrics = await chargefy.metrics.get({
  startDate: '2026-01-01',
  endDate: '2026-03-12',
  interval: 'month',
});
```

## Exemplo de Resposta

```json theme={null}
{
  "periods": [
    {
      "date": "2026-01-01",
      "revenue": 1250000,
      "activeSubscriptions": 120,
      "newSubscriptions": 15,
      "canceledSubscriptions": 3,
      "churnRate": 2.5,
      "mrr": 450000
    },
    {
      "date": "2026-02-01",
      "revenue": 1380000,
      "activeSubscriptions": 132,
      "newSubscriptions": 18,
      "canceledSubscriptions": 6,
      "churnRate": 4.5,
      "mrr": 495000
    },
    {
      "date": "2026-03-01",
      "revenue": 1420000,
      "activeSubscriptions": 140,
      "newSubscriptions": 12,
      "canceledSubscriptions": 4,
      "churnRate": 3.0,
      "mrr": 520000
    }
  ],
  "totals": {
    "totalRevenue": 4050000,
    "totalSales": 312
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.