# Supersede a finalized document

Source: https://amanucci.com/nl/docs/developers/api/documents/supersedeDocument

## POST /v1/entities/{entityId}/documents/{documentId}/supersede

Supersede a finalized document

Revise a sent quote: chain a NEW draft quote off it, carrying every line with a fresh id. The old quote is replaced (`supersededBy`, NULL→id) only when that draft is finalized, so the customer may answer the old one until then; one draft revision at a time, so a second call answers the same draft, 200. Finalize is never repeated on one row — that is what keeps 'which version did the client get?' provable, since the old row keeps its number, its artifacts and its send record. A DRAFT is refused (409 `not_a_draft`): a draft is simply edited; an invoice or a credit note, 409 `requires_credit_note`; a quote a newer one already replaced, 409 `quote_superseded`.

Operation ID: `supersedeDocument`

### Parameters

```json
[
  {
    "schema": {
      "type": "string",
      "format": "uuid"
    },
    "required": true,
    "name": "documentId",
    "in": "path"
  },
  {
    "schema": {
      "type": "string",
      "format": "uuid"
    },
    "required": true,
    "name": "entityId",
    "in": "path"
  }
]
```

### Responses

#### 200 The quote's draft revision an earlier call made, written nothing.

```json
{
  "application/json": {
    "schema": {
      "$ref": "#/components/schemas/SupersedeResult"
    }
  }
}
```

#### 201 The draft revision, and the quote it will replace once finalized.

```json
{
  "application/json": {
    "schema": {
      "$ref": "#/components/schemas/SupersedeResult"
    }
  }
}
```

#### 401 Dead or absent credential (`unauthenticated`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 403 Authenticated, present, and refused: a missing grant, a missing seat, or a missing step-up.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 404 Absent, or hidden from this asker — the two are indistinguishable (`not-found`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 409 The world is not in the state the request assumed: a stale `expectedSeq`, or a transition already made.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 422 The request did not satisfy the schema (`invalid-input`).

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 429 Too many requests on this door's bucket (`rate-limited`); refused before any handler ran, `Retry-After` says when to come back.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```

#### 503 Temporarily unavailable; `Retry-After` says when to come back.

```json
{
  "application/problem+json": {
    "schema": {
      "$ref": "#/components/schemas/Problem"
    }
  }
}
```
