---
title: "POST /api/cascade-tracing/documents/replace"
method: POST
path: "/api/cascade-tracing/documents/replace"
tags: ["Order Tracing - Documents"]
---

# POST /api/cascade-tracing/documents/replace

`POST /api/cascade-tracing/documents/replace`

## Request

- Base URL: `https://api.retraced.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.retraced.com/api/cascade-tracing/documents/replace`
- Auth: none declared

Replaces a tracing document the caller's company uploaded with one of its uploaded files. The old document is removed and a new one — same type, same Order Hub order, named after the new file — is attached to the purchase order's link; the file is moved to the private bucket. 404 `not_found` (purchase order, document or link missing or removed), 403 `insufficient_rights` (another company's document), 400 `document_type_not_valid` (`documentType` differs from the document's type), 404 `invalid_document_id` (the file is not the caller's). The links' document figures are refreshed in the background.

## Request body

- object
  - `oldTracingDocumentId` string, required
  - `tracingPurchaseOrderId` string, required
  - `documentType` string, required
  - `documents` string[], required

## Response `200`

Default Response

- object
  - `metadata` object, required
    - `success` boolean, required: True when the request succeeded.
  - `data` object, required
    - `id` string, required
    - `tracingDocumentId` string, required

## Other responses

- `400`: Default Response
- `401`: Default Response
- `403`: Default Response
- `404`: Default Response

## Changes

> 108 revisions in range; 2 not diffed.

- **2026-10-09** `ddfec192e804`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/retraced/apis/api-reference/changes/api/cascade-tracing/documents/replace/post.md)

---

[API](https://skmtc.dev/retraced/apis/api-reference.md) - [All operations](https://skmtc.dev/retraced/apis/api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/retraced/apis/api-reference/revisions/83309c4abd20?raw)
