---
title: "Get the factory's PR cost distribution grouped by PR size"
method: GET
path: "/factory/{uid}/costs/per-pr/by-size"
tags: ["Factories", "Metrics"]
---

# Get the factory's PR cost distribution grouped by PR size

`GET /factory/{uid}/costs/per-pr/by-size`

## Request

- Base URL: `https://app.warp.dev/api/v1`
- URL: `https://app.warp.dev/api/v1/factory/{uid}/costs/per-pr/by-size`
- Auth: HTTP bearer

The mean per-PR attributed cost of the factory's PRs first seen in
a UTC date range, grouped by PR size. Pass group_by_period to
additionally receive per-period mean series aligned to
period_list.

## Path parameters

- `uid` string, required

## Query parameters

- `start_date` string, date-time
- `end_date` string, date-time
- `group_by_period` 'day' | 'week' | 'month': Binning granularity for factory metrics series. Weeks start on Sunday (UTC), consistent with existing Warp analytics.

## Response `200`

Cost-by-size distribution for the requested range

- FactoryCostByPRSizeResponse: Fields every factory-scoped metrics response carries alongside its data, so responses from several factories can be combined or told apart.
  - `as_of` string, date-time, required: The time the data is current as of. Data can lag live activity by a few minutes.
  - `team_uid` string, required: Public UID of the team that owns the factory.
  - `factory_uid` string, required: Public UID of the factory the response is scoped to.
  - `group_by_period` 'day' | 'week' | 'month': Binning granularity for factory metrics series. Weeks start on Sunday (UTC), consistent with existing Warp analytics.
  - `period_list` string[]: Period labels every series aligns to (dates like 2026-07-01; weeks labeled by their Sunday start date). Present only when group_by_period was requested.
  - `data` FactoryCostByPRSizeData, required: PR cost distribution by size. buckets always lists every size, smallest first, so the roster is stable; empty buckets carry pr_count 0 and a null mean. sized_pr_count <= pr_count — the difference is the PRs whose line counts were never observed and are excluded from every bucket.
    - `pr_count` integer, required: Every PR first seen in the range, sized or not.
    - `sized_pr_count` integer, required: PRs with observed line counts — the buckets' coverage.
    - `buckets` FactoryCostByPRSizeBucket[], required
      - `size` 'S' | 'M' | 'L' | 'XL', required: A PR's T-shirt size, derived from its webhook-collected line counts (additions + deletions): S < 100, M < 500, L < 1000, XL >= 1000.
      - `pr_count` integer, required: Sized PRs in this bucket first seen in the range.
      - `mean` number, double, nullable, required: Mean per-PR attributed cost in US dollars; null when the bucket has no PRs in the range.
      - `mean_series` number[]: Mean per-PR cost per period, aligned to period_list; null for periods where the bucket has no PRs. Present only when group_by_period was requested.

## Other responses

- `400`: Invalid date range or group_by_period, or more than 365 periods requested
- `401`: Authentication required
- `404`: Factory not found or not accessible
- `429`: The caller has used up the request budget shared by the factory metrics endpoints. Wait the number of seconds in Retry-After, then retry.
- `500`: Internal server error

## Changes

- **2026-10-21** `7ee3ba55debc`: 2 info
  - api tag `factory-metrics` added
  - api tag `factory` removed
- **2026-10-15** `f4630aae17ba`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/warp/apis/oz-agent-api/changes/factory/:uid/costs/per-pr/by-size/get.md)

---

[API](https://skmtc.dev/warp/apis/oz-agent-api.md) - [All operations](https://skmtc.dev/warp/apis/oz-agent-api/llms.txt) - [OpenAPI document](https://skmtc.dev/warp/apis/oz-agent-api/revisions/4b5d145669be?raw)
