# Record a quote's outcome

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

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

Record a quote's outcome

Record a finalized quote's outcome, once: `accepted` makes its draft invoice in the same transaction — its lines and discount under fresh ids, issued today and due the customer's payment term after it — and answers that invoice; `declined` makes nothing. A repeat of the same outcome answers it again and writes nothing; the other one, once set, is 409 `outcome_conflict`. An accept past the quote's `validUntil` is 409 `quote_expired`; either answer to a quote a newer one replaces (`supersededBy` set), 409 `quote_superseded`; a document that is not a finalized quote, 409 `not_a_quote`.

Operation ID: `recordDocumentOutcome`

### 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": {
          "outcome": {
            "type": "string",
            "enum": [
              "accepted",
              "declined"
            ]
          }
        },
        "required": [
          "outcome"
        ],
        "additionalProperties": false
      }
    }
  }
}
```

### Responses

#### 200 The outcome, and the invoice an accept made.

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

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