GoliathDevelopersGet an API key
Reference/Contractsgenerated from the gateway manifest

prepareContract

Step 2: freeze a contract READY to send, with its unsigned PDF.

POST/api/v1/callWRITEidempotent · 24 hruns as the key's owner
View as Markdown

Step 2: freeze a contract READY to send, with its unsigned PDF. Build input.contract from getContractSendDraft's result (change what the person asked): values as { key, value } for every value to set, required blanks included; one recipient per role with exactly one of email or phone. Pass idempotencyKey (a new UUID) and resend it unchanged on a retry, so a lost response never makes a second contract. A template published again since step 1 is refused: start over. Needs the manage contracts capability. It reaches no signer: the person presses Send on /contracts/<id>, or a developer-API key calls sendContract.

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": "prepareContract",
    "variables": {
      "input": {
        "idempotencyKey": "<idempotencyKey>",
        "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
        }
      }
    }
  }'
import { GoliathClient } from '@goliath-data/sdk'

const goliath = new GoliathClient({
  apiKey: process.env.GOLIATH_API_KEY!,
  baseUrl: 'https://server.goliathdata.com',
})

const result = await goliath.contracts.prepareContract(
  {
    input: {
      idempotencyKey: '<idempotencyKey>',
      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
      }
    }
  },
  { idempotencyKey: crypto.randomUUID() },
)
const res = await fetch('https://server.goliathdata.com/api/v1/call', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.GOLIATH_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': crypto.randomUUID(),
  },
  body: JSON.stringify({
    operationId: 'prepareContract',
    variables: {
      input: {
        idempotencyKey: '<idempotencyKey>',
        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
        }
      }
    }
  }),
})
const { data, errors } = await res.json()

Variables

The example sends only what the schema requires. Some operations also need one of several optional variables (one filter or another, say); the description above says which.

inputAdminContractPrepareInput!required
idempotencyKeyID!required

A UUID the client generates once per prepare; a retry with the same key returns the same contract.

contractAdminContractSendInput!required

A contract as the sender has it on the prepare screen.

heldContractIdID

A held workflow draft this send completes (from `heldDraft`): revision 1 is frozen on that contract.

Every field, all the way down
variables
[
  {
    "name": "input",
    "type": "AdminContractPrepareInput!",
    "required": true,
    "description": null,
    "defaultValue": null,
    "fields": [
      {
        "name": "idempotencyKey",
        "type": "ID!",
        "required": true,
        "description": "A UUID the client generates once per prepare; a retry with the same key returns the same contract.",
        "defaultValue": null
      },
      {
        "name": "contract",
        "type": "AdminContractSendInput!",
        "required": true,
        "description": "A contract as the sender has it on the prepare screen.",
        "defaultValue": null,
        "fields": [
          {
            "name": "templateId",
            "type": "ID!",
            "required": true,
            "description": null,
            "defaultValue": null
          },
          {
            "name": "templateVersionId",
            "type": "ID!",
            "required": true,
            "description": "The published version the screen was opened on; a newer publish refuses the prepare.",
            "defaultValue": null
          },
          {
            "name": "contactId",
            "type": "ID!",
            "required": true,
            "description": null,
            "defaultValue": null
          },
          {
            "name": "pipelineItemId",
            "type": "ID",
            "required": false,
            "description": null,
            "defaultValue": null
          },
          {
            "name": "dealId",
            "type": "ID",
            "required": false,
            "description": null,
            "defaultValue": null
          },
          {
            "name": "title",
            "type": "String!",
            "required": true,
            "description": null,
            "defaultValue": null
          },
          {
            "name": "values",
            "type": "[AdminContractSendValueInput!]!",
            "required": true,
            "description": "The sender's value per prefill; a prefill left out keeps what the CRM filled.",
            "defaultValue": null,
            "fields": [
              {
                "name": "key",
                "type": "ID!",
                "required": true,
                "description": "The prefill's key.",
                "defaultValue": null
              },
              {
                "name": "value",
                "type": "String!",
                "required": true,
                "description": null,
                "defaultValue": null
              },
              {
                "name": "type",
                "type": "AdminContractValueType",
                "required": false,
                "description": "The value's type on this send, when the sender changed it; left out keeps the template's.",
                "defaultValue": null,
                "enumValues": [
                  "TEXT",
                  "DATE",
                  "MONEY",
                  "NUMBER",
                  "BOOLEAN"
                ]
              }
            ]
          },
          {
            "name": "recipients",
            "type": "[AdminContractSendRecipientInput!]!",
            "required": true,
            "description": null,
            "defaultValue": null,
            "fields": [
              {
                "name": "roleKey",
                "type": "ID!",
                "required": true,
                "description": null,
                "defaultValue": null
              },
              {
                "name": "displayName",
                "type": "String!",
                "required": true,
                "description": null,
                "defaultValue": null
              },
              {
                "name": "email",
                "type": "String",
                "required": false,
                "description": "Their email when they are sent it by Email; give exactly one of an email or a phone.",
                "defaultValue": null
              },
              {
                "name": "phone",
                "type": "String",
                "required": false,
                "description": "Their mobile number when they are sent it by Text, in any US form; give exactly one of an email or a phone.",
                "defaultValue": null
              },
              {
                "name": "contactId",
                "type": "ID",
                "required": false,
                "description": "The contact this recipient is, when they are one.",
                "defaultValue": null
              },
              {
                "name": "signingOrder",
                "type": "Int",
                "required": false,
                "description": "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.",
                "defaultValue": null
              }
            ]
          },
          {
            "name": "subject",
            "type": "String!",
            "required": true,
            "description": null,
            "defaultValue": null
          },
          {
            "name": "message",
            "type": "String!",
            "required": true,
            "description": null,
            "defaultValue": null
          },
          {
            "name": "expiryDays",
            "type": "Int!",
            "required": true,
            "description": "Days signers have once it is sent, 1-90.",
            "defaultValue": null
          },
          {
            "name": "expiresOn",
            "type": "String",
            "required": false,
            "description": "The day the links stop working, YYYY-MM-DD, through its end in the contract's time zone; left out, expiryDays from the send.",
            "defaultValue": null
          },
          {
            "name": "noteInText",
            "type": "Boolean",
            "required": false,
            "description": "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).",
            "defaultValue": null
          },
          {
            "name": "reminderIntervalDays",
            "type": "Int",
            "required": false,
            "description": "Days between automatic reminders, 1-30; left out, every day; null turns them off.",
            "defaultValue": null
          },
          {
            "name": "afterSigning",
            "type": "ContractAfterSigningInput",
            "required": false,
            "description": "This send's After signing button. Left out: the template's; null: none on this send.",
            "defaultValue": null,
            "fields": [
              {
                "name": "label",
                "type": "String!",
                "required": true,
                "description": null,
                "defaultValue": null
              },
              {
                "name": "url",
                "type": "String!",
                "required": true,
                "description": null,
                "defaultValue": null
              },
              {
                "name": "caption",
                "type": "String",
                "required": false,
                "description": null,
                "defaultValue": null
              },
              {
                "name": "icon",
                "type": "ContractAfterSigningIcon!",
                "required": true,
                "description": "The mark beside the After signing button's label. GOLIATH: Goliath's own mark, with a trailing arrow.",
                "defaultValue": null,
                "enumValues": [
                  "GOLIATH",
                  "ARROW_RIGHT",
                  "CALENDAR",
                  "NONE"
                ]
              },
              {
                "name": "style",
                "type": "ContractAfterSigningStyle!",
                "required": true,
                "description": "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.",
                "defaultValue": null,
                "enumValues": [
                  "DARK",
                  "LIGHT",
                  "BRAND"
                ]
              },
              {
                "name": "color",
                "type": "String",
                "required": false,
                "description": null,
                "defaultValue": null
              },
              {
                "name": "autoContinue",
                "type": "Boolean!",
                "required": true,
                "description": null,
                "defaultValue": null
              }
            ]
          },
          {
            "name": "salesOfferId",
            "type": "ID",
            "required": false,
            "description": "The Goliath sales offer this send carries (a Goliath plan template's, created by a Goliath admin from the Plan sheet).",
            "defaultValue": null
          }
        ]
      },
      {
        "name": "heldContractId",
        "type": "ID",
        "required": false,
        "description": "A held workflow draft this send completes (from `heldDraft`): revision 1 is frozen on that contract.",
        "defaultValue": null
      }
    ]
  }
]

Response

What comes back under data: a list shows as one entry, and a value as its type.

response shape
{
  "data": {
    "contractsMutation": {
      "prepareContract": {
        "id": "<ID>",
        "title": "…",
        "status": "PREPARING",
        "revisionNumber": 0,
        "contactName": "…",
        "unsignedPdfUrl": "…"
      }
    }
  }
}

Errors

Idempotency

Send an Idempotency-Key of 1 to 255 characters. A finished request retried with the same key replays its stored response, marked Idempotency-Replayed: true; one still in flight returns 409 idempotency_conflict. Keys expire after 24 hours. Write without fear →