# previewContractMessages

What the first signers would be sent: the signing email's words (`email`) and the text (`text`), each null when no first signer is reached that way, worded by the send's own code. Takes what prepareContract takes as `input.contract`. Nothing is saved or sent.

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

## Variables

- `input`: `AdminContractSendInput!` (required). A contract as the sender has it on the prepare screen.
  - `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": {
    "previewMessages": {
      "email": {
        "to": "…",
        "fromName": "…",
        "subject": "…",
        "heading": "…",
        "senderName": "…",
        "replyToFirstName": "…",
        "message": "…",
        "documentTitle": "…",
        "documentDetail": "…",
        "openBy": "…"
      },
      "text": {
        "to": "…",
        "body": "…"
      }
    }
  }
}
```

## 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": "previewContractMessages",
    "variables": {
      "input": {
        "templateId": "<templateId>",
        "templateVersionId": "<templateVersionId>",
        "contactId": "<contactId>",
        "title": "<String>",
        "values": [
          {
            "key": "<key>",
            "value": "<String>"
          }
        ],
        "recipients": [
          {
            "roleKey": "<roleKey>",
            "displayName": "<String>"
          }
        ],
        "subject": "<String>",
        "message": "<String>",
        "expiryDays": 10
      }
    }
  }'
```
