Workflow Email

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

POST

Create workflow email drafts

Write a first draft of an email to the people an entity points at. A model writes it when the project has AI drafts on and the organization approved AI data processing; otherwise, or when the model fails, the fixed template for the source is returned. Nothing is saved.

Required API key scopes

hog_flow:write

Request parameters

  • source
  • source_id
    string

Response


Example request

POST /api/projects/:project_id/workflow_email_drafts
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/workflow_email_drafts/\
-d source=undefined,\
-d source_id="string"

Example response

Status 200
RESPONSE
{
"subject": "string",
"preheader": "string",
"html": "string",
"text": "string",
"generated_by": "ai",
"template_reason": "ai_not_approved"
}