Messaging

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

Endpoints

POST
POST
GET
POST
GET
POST
GET

Create messaging preferences add opt out

Manually add a recipient to the opt-out list for a specific category or all marketing messages.

Required API key scopes

hog_flow:write

Request parameters

  • identifier
    string
  • category_key
    string

Response


Example request

POST /api/projects/:project_id/messaging_preferences/add_opt_out
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_preferences/add_opt_out/\
-d identifier="string"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"identifier": "string",
"updated_at": "2019-08-24T14:15:22Z",
"preferences": null
}

Create messaging preferences bulk add opt outs

Opt every recipient in the list out of the category named on their entry, or a default category.

Required API key scopes

hog_flow:write

Request parameters

  • opt_outs
    Click to open
    array
  • category_key
    string

Response


Example request

POST /api/projects/:project_id/messaging_preferences/bulk_add_opt_outs
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_preferences/bulk_add_opt_outs/\
-d opt_outs="array"

Example response

Status 200
RESPONSE
{
"total": 0,
"opted_out": 0,
"skipped": 0,
"errors": [
"string"
]
}
Status 404
RESPONSE
{
"error": "string"
}

Retrieve messaging preferences export opt outs csv

Stream the opt-out list for a category as a CSV file that can be re-imported as-is.

Required API key scopes

hog_flow:read

Query parameters

  • category_key
    string

Example request

GET /api/projects/:project_id/messaging_preferences/export_opt_outs_csv
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_preferences/export_opt_outs_csv/

Example response

Status 200
Status 404
RESPONSE
{
"error": "string"
}

Create messaging preferences generate link

Generate an unsubscribe link for the current user's email address

Request parameters

  • recipient
    string

Response


Example request

POST /api/projects/:project_id/messaging_preferences/generate_link
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_preferences/generate_link/\
-d recipient="string"

Example response

Status 200
RESPONSE
{
"preferences_url": "http://example.com"
}

Retrieve messaging preferences opt outs

Get opt-outs filtered by category or overall opt-outs if no category specified

Required API key scopes

hog_flow:read

Query parameters

  • category_key
    string
  • page
    integer
  • page_size
    integer

Response


Example request

GET /api/projects/:project_id/messaging_preferences/opt_outs
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_preferences/opt_outs/

Example response

Status 200
RESPONSE
{
"count": 0,
"next": "http://example.com",
"previous": "http://example.com",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"identifier": "string",
"updated_at": "2019-08-24T14:15:22Z",
"preferences": null
}
]
}
Status 404
RESPONSE
{
"error": "string"
}

Create messaging preferences remove opt out

Opt a recipient back in to a specific category, or to all marketing messages.

Required API key scopes

hog_flow:write

Request parameters

  • identifier
    string
  • category_key
    string

Response


Example request

POST /api/projects/:project_id/messaging_preferences/remove_opt_out
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_preferences/remove_opt_out/\
-d identifier="string"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"identifier": "string",
"updated_at": "2019-08-24T14:15:22Z",
"preferences": null
}

Retrieve messaging preferences webhook url

Return the webhook URL for Customer.io integration setup.

Response


Example request

GET /api/projects/:project_id/messaging_preferences/webhook_url
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_preferences/webhook_url/

Example response

Status 200
RESPONSE
{
"url": "http://example.com"
}