---
title: "Task finished (completed or failed)"
method: POST
path: "taskFinalized"
---

# Task finished (completed or failed)

`POST taskFinalized` (webhook)

Sent once per task to the webhook_url given at submission, when the task reaches completed or failed. The body is the default GET /tasks/{id} response (no billing, no webhook block). Reply with any 2xx within 10 seconds. Non-2xx, timeout or connection failure triggers up to two retries (~40 s and ~5 min after the task finished). Delivery is at-least-once: deduplicate on the body id. Redirects are not followed; the response body is never read. If all attempts fail the result is NOT lost: poll GET /tasks/{id} — the webhook is the fast path, GET is the guaranteed path.

## Headers

- `User-Agent` 'reAPI-Webhook/1', required

## Payload

- object
  - `id` string, required
  - `model` string, required
  - `status` 'completed' | 'failed', required
  - `modal_expires_at` integer: Midjourney only: Unix deadline for submitting modal parameters to the same task.
  - `created_at` integer, required
  - `output` object, nullable
  - `usage` object, required
    - `credits` integer, required: Backward-compatible whole-credit settlement summary. Exact token-metered amounts are reported in the optional top-level billing object.
  - `billing` union: GPT Image settlement evidence. Returned only when GET /tasks/{id} uses include=billing. source=openai_token_usage is exact; source=reservation_estimate means successful output was charged at the admission reservation because trustworthy token meters were unavailable.
    - object
      - `source` 'openai_token_usage' | 'reservation_estimate', required: Evidence used for the final charge.
      - `credits_exact` number, required: Full formula-derived amount in credits, retained to micro-USD precision.
      - `cost_usd` number, required: Full formula-derived amount in USD. In a balance shortfall this is the actual amount, not only the amount collected.
      - `credits_charged` integer: Final whole-credit reservation charge when source is reservation_estimate.
      - `cost_usd_charged` number: Final reservation charge in USD when source is reservation_estimate.
      - `text_input_tokens` integer, required: Actual text-input tokens reported by the model.
      - `image_input_tokens` integer, required: Actual image-input tokens reported by the model.
      - `image_output_tokens` integer, required: Actual image-output tokens reported by the model.
      - `cached_tokens` integer: Optional cached input reported by the model. It is retained as usage metadata; the sell formula applies the configured standard rates to the reported text/image input totals and does not apply a separate cache discount.
    - object
      - `source` 'openai_token_usage' | 'reservation_estimate', required: Evidence used for the final charge.
      - `credits_exact` number: Full formula-derived amount in credits, retained to micro-USD precision.
      - `cost_usd` number: Full formula-derived amount in USD. In a balance shortfall this is the actual amount, not only the amount collected.
      - `credits_charged` integer, required: Final whole-credit reservation charge when source is reservation_estimate.
      - `cost_usd_charged` number, required: Final reservation charge in USD when source is reservation_estimate.
      - `text_input_tokens` integer: Actual text-input tokens reported by the model.
      - `image_input_tokens` integer: Actual image-input tokens reported by the model.
      - `image_output_tokens` integer: Actual image-output tokens reported by the model.
      - `cached_tokens` integer: Optional cached input reported by the model. It is retained as usage metadata; the sell formula applies the configured standard rates to the reported text/image input totals and does not apply a separate cache discount.
  - `error` object, nullable
  - `webhook` object, nullable: Webhook delivery record. Returned only when GET /tasks/{id} uses include=webhook; null when the task was submitted without webhook_url. Never included in the webhook payload itself.
    - `status` 'pending' | 'in_progress' | 'delivered' | 'failed', required: pending = task not finished yet; in_progress = an attempt is running; delivered = a 2xx was recorded; failed = the last attempt failed (retries stop after the third).
    - `attempts` integer, required
    - `claimed_at` string, date-time, nullable
    - `response_status` integer, nullable: HTTP status your endpoint returned on the last attempt.
    - `last_error` string, nullable: http_<status> | timeout | connect_failed | dns_failed | tls_error | blocked_private_address | request_failed | render_timeout | render_failed | stale_claim | attempt_lost
    - `last_attempt_at` string, date-time, nullable
    - `delivered_at` string, date-time, nullable

## Acknowledgement `2XX`

Acknowledged. Any other status counts as a failed attempt.

---

[API](https://skmtc.dev/reapi/apis/reapi-http-api.md) - [All operations](https://skmtc.dev/reapi/apis/reapi-http-api/llms.txt) - [OpenAPI document](https://skmtc.dev/reapi/apis/reapi-http-api/revisions/1d2713a6058a?raw)
