GoliathDevelopersGet an API key
Reference/Communicationsgenerated from the gateway manifest

sendEmail

Send an email as the key owner through their connected Gmail/Outlook mailbox.

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

Send an email as the key owner through their connected Gmail/Outlook mailbox. NEEDS THE ORGANIZATION'S SEND CONSENT ATTESTATION, like sendText: refused with 403 send_consent_not_attested until an org admin attests (setSendConsentAttestation), and with 403 outbound_paused while the org has paused everything. IMPORTANT: bodyHtml is the authored content, not necessarily the complete delivered Gmail body: appendSignature defaults to true, so Goliath appends the sending mailbox's synced/default Gmail signature when one is available. Set appendSignature to false when bodyHtml must be the complete email with nothing appended. Outlook sends do not append a Goliath-managed signature. fromClientId + fromEmail identify the sending mailbox: get them from listCommunicationChannels. contactId (optional) attaches the email to that contact timeline; a Do-Not-Contact-blocked contactId returns a GraphQL error (the one failure that is not ok:false) and releases any Idempotency-Key for a corrected retry. On any other failure ok is false and failureReason + failureMessage explain why (NO_CONNECTED_MAILBOX, INVALID_SENDER, MAILBOX_MISSING_SEND_SCOPE, or PROVIDER_SEND_FAILED). No attachments or threading in v1.

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": "sendEmail",
    "variables": {
      "fromClientId": "<String>",
      "fromEmail": "<String>",
      "to": [
        "<String>"
      ],
      "subject": "<String>"
    }
  }'
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.communications.sendEmail(
  {
    fromClientId: '<String>',
    fromEmail: '<String>',
    to: [
      '<String>'
    ],
    subject: '<String>'
  },
  { 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: 'sendEmail',
    variables: {
      fromClientId: '<String>',
      fromEmail: '<String>',
      to: [
        '<String>'
      ],
      subject: '<String>'
    }
  }),
})
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.

fromClientIdString!required
fromEmailString!required
to[String!]!required
cc[String!]
bcc[String!]
subjectString!required
bodyHtmlString
appendSignatureBoolean

Default true.

contactIdID

Response

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

response shape
{
  "data": {
    "emailMutation": {
      "sendEmail": {
        "ok": true,
        "failureReason": "NO_CONNECTED_MAILBOX",
        "failureMessage": "…",
        "contact": {
          "id": "<ID>"
        }
      }
    }
  }
}

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 →