# correctContract

Correct a sent contract on the same template version, contact and deal: `input.contract` as prepareContract takes it with the changes, `reason` (emailed to the signers whose link stops working, and kept on the evidence chain), `expectedRevisionNumber` (getContract's revisionNumber; a correction since refuses this one), `expectedSignatureCount` (how many had signed; a signature since refuses it) and `idempotencyKey` (a new UUID, resent unchanged on a retry). Needs the manage contracts capability.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "correctContract", "variables": {...} }`
- Scope: `WRITE`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `input`: `AdminContractCorrectInput!` (required)
  - `idempotencyKey`: `ID!` (required). A UUID the client generates once per correction; a retry with the same key corrects once.
  - `contractId`: `ID!` (required)
  - `expectedRevisionNumber`: `Int!` (required). The revision the screen was opened on (correcting.revisionNumber); a correction made since refuses this one.
  - `expectedSignatureCount`: `Int`. How many had signed when the screen opened (correcting.signedNames); a signature since refuses this one. Left out, no check.
  - `reason`: `String!` (required). What changed: on the evidence chain, and emailed to signers whose link stops working.
  - `contract`: `AdminContractSendInput!` (required). The corrected contract, on the same template version, contact and deal.
    - `templateId`: `ID!` (required)
    - `templateVersionId`: `ID!` (required). The published version the screen was opened on; a newer publish refuses the prepare.
    - `contactId`: `ID!` (required)
    - `pipelineItemId`: `ID`
    - `dealId`: `ID`
    - `title`: `String!` (required)
    - `values`: `[AdminContractSendValueInput!]!` (required). The sender's value per prefill; a prefill left out keeps what the CRM filled.
      - `key`: `ID!` (required). The prefill's key.
      - `value`: `String!` (required)
      - `type`: `AdminContractValueType` (one of `TEXT`, `DATE`, `MONEY`, `NUMBER`, `BOOLEAN`). The value's type on this send, when the sender changed it; left out keeps the template's.
    - `recipients`: `[AdminContractSendRecipientInput!]!` (required)
      - `roleKey`: `ID!` (required)
      - `displayName`: `String!` (required)
      - `email`: `String`. Their email when they are sent it by Email; give exactly one of an email or a phone.
      - `phone`: `String`. Their mobile number when they are sent it by Text, in any US form; give exactly one of an email or a phone.
      - `contactId`: `ID`. The contact this recipient is, when they are one.
      - `signingOrder`: `Int`. The signer's turn, 1-based; signers sharing a turn sign at once. Null on a copy; null on every recipient keeps the template's order.
    - `subject`: `String!` (required)
    - `message`: `String!` (required)
    - `expiryDays`: `Int!` (required). Days signers have once it is sent, 1-90.
    - `expiresOn`: `String`. The day the links stop working, YYYY-MM-DD, through its end in the contract's time zone; left out, expiryDays from the send.
    - `noteInText`: `Boolean`. The note opens the invitation texts too, as the send screen's note field says; left out, the note is for the email alone (workflows, the API).
    - `reminderIntervalDays`: `Int`. Days between automatic reminders, 1-30; left out, every day; null turns them off.
    - `afterSigning`: `ContractAfterSigningInput`. This send's After signing button. Left out: the template's; null: none on this send.
      - `label`: `String!` (required)
      - `url`: `String!` (required)
      - `caption`: `String`
      - `icon`: `ContractAfterSigningIcon!` (required, one of `GOLIATH`, `ARROW_RIGHT`, `CALENDAR`, `NONE`). The mark beside the After signing button's label. GOLIATH: Goliath's own mark, with a trailing arrow.
      - `style`: `ContractAfterSigningStyle!` (required, one of `DARK`, `LIGHT`, `BRAND`). How the After signing button is painted. DARK: The app's dark button. LIGHT: White with an outline. BRAND: Filled with the template owner's own color.
      - `color`: `String`
      - `autoContinue`: `Boolean!` (required)
    - `salesOfferId`: `ID`. The Goliath sales offer this send carries (a Goliath plan template's, created by a Goliath admin from the Plan sheet).

## Response (data, an example)

```json
{
  "contractsMutation": {
    "correctContract": {
      "id": "<ID>",
      "title": "…",
      "status": "PREPARING",
      "revisionNumber": 0
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "correctContract",
    "variables": {
      "input": {
        "idempotencyKey": "<idempotencyKey>",
        "contractId": "<contractId>",
        "expectedRevisionNumber": 10,
        "reason": "<String>",
        "contract": {
          "templateId": "<templateId>",
          "templateVersionId": "<templateVersionId>",
          "contactId": "<contactId>",
          "title": "<String>",
          "values": [
            {
              "key": "<key>",
              "value": "<String>"
            }
          ],
          "recipients": [
            {
              "roleKey": "<roleKey>",
              "displayName": "<String>"
            }
          ],
          "subject": "<String>",
          "message": "<String>",
          "expiryDays": 10
        }
      }
    }
  }'
```
