# Correct a numbered document's email address

Source: https://amanucci.com/docs/developers/api/documents/readdressDocument

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

Correct a numbered document's email address

Correct the address a finalized document's email goes to, while nothing has reached the customer: `to` becomes its email's own address, `null` handing it back to the customer's first. In the same transaction it appends the document's next revision by the caller, its snapshot the head's with the address moved, which Activity shows as an `edited` row naming the old and the new address. A repeat of the address it holds answers it again and writes nothing. A draft is 409 `not_finalized` (its address is `reviseDocument`'s `email`), a document something reached 409 `address_frozen` (`document_send.recipient` keeps where each attempt went), an address no email can go to 422 `email_invalid`, each writing nothing. An attempt still in flight does not freeze it.

Operation ID: `readdressDocument`

### 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": {
        "type": "object",
        "properties": {
          "to": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 320,
            "description": "The address, one with an `@` and no space; `null`: the customer's first."
          }
        },
        "required": [
          "to"
        ],
        "additionalProperties": false
      }
    }
  }
}
```

### Responses

#### 200 The address its email goes to now, and the head revision.

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

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