---
title: "Record or update a writer run (#5034)"
method: POST
path: "/internal/company-metrics/runs"
tags: ["Internal"]
---

# Record or update a writer run (#5034)

`POST /internal/company-metrics/runs`

## Request

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

Idempotent on `job_run_id`; a second call updates the run. Its writer must write a current key and never changes, and is never `app-compute`, the in-app job (`wrong_writer`). A running run has no finished_at; a finished one has one. The writer's Google-signed ID token only.

## Request body

- CompanyMetricRun
  - `job_run_id` string, required
  - `writer` string, required
  - `started_at` string, date-time, required
  - `finished_at` string, date-time, nullable, required
  - `status` 'running' | 'ok' | 'partial' | 'error' | 'not_wired', required
  - `rows_written` integer, required
  - `errors` object[], required: References only, never row content. `{code, message, key?, module?}`; a `not_wired` code with `key` marks that key not wired.
    - `code` string, required
    - `message` string
    - `key` string
    - `module` string

## Response `200`

Recorded

- object
  - `success` true, required
  - `data` object, required
    - `job_run_id` string, required
    - `status` string, 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
- `422`: `wrong_writer`, `bad_request`, 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/runs/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)
