# sendEmail

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.

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

## Variables

- `fromClientId`: `String!` (required)
- `fromEmail`: `String!` (required)
- `to`: `[String!]!` (required)
- `cc`: `[String!]`
- `bcc`: `[String!]`
- `subject`: `String!` (required)
- `bodyHtml`: `String`
- `appendSignature`: `Boolean` (default `true`)
- `contactId`: `ID`

## Response (data, an example)

```json
{
  "emailMutation": {
    "sendEmail": {
      "ok": true,
      "failureReason": "NO_CONNECTED_MAILBOX",
      "failureMessage": "…",
      "contact": {
        "id": "<ID>"
      }
    }
  }
}
```

## 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": "sendEmail",
    "variables": {
      "fromClientId": "<String>",
      "fromEmail": "<String>",
      "to": [
        "<String>"
      ],
      "subject": "<String>"
    }
  }'
```
