Get message usage

SDK platic.usage.messages()

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

Example

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

Query parameters

ParameterTypeDescriptionRequired
workspacestringWorkspace ID. Required when your credential covers several workspaces (list workspaces); without it the answer is 400When the credential has several
startDatestringISO 8601 start date with offset. Defaults to the billing-period start—
endDatestringISO 8601 end date with offset. Defaults to the billing-period end—
groupByenumtype (default), channel, templateCategory, campaign, status, or country (rate country; billable only)—
modeenumfull 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—
universeenumall (default) includes failed/non-billable messages; billable shows only charged messages—

Example: billable messages only

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

Response

{
  "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

FieldDescription
workspaceIdWorkspace ID
billingPeriodActive billing period of the workspace
dataSinceEarliest reliable date for billable metrics
universeRequested universe: all or billable
usage.modeEffective mode: full or fast. Enterprise always returns fast
usage.groupByApplied grouping dimension
usage.rangeEffective evaluated range
usage.seriesDaily series for the selected universe
usage.totalsByGroup[].messagesGroup messages within the selected universe
usage.totalsByGroup[].nonBillableMessagesGroup messages that are not charged
usage.totalsByGroup[].changePctChange vs the immediately preceding equal-length period
usage.summary.totalMessagesTotal volume, including failed/non-billable messages
usage.summary.billableMessagesMessages that are charged
usage.summary.nonBillableMessagesMessages that are not charged
usage.summary.failedMessagesFailed messages; they do not consume balance
usage.summary.humanServiceCountPart of serviceCount sent by a person from the inbox
usage.summary.creditsUsedCredits consumed (omitted for enterprise)
usage.commentsInstagram and Facebook comments in the range: received (from others) and agentReplies (replies the agent delivered). null when they could not be counted
usage.freshnessSource, latest update, and expected lag

Modes

ModeRecommended use
fullThe default. Exact count over transactions, with country rates and the workspace's balances; honors the exact time of startDate and endDate. Maximum 92 days
fastLong 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.

Errors

Statusdetails.codeWhen it happens
400INVALID_REQUESTA 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
400INVALID_REQUESTYour 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
401UNAUTHENTICATEDThe credential is missing or invalid
403FORBIDDENWith an OAuth token, the person has no access to the dashboard (statistics) in that workspace. The message is Missing dashboard permission
404NOT_FOUNDThe workspace no longer exists. This is rare
{
  "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.