# Merge two parties through a case

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

## POST /v1/entities/{entityId}/cases/{caseId}/merge-party

Merge two parties through a case

Merge two parties proven one (a human confirms; no silent weak-key merge, ever). The merge RESOLVES this live case — the one you read the duplicate on. One transaction: `loserId` is tombstoned into `winnerId` through the party door (both live parties of these books; the loser keeps its history, it stops being offered), the case closes `corrected` with the pair and your reason and you as its resolver, and every open item of the entity with no live allocation goes back to the Matcher, so the merged party's items and IBANs match as one and its parked lines re-pair. A party into itself is 422 `party_invalid`; a party already merged, or a merged target, is 409 `party_conflict`, and so is a merge into the entity's own seller while a document or a recurring plan not ended names the loser or a party merged into it (a draft or a plan can name another party first; a finalized document never moves); another entity's party, or none, is 404; another entity's case is the hidden 404; a case already closed is 409 `case_terminal`. A retry on a case this act resolved with the same pair answers 200 with the stored result. Not a signed act: it posts nothing itself. A case the Assembler closed because its document was booked from another of its files (a scan's gate case its e-invoice booked) is 409 `case_booked_from_file`, in words naming the kind of file it was booked from.

Operation ID: `mergeParty`

### Parameters

```json
[
  {
    "schema": {
      "type": "string",
      "format": "uuid"
    },
    "required": true,
    "name": "caseId",
    "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/MergeParty"
      }
    }
  }
}
```

### Responses

#### 200 A retry on a case this act resolved: the stored result.

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

#### 201 The parties are one, with your name on the case.

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

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