Elements runtime reference / AI and delivery

sendEmail

Send tenant-scoped email through data-worker-agent and notification-delivery without exposing email credentials to Element code.

Signatuur

sendEmail(payload=None, **kwargs) / send_email(to=None, subject=None, body=None, html_body=None, template_key=None, template_context=None, recipients=None, recipient_uids=None, data=None, attachments=None, persist_notification=None, idempotency_key=None, timeout_seconds=None)

Doel

Send tenant-scoped email through data-worker-agent and notification-delivery without exposing email credentials to Element code.

Aliases and imports

  • send_email
  • send_email_message
  • mail.send

Payloadformaat

Use these fields as the Python call arguments or keyword payload for this helper.

{
  "to": [
    {
      "email": "customer@example.com",
      "displayName": "Customer"
    }
  ],
  "subject": "Your report is ready",
  "body": "The report is attached.",
  "attachments": [
    {
      "gcsUri": "gs://dashview-cache/filestore/tenant/exports/report.pdf",
      "filename": "report.pdf"
    }
  ],
  "data": {
    "campaign": "q1"
  },
  "idempotencyKey": "report-ready:customer@example.com:2026-07-06"
}
FieldDescription
to/recipientsRecipient emails, user UIDs, or recipient objects such as {'email': 'customer@example.com', 'displayName': 'Customer'}.
recipient_uids/recipientUidsDashview user recipient UIDs. Use these when also persisting inbox notifications.
subjectRequired email subject, or title in dict payload form.
body/html_body/htmlBodyPlain text and optional HTML body. A template key can provide body content when configured.
template_key/templateKeyOptional notification-delivery email template key configured for the tenant.
template_context/templateContextOptional JSON object merged into the tenant email template context.
dataOptional JSON object stored in notification data and template context.
attachmentsOptional GCS attachment refs with bucket/objectPath/object_path/object or gcsUri.
persist_notification/persistNotificationOptional bool. Only applies to recipients with a UID.
idempotency_key/idempotencyKeyOptional caller key for audit/idempotency.
timeout_seconds/timeoutSecondsOptional delivery timeout.

Return payload

{
  "ok": true,
  "sent": 1,
  "failed": 0,
  "skipped": 0,
  "results": [
    {
      "recipientEmail": "customer@example.com",
      "email": {
        "status": "sent"
      }
    }
  ]
}

Voorbeeld

from sendEmail import sendEmail


def run():
    result = sendEmail(
        to=["customer@example.com"],
        subject="Update",
        body="Your update is ready.",
        data={"campaign": "q1"},
    )
    return {"sent": result["sent"], "failed": result["failed"]}

Scope-notities