---
title: "Code metrics overview"
method: GET
path: "/reports/metrics/code"
tags: ["Built-in reports"]
---

# Code metrics overview

`GET /reports/metrics/code`

Overview of pull request metrics per team, mirroring the
[Code metrics — Overview](https://app.swarmia.com/metrics/code)
report in the app. Returns one row per matched team plus a
`summaryRow` aggregating across all of them.

Durations (`cycleTime`, `timeToFirstReview`, `mergeTime`) are in
**seconds**. `reviewRate` is a percentage (0–100). The numeric
`aggregate` parameter controls how the duration and batch-size
metrics are aggregated.

Supported revisions: `1`, `2` (`latest` is equivalent to `2`).
Revision 2 added the `teamFte` and `mergedPrsByFte` columns and
treats `teamId`/`parentTeamId` as comma-separated lists. In
revision 1, supplying `teamId` returns that team's child teams
only (the team itself is excluded from rows but still counted in
`summaryRow`).

## Query parameters

- `output` 'json' | 'csv'
- `revision` string, required
- `timeframe.start` string, date, required
- `timeframe.end` string, date, required
- `timezone` string
- `teamId` string
- `parentTeamId` string
- `aggregate` 'Sum' | 'Avg' | 'Min' | 'Max' | 'P99' | 'P95' | 'P90' | 'P85' | 'P80' | 'P75' | 'P50'
- `pullRequestFilter` string

## Response `200`

Successful response.

- EntityReportMetricsCodeResult
  - `schema` object, required — Describes each property in `rows`. Keys are property names, values carry a human-readable `title`, `description` and the `aggregate` used.
  - `rows` object[], required
    - `_key` EntityReferenceTeam, required — Teams represent your organization structure and are the owners of other entities like Issues and Pull requests.
      - `type` 'Team', required
      - `id` string, uuid, required
      - `name` string, required
    - `id` string, nullable — Team's Swarmia ID. `null` in the summary row.
    - `name` string, nullable — Team name. `null` in the summary row.
    - `cycleTime` number, nullable, required — Aggregated pull request cycle time, in seconds. `null` when no data.
    - `reviewRate` number, nullable, required — Percentage (0–100) of merged PRs that were approved. `null` when no data.
    - `timeToFirstReview` number, nullable, required — Aggregated time waiting for the first review, in seconds. `null` when no data.
    - `mergedCount` integer, required — Number of merged pull requests.
    - `mergeTime` number, nullable, required — Aggregated time waiting to merge after approval, in seconds. `null` when no data.
    - `batchSize` number, nullable, required — Aggregated batch size (lines changed). `null` when no data.
    - `contributorCount` integer, required — Number of unique contributors.
    - `averageInProgress` number, nullable, required — Average number of pull requests in progress. Always an average, regardless of `aggregate`.
    - `teamFte` number, nullable, required — Average active developers (full-time equivalent). `null` when no FTE data.
    - `mergedPrsByFte` number, nullable, required — Merged pull requests per FTE. `null` when FTE is unavailable.
  - `summaryRow` MetricsCodeMetrics — The code metrics shared by each row and the summary row.
    - `_key` EntityReferenceTeam, required — Teams represent your organization structure and are the owners of other entities like Issues and Pull requests.
      - `type` 'Team', required
      - `id` string, uuid, required
      - `name` string, required
    - `id` string, nullable — Team's Swarmia ID. `null` in the summary row.
    - `name` string, nullable — Team name. `null` in the summary row.
    - `cycleTime` number, nullable, required — Aggregated pull request cycle time, in seconds. `null` when no data.
    - `reviewRate` number, nullable, required — Percentage (0–100) of merged PRs that were approved. `null` when no data.
    - `timeToFirstReview` number, nullable, required — Aggregated time waiting for the first review, in seconds. `null` when no data.
    - `mergedCount` integer, required — Number of merged pull requests.
    - `mergeTime` number, nullable, required — Aggregated time waiting to merge after approval, in seconds. `null` when no data.
    - `batchSize` number, nullable, required — Aggregated batch size (lines changed). `null` when no data.
    - `contributorCount` integer, required — Number of unique contributors.
    - `averageInProgress` number, nullable, required — Average number of pull requests in progress. Always an average, regardless of `aggregate`.
    - `teamFte` number, nullable, required — Average active developers (full-time equivalent). `null` when no FTE data.
    - `mergedPrsByFte` number, nullable, required — Merged pull requests per FTE. `null` when FTE is unavailable.

## Other responses

- `400` — Invalid or unknown parameters.
- `401` — Missing or invalid API token.

---

[API](https://skmtc.net/swarmia/apis/swarmia-rest-api.md) · [All operations](https://skmtc.net/swarmia/apis/swarmia-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/swarmia/swarmia-rest-api/revisions/68d401c79425/schema)
