---
title: "Write up to 500 metric values, atomically (#5034)"
method: POST
path: "/internal/company-metrics/values"
tags: ["Internal"]
---

# Write up to 500 metric values, atomically (#5034)

`POST /internal/company-metrics/values`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/internal/company-metrics/values`
- Auth: HTTP bearer

Any refused row refuses the batch, so a replay lands whole or not at all. Single writer: each row's writer must equal its definition's writer and its run's writer, and is never `app-compute`, the in-app job (`wrong_writer`); an unknown key, version or run is `unknown_metric`, `unknown_version` or `unknown_run`; a superseded version, or a version below the stored row's, is `version_conflict` (409). Upsert key (metric_key, grain, period_start, segment): an older `source_as_of` is ignored (`stale_ignored`); the same `source_as_of` and content moves only computed_at and job_run_id (`unchanged`); anything else replaces the row. The writer colors values; the server checks the state against the lines, n and min_n but never recolors. The writer's Google-signed ID token only.

## Request body

- object
  - `job_run_id` string: When given, every row must name this run.
  - `rows` CompanyMetricValueRow[], required
    - `metric_key` string, required
    - `metric_version` integer, required
    - `grain` 'day' | 'week' | 'month', required
    - `period_start` string, date, required: Aligned to the grain: the day, the Monday, the first of the month (ET).
    - `segment` string, required: `all`, or dim:value pairs sorted by dim (canonical spelling only).
    - `value` number, nullable, required
    - `numerator` number, nullable, required
    - `denominator` number, nullable, required
    - `sample_n` integer, nullable, required
    - `value_state` 'green' | 'amber' | 'red' | 'no_data' | 'insufficient_n' | 'null', nullable, required
    - `source_as_of` string, date-time, required
    - `computed_at` string, date-time, required
    - `writer` string, required
    - `job_run_id` string, required
    - `evidence` object, required: References only; compact JSON at most 2048 bytes.

## Response `200`

Accepted

- object
  - `success` true, required
  - `data` object, required
    - `accepted` integer, required
    - `inserted` integer, required
    - `updated` integer, required
    - `unchanged` integer, required
    - `stale_ignored` integer, required

## Other responses

- `401`: No credential, or a token that is not the writer's (bad signature, audience or expiry)
- `403`: `forbidden`: a signed-in person, any API key (the service tokens included), an MCP OAuth token, or another service account
- `409`: `version_conflict`; the refused rows are in `error.extensions.rows`
- `422`: `unknown_metric`, `unknown_version`, `wrong_writer`, `unknown_run`, `bad_grain`, `bad_period_start`, `bad_segment`, `bad_value_state`, `evidence_too_large` (the code is `error.title`, the rows in `error.extensions.rows`), or a body that failed validation

## Changes

- **2026-11-19** `96dc1148df17`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/medianfi/apis/median-api/changes/internal/company-metrics/values/post.md)

---

[API](https://skmtc.dev/medianfi/apis/median-api.md) - [All operations](https://skmtc.dev/medianfi/apis/median-api/llms.txt) - [OpenAPI document](https://skmtc.dev/medianfi/apis/median-api/revisions/4f4c2d34276b?raw)
