List Work Run Corrections

Use this page when a developer script needs correction history for a Compliance Work Run. The operator lifecycle remains documented in Recording corrections.

Current status: the route shape below is checked against the site-side source fixture in docs-api/work-run-correction-openapi-sdk-fixtures.json. Exact production pagination fields, filter names, auth scopes, and generated SDK method names remain pending until the platform-owned OpenAPI snapshot is committed.

Raw HTTP List

GET /admin/work-runs/{work_run_id}/corrections returns immutable correction history rows, including pending, applied, rejected, and superseded decisions. Use limit and cursor; do not guess sequence offsets. Reads do not need an Idempotency-Key or Expected-Version header.

curl -i -sS \
  "$RETVEST_API_BASE/admin/work-runs/$WORK_RUN_ID/corrections?limit=25&cursor=$CORRECTION_CURSOR" \
  -H "Authorization: Bearer $RETVEST_API_KEY" \
  -H "Accept: application/json, application/problem+json" \
  -H "X-Request-Id: req_correction_list_example_001"
{
  "fixture_id": "work-run-correction.list.success-page.v1",
  "items": [
    {
      "correction_id": "wrc_example_001",
      "work_run_id": "wr_example",
      "correction_sequence": 1,
      "correction_status": "pending",
      "receipt_type": "correction_recorded",
      "request_id": "req_correction_create_example_001"
    },
    {
      "correction_id": "wrc_example_001",
      "work_run_id": "wr_example",
      "correction_sequence": 2,
      "correction_status": "applied",
      "receipt_type": "correction_applied",
      "request_id": "req_correction_apply_example_001"
    },
    {
      "correction_id": "wrc_example_002",
      "work_run_id": "wr_example",
      "correction_sequence": 3,
      "correction_status": "rejected",
      "receipt_type": "correction_rejected",
      "rejection_reason_code": "unsupported_evidence",
      "request_id": "req_correction_reject_example_001"
    },
    {
      "correction_id": "wrc_example_003",
      "work_run_id": "wr_example",
      "correction_sequence": 4,
      "correction_status": "superseded",
      "receipt_type": "correction_superseded",
      "request_id": "req_correction_retry_example_001"
    }
  ],
  "pagination": {
    "limit": 25,
    "next_cursor": "cursor_example_next"
  },
  "request_id": "req_correction_list_example_001"
}

SDK Example

Keep the SDK-side example source-only until generated methods exist. The helper returns metadata suitable for operator screens and support tickets, not raw correction bodies.

type CorrectionStatus = "pending" | "applied" | "rejected" | "superseded";

type CorrectionProblemCode =
  | "invalid_cursor"
  | "forbidden"
  | "tenant_mismatch"
  | "rate_limited"
  | "unavailable"
  | "timeout";

type CorrectionProblem = {
  status?: number;
  code?: CorrectionProblemCode;
  category?: CorrectionProblemCode;
  request_id?: string;
  retry_after?: string;
};

type CorrectionListResult = {
  items: Array<{
    correction_id: string;
    correction_sequence: number;
    correction_status: CorrectionStatus;
    receipt_type?: string;
    rejection_reason_code?: string;
    request_id?: string;
  }>;
  pagination: { limit: number; next_cursor: string | null };
  request_id?: string;
};

export async function listWorkRunCorrections(options: {
  baseUrl: string;
  apiKey: string;
  workRunId: string;
  cursor?: string;
  requestId: string;
}) {
  const search = new URLSearchParams({ limit: "25" });
  if (options.cursor) search.set("cursor", options.cursor);

  const response = await fetch(
    `${options.baseUrl}/admin/work-runs/${encodeURIComponent(options.workRunId)}/corrections?${search}`,
    {
      headers: {
        Authorization: `Bearer ${options.apiKey}`,
        Accept: "application/json, application/problem+json",
        "X-Request-Id": options.requestId
      }
    }
  );

  if (!response.ok) {
    const problem = (await response.json().catch(() => ({}))) as CorrectionProblem;
    throw {
      problem,
      retryAfter: response.headers.get("Retry-After") ?? problem.retry_after ?? null
    };
  }

  return (await response.json()) as CorrectionListResult;
}

Pagination And Retry

When next_cursor is present, pass that cursor back with the same filters and limit. If the platform returns invalid_cursor, discard only that cursor, reload the first page, and keep already-rendered rows keyed by correction_id plus correction_sequence until the replacement page arrives.

Retry-After may appear on rate_limited, unavailable, or timeout responses. Use it for reads, but keep role and tenant failures terminal until the actor or scope changes.

Problem code Developer handling
invalid_cursor Drop the cursor and reload from the first page without logging the cursor value.
forbidden Hide restricted history fields and do not expose review-only metadata.
tenant_mismatch Show a generic unavailable state; do not reveal whether another tenant's Work Run exists.
rate_limited Respect Retry-After before the next read.
unavailable or timeout Retry the read after Retry-After and keep the previous visible state until replacement data arrives.

Choose what this site may use. Your choice is kept in this browser only.