# Correct a document's kind

Source: https://amanucci.com/fr/docs/developers/api/cases/correctDocumentKind

## POST /v1/entities/{entityId}/documents/{documentId}/correct-kind

Correct a document's kind

Correct an inbound document's kind — an invoice that is a credit note, or the reverse (never a silent flip). One transaction: the act opens a `low_confidence_material` case with you as its opener, records your claim `document.kind` (`human:<you>` at 1.000) citing it, moves the document's kind with your name on the correction, versions the event — n+1 of an assembled document, re-classified from your claim (a purchase becomes a credit note); the first of one not yet assembled — and closes the case `corrected` naming the new version. The ADE then re-decides: a booked document is reversed and re-posted under the same automation policy (the CORRECT flow). An outbound document, or another entity's, is the hidden 404; the kind it already has is 409 `kind_unchanged`. The client-minted `id` is the case's and the idempotency key: a retry answers 200 with the stored result. Not a signed act: it posts nothing itself.

Operation ID: `correctDocumentKind`

### Parameters

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

### Request body

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/CorrectDocumentKind"
      }
    }
  }
}
```

### Responses

#### 200 A retry of the same id: the stored result.

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

#### 201 The kind moved, with your name on it, and the event has a new version.

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

#### 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"
    }
  }
}
```
