---
title: "Aggregate App Stats"
method: POST
path: "/api/v1/stats/usage/app"
tags: ["Statistics"]
---

# Aggregate App Stats

`POST /api/v1/stats/usage/app`

Creates a background task to calculate the number of message attempts (`messageDestinations`) made for all applications in the environment.

Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to
retrieve the results of the operation.

The completed background task will return a payload like the following:
```json
{
  "id": "qtask_33qe39Stble9Rn3ZxFrqL5ZSsjT",
  "status": "finished",
  "task": "application.stats",
  "data": {
    "appStats": [
      {
        "messageDestinations": 2,
        "appId": "app_33W1An2Zz5cO9SWbhHsYyDmVC6m",
        "appUid": null
      }
    ]
  }
}
```

## Headers

- `idempotency-key` string

## Request body

- AppUsageStatsIn
  - `since` string, date-time, required
  - `until` string, date-time, required
  - `appIds` string[], nullable — Specific app IDs or UIDs to aggregate stats for. Note that if none of the given IDs or UIDs are resolved, a 422 response will be given.

## Response `202`

- AppUsageStatsOut
  - `unresolvedAppIds` string[], required — Any app IDs or UIDs received in the request that weren't found. Stats will be produced for all the others.
  - `id` string, required — The QueueBackgroundTask's ID.
  - `status` 'running' | 'finished' | 'failed', required
  - `task` 'endpoint.replay' | 'endpoint.recover' | 'application.stats' | 'message.broadcast' | 'sdk.generate' | 'event-type.aggregate' | 'application.purge_content' | 'endpoint.bulk-replay', required
  - `updatedAt` string, date-time, required

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `409` — Conflict
- `422` — Validation Error
- `429` — Too Many Requests

---

[API](https://skmtc.net/svix/apis/svix-api.md) · [All operations](https://skmtc.net/svix/apis/svix-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/svix/svix-api/versions/16dbcc056c48/schema)
