---
docId: doc_bba2c333a68446bcb5c304b8f0a70ef5
title: Get message usage
description: "Read totals and daily series for billable and non-billable messages."
api:
  group: estadisticas
  auth: bearer
  operations:
    - operationId: getUsageMessages
      method: GET
      path: /v1/usage/messages
      postmanName: Get message usage
---

<script>
  import { Note, Ways } from '$lib/components';
</script>

# Get message usage

Read message totals and daily series. The response separates total volume, charged messages, and failed or non-billable messages.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl "https://api.platic.ai/v1/usage/messages?groupBy=channel" \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.usage.messages({ groupBy: "channel" });
```

</Ways.Way>
</Ways>

## Query parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `workspace` | string | Workspace ID. Required when your credential covers several workspaces ([list workspaces](/api-reference/workspaces)); without it the answer is `400` | When the credential has several |
| `startDate` | string | ISO 8601 start date with offset. Defaults to the billing-period start | — |
| `endDate` | string | ISO 8601 end date with offset. Defaults to the billing-period end | — |
| `groupBy` | enum | `type` (default), `channel`, `templateCategory`, `campaign`, `status`, or `country` (rate country; billable only) | — |
| `mode` | enum | `full` reads transactions (exact, same as the **Usage** page); `fast` uses daily aggregates. When omitted: `full` on ranges up to 92 days, `fast` on longer ranges and on enterprise | — |
| `universe` | enum | `all` (default) includes failed/non-billable messages; `billable` shows only charged messages | — |

### Example: billable messages only

```bash
curl "https://api.platic.ai/v1/usage/messages?workspace=g6yCA16pkWl5eXo7KszB&groupBy=status&universe=billable" \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

## Response

```json
{
  "status": "success",
  "data": {
    "workspaceId": "g6yCA16pkWl5eXo7KszB",
    "billingPeriod": {
      "startDate": "2026-06-01T06:00:00.000Z",
      "endDate": "2026-07-01T05:59:59.999Z"
    },
    "dataSince": "2026-05-21T06:00:00.000Z",
    "universe": "all",
    "usage": {
      "planName": "Growth",
      "credits": 6500,
      "mode": "full",
      "groupBy": "type",
      "range": {
        "startDate": "2026-06-01T06:00:00.000Z",
        "endDate": "2026-07-01T05:59:59.999Z"
      },
      "freshness": {
        "source": "transactions",
        "lastUpdated": null,
        "expectedLagSeconds": 0
      },
      "series": [
        { "date": "2026-06-29T12:00:00.000Z", "group": "Servicio", "value": 180 },
        { "date": "2026-06-29T12:00:00.000Z", "group": "Campaña", "value": 40 }
      ],
      "totalsByGroup": [
        { "group": "Servicio", "messages": 950, "nonBillableMessages": 0, "creditsUsed": 950, "includedValueCentavos": 0, "overageCentavos": 0, "changePct": -11.2 },
        { "group": "Campaña", "messages": 250, "nonBillableMessages": 12, "creditsUsed": 358, "includedValueCentavos": 0, "overageCentavos": 0, "changePct": 0 }
      ],
      "summary": {
        "totalMessages": 1200,
        "billableMessages": 1188,
        "nonBillableMessages": 12,
        "failedMessages": 12,
        "serviceCount": 950,
        "humanServiceCount": 120,
        "campaignCount": 250,
        "creditsUsed": 1308,
        "credits": 6500,
        "totalChangePct": -8.8,
        "serviceChangePct": -11.2,
        "campaignChangePct": 0
      },
      "comments": {
        "received": 340,
        "agentReplies": 210
      }
    }
  }
}
```

## Main fields

| Field | Description |
|-------|-------------|
| `workspaceId` | Workspace ID |
| `billingPeriod` | Active billing period of the workspace |
| `dataSince` | Earliest reliable date for billable metrics |
| `universe` | Requested universe: `all` or `billable` |
| `usage.mode` | Effective mode: `full` or `fast`. Enterprise always returns `fast` |
| `usage.groupBy` | Applied grouping dimension |
| `usage.range` | Effective evaluated range |
| `usage.series` | Daily series for the selected universe |
| `usage.totalsByGroup[].messages` | Group messages within the selected universe |
| `usage.totalsByGroup[].nonBillableMessages` | Group messages that are not charged |
| `usage.totalsByGroup[].changePct` | Change vs the immediately preceding equal-length period |
| `usage.summary.totalMessages` | Total volume, including failed/non-billable messages |
| `usage.summary.billableMessages` | Messages that are charged |
| `usage.summary.nonBillableMessages` | Messages that are not charged |
| `usage.summary.failedMessages` | Failed messages; they do not consume balance |
| `usage.summary.humanServiceCount` | Part of `serviceCount` sent by a person from the inbox |
| `usage.summary.creditsUsed` | Credits consumed (omitted for enterprise) |
| `usage.comments` | Instagram and Facebook comments in the range: `received` (from others) and `agentReplies` (replies the agent delivered). `null` when they could not be counted |
| `usage.freshness` | Source, latest update, and expected lag |

## Modes

| Mode | Recommended use |
|------|-----------------|
| `full` | The default. Exact count over transactions, with country rates and the workspace's balances; honors the exact time of `startDate` and `endDate`. Maximum 92 days |
| `fast` | Long ranges and frequent polling. Reads daily aggregates: counts whole days (Mexico City time), costs are estimates, and it normally lags by seconds |

With `groupBy=type`, the groups are:

- `Servicio`: service messages.
- `Servicio (manual)`: messages a person sends from the inbox.
- `Respuestas a comentarios`: the agent's replies and your team's private replies. These are free during the beta.
- `Campaña`: campaign messages.

The calculation matches the app's **Usage** page.

<Note type="note">

Enterprise always uses aggregates (`mode: "fast"`), even when `mode=full` is requested. `creditsUsed` and cost fields are omitted because rates are contract-specific, while `nonBillableMessages` and per-group `changePct` remain available.

</Note>

## Errors

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | A query parameter is not valid: one the endpoint does not know, a date that is not ISO 8601 with offset, or a value outside the allowed list (`groupBy`, `mode`, `universe`). `details.issues` says which one |
| `400` | `INVALID_REQUEST` | Your credential covers several workspaces and you did not send `?workspace=`, or you sent one it does not cover. `details.available` lists the IDs you can use and `details.requested` the one you sent |
| `401` | `UNAUTHENTICATED` | The credential is missing or invalid |
| `403` | `FORBIDDEN` | With an OAuth token, the person has no access to the dashboard (statistics) in that workspace. The message is `Missing dashboard permission` |
| `404` | `NOT_FOUND` | The workspace no longer exists. This is rare |

```json
{
  "code": 400,
  "error": "Bad Request - The request has validation errors",
  "details": {
    "code": "INVALID_REQUEST",
    "message": "The request has validation errors",
    "issues": [
      {
        "code": "invalid_enum_value",
        "received": "agent",
        "options": ["type", "channel", "templateCategory", "campaign", "status", "country"],
        "path": ["groupBy"],
        "message": "Invalid enum value. Expected 'type' | 'channel' | 'templateCategory' | 'campaign' | 'status' | 'country', received 'agent'"
      }
    ]
  }
}
```

The general error format is in [Errors](/api-reference/errors).
