Email templates

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

Endpoints

GET
POST
GET
PATCH
DELETE
PATCH
POST
POST

List all messaging templates

Required API key scopes

hog_flow:read

Query parameters

  • basic
    boolean
    Default: false
  • created_by
    integer
  • limit
    integer
  • offset
    integer
  • search
    string
    Default:
  • tags
    array
  • transactional
    boolean | null

Response


Example request

GET /api/projects/:project_id/messaging_templates
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/messaging_templates/

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"tags": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"type": "string",
"message_category": "f74e6cc3-ac28-48ea-b195-3d593d7f03ec",
"deleted": true,
"sensitive": true,
"click_tracking_enabled": true,
"transactional_hog_flow_id": "a8e25637-2aa3-4321-9b11-3c79bdd88594",
"draft_content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"has_draft": true
}
]
}

Create messaging templates

Required API key scopes

hog_flow:write

Request parameters

  • name
    string
  • description
    string
  • tags
    array
  • content
  • type
    string
  • message_category
    string | null
  • deleted
    boolean
  • sensitive
    boolean
  • click_tracking_enabled
    boolean | null
  • draft_content

Response


Example request

POST /api/projects/:project_id/messaging_templates
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/messaging_templates/\
-d name="string"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"tags": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"type": "string",
"message_category": "f74e6cc3-ac28-48ea-b195-3d593d7f03ec",
"deleted": true,
"sensitive": true,
"click_tracking_enabled": true,
"transactional_hog_flow_id": "a8e25637-2aa3-4321-9b11-3c79bdd88594",
"draft_content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"has_draft": true
}

Retrieve messaging templates

Required API key scopes

hog_flow:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/messaging_templates/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/messaging_templates/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"tags": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"type": "string",
"message_category": "f74e6cc3-ac28-48ea-b195-3d593d7f03ec",
"deleted": true,
"sensitive": true,
"click_tracking_enabled": true,
"transactional_hog_flow_id": "a8e25637-2aa3-4321-9b11-3c79bdd88594",
"draft_content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"has_draft": true
}

Update messaging templates

Required API key scopes

hog_flow:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • description
    string
  • tags
    array
  • content
  • type
    string
  • message_category
    string | null
  • deleted
    boolean
  • sensitive
    boolean
  • click_tracking_enabled
    boolean | null
  • draft_content

Response


Example request

PATCH /api/projects/:project_id/messaging_templates/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/messaging_templates/:id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"tags": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"type": "string",
"message_category": "f74e6cc3-ac28-48ea-b195-3d593d7f03ec",
"deleted": true,
"sensitive": true,
"click_tracking_enabled": true,
"transactional_hog_flow_id": "a8e25637-2aa3-4321-9b11-3c79bdd88594",
"draft_content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"has_draft": true
}

Delete messaging templates

Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true

Required API key scopes

hog_flow:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/messaging_templates/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/messaging_templates/:id/

Example response

Status 405 No response body

Update messaging templates design

Required API key scopes

hog_flow:write

Path parameters

  • id
    string

Request parameters

  • operations
    Click to open
    array

Response


Example request

PATCH /api/projects/:project_id/messaging_templates/:id/design
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/messaging_templates/:id/design/\
-d operations="array"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"tags": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"type": "string",
"message_category": "f74e6cc3-ac28-48ea-b195-3d593d7f03ec",
"deleted": true,
"sensitive": true,
"click_tracking_enabled": true,
"transactional_hog_flow_id": "a8e25637-2aa3-4321-9b11-3c79bdd88594",
"draft_content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"has_draft": true
}

Create messaging templates make transactional

Make this template sendable over the transactional email API, or the transactional push API for a push template. This creates the workflow that sends it, with its own metrics, run history and versions. This can't be undone: the template stays transactional. Transactional sends ignore marketing opt-outs. Calling it again on a transactional template changes nothing. Needs the transactional_email:write scope, the same scope as sending. A key with hog_flow:write also works, but that scope reaches the rest of Workflows too. Without hog_flow:read, the response leaves out content and draft_content.

Required API key scopes

transactional_email:write

Path parameters

  • id
    string

Request parameters

  • from_integration_id
    integer | null
  • expected_type

Response


Example request

POST /api/projects/:project_id/messaging_templates/:id/make_transactional
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/messaging_templates/:id/make_transactional/\
-d from_integration_id="integer"

Example response

Status 200 The transactional template
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"description": "string",
"tags": [
"string"
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"type": "string",
"message_category": "f74e6cc3-ac28-48ea-b195-3d593d7f03ec",
"deleted": true,
"sensitive": true,
"click_tracking_enabled": true,
"transactional_hog_flow_id": "a8e25637-2aa3-4321-9b11-3c79bdd88594",
"draft_content": {
"templating": "liquid",
"email": {
"subject": "string",
"text": "string",
"preheader": "string",
"html": "string",
"design": {
"counters": {},
"schemaVersion": 0,
"body": {
"id": "string",
"rows": [
{}
],
"headers": [
{}
],
"footers": [
{}
],
"values": {}
}
},
"from": {
"email": "string",
"name": "string",
"integrationId": 0
},
"replyTo": "string"
},
"push": {
"title": "string",
"body": "string",
"image": "string",
"link": "string",
"channels": [
0
],
"data": {
"property1": "string",
"property2": "string"
}
}
},
"has_draft": true
}
Status 400 The template can't be sent, or there is no verified sender
Status 404 Template not found

Create messaging templates send

Send one transactional email from this template to one recipient. The template must be made transactional first. message_data fills the template's {{ variables.* }} placeholders. Transactional emails skip opt-outs and frequency caps. Send an Idempotency-Key header to retry safely without sending the email twice. Needs the transactional_email:write scope. A key with hog_flow:write also works, but that scope reaches the rest of Workflows too.

Required API key scopes

transactional_email:write

Path parameters

  • id
    string

Request parameters

  • to
    string
  • message_data
    object
  • identifiers

Response


Example request

POST /api/projects/:project_id/messaging_templates/:id/send
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/messaging_templates/:id/send/\
-d to="string"

Example response

Status 202 Email queued
RESPONSE
{
"message_id": "string",
"replayed": true,
"warnings": [
{
"code": "sandbox_sender",
"message": "string",
"setup_url": "string",
"agent_action": "string"
}
],
"status": "queued",
"scheduled_at": "2019-08-24T14:15:22Z"
}
Status 400 A field is invalid, the template isn't transactional or its email is paused, the sender isn't verified, the recipient can't be used, the Idempotency-Key is invalid, the email is too large to send, or the project has reached its limit of template keys and the `template_key` is new. When a code send from a project with no verified sending domain would go out from the PostHog test sender, that sender refuses `cc`, `bcc` and `attachments`
Status 403 The project has no verified sending domain, and the PostHog test sender isn't available for its organization
Status 404 Template not found
Status 409 A request with the same Idempotency-Key is still in progress
Status 422 The email can't go out: the recipient is suppressed or can't receive email, sending is suspended for the project or paused for this transactional email, or the Idempotency-Key was already used for a different request, or the email would go out from the PostHog test sender to someone outside the organization
Status 429 Rate limited, or the project is over its email quota
Status 503 The email pipeline did not confirm the send