---
title: "Settle Prose"
method: POST
path: "/billing/internal/settle-prose"
tags: ["billing"]
---

# Settle Prose

`POST /billing/internal/settle-prose`

Settle one scoped-prose job's billing (Phase 3), called by Modal.

Idempotent via the ledger claim on ``prose_jobs``: exactly one of
``settled_at`` / ``hold_released_at`` is claimed first-writer-wins, so a
duplicate Modal dispatch, a replayed callback, or a timeout reconciliation
can neither double-charge nor double-refund. Billing account (personal vs
team pool) and the estimated hold come from the claimed row, never the
payload. Pricing stays single-sourced: real token counts recompute the
authoritative cost via ``llm_pricing``.

## Headers

- `x-service-token` string, required

## Request body

- ProseSettleRequest — Scoped-prose job settlement callback (Phase 3). ``outcome`` is ``completed`` (debit actual cost) or ``failed`` (release the hold). Billing routing (personal vs team pool) comes from the claimed ``prose_jobs`` row, not this payload — only the token counts, provider/model, and the Dodo customer id are trusted from Modal. Idempotency is enforced by the ledger claim, so a replayed callback is a no-op.
  - `prose_job_id` string, required
  - `outcome` string
  - `dodo_customer_id` string
  - `actual_cost_cents` integer
  - `actual_input_tokens` integer
  - `actual_output_tokens` integer
  - `completed_count` integer
  - `failed_count` integer
  - `provider` string
  - `model` string
  - `error` string, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/repowise/apis/repowise-hosted-api.md) · [All operations](https://skmtc.dev/repowise/apis/repowise-hosted-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/repowise/repowise-hosted-api/revisions/1e57283a9737/schema)
