Waitlist open: get early access

API reference: Integrations

7 endpoints of the Integrations group.

The PostHog integration

GET/v1/integrations/posthog

Sendtide forwards mail events to PostHog as sendtide_email_<type> (sent, delivered, opened, clicked, bounced, complained, unsubscribed, failed) through PostHog's batch capture API. PostHog is an optional recipient that you configure yourself with your own project; events go there only after you set it up. The project API key is never returned, only api_key_hint.

Example

curl "https://api.sendtide.ch/v1/integrations/posthog" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
200 The integration (configured false when not set up) PostHogIntegration
Response fields
configuredboolean
idstring | null
enabledboolean
disabled_reasonstring | null
hoststring
api_key_hintstring | nullExample: phc_…ab12
eventsarray<string>
distinct_idobject
distinct_id.modeenum: hashed | plain | metadata
distinct_id.metadata_keystring
metadata_keysarray<string>
success_rate_24hnumber | null
created_atstring | null (date-time)
event_typesarray<string>
hostsarray<object>
hosts[].idstring
hosts[].urlstring

Set up or change the PostHog integration

PUT/v1/integrations/posthog

api_key (the project API key, phc_...) is required the first time. host is https://eu.i.posthog.com (default), https://us.i.posthog.com or the https URL of a self-hosted PostHog. distinct_id.mode is hashed (default: SHA-256 of an account specific salt and the recipient address), plain (the address) or metadata (the field metadata_key of the send request's metadata, the hashed id when it is missing). Only the metadata_keys you list are sent along as metadata_<key> properties. Re-enabling clears a disable reason. Test keys cannot change it (403 test_key_forbidden).

Request body application/json

FieldTypeDescription
api_keystringExample: phc_abc123
hoststring (uri)
eventsarray<enum: sent | delivered | opened | clicked | bounced | complained | unsubscribed | failed>
distinct_idobject
distinct_id.modeenum: hashed | plain | metadata
distinct_id.metadata_keystringExample: user_id
metadata_keysarray<string>
enabledboolean

Example

curl -X PUT "https://api.sendtide.ch/v1/integrations/posthog" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"api_key":"phc_abc123"}'

Responses

StatusDescription
200 Updated PostHogIntegration
Response fields
configuredboolean
idstring | null
enabledboolean
disabled_reasonstring | null
hoststring
api_key_hintstring | nullExample: phc_…ab12
eventsarray<string>
distinct_idobject
distinct_id.modeenum: hashed | plain | metadata
distinct_id.metadata_keystring
metadata_keysarray<string>
success_rate_24hnumber | null
created_atstring | null (date-time)
event_typesarray<string>
hostsarray<object>
hosts[].idstring
hosts[].urlstring
201 Set up PostHogIntegration
Response fields
configuredboolean
idstring | null
enabledboolean
disabled_reasonstring | null
hoststring
api_key_hintstring | nullExample: phc_…ab12
eventsarray<string>
distinct_idobject
distinct_id.modeenum: hashed | plain | metadata
distinct_id.metadata_keystring
metadata_keysarray<string>
success_rate_24hnumber | null
created_atstring | null (date-time)
event_typesarray<string>
hostsarray<object>
hosts[].idstring
hosts[].urlstring
422 Error in the usual format, errors and limits

Remove the PostHog integration

DELETE/v1/integrations/posthog

Deletes the integration with its project key and its delivery log. Events already sent stay in PostHog.

Example

curl -X DELETE "https://api.sendtide.ch/v1/integrations/posthog" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
204 Removed
404 Error in the usual format, errors and limits

Send a test event to PostHog now

POST/v1/integrations/posthog/test

Sends one sendtide_test event (it creates no person) and reports PostHog's answer.

Example

curl -X POST "https://api.sendtide.ch/v1/integrations/posthog/test" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
200 Result
Response fields
deliveredboolean
statusinteger
duration_msinteger
errorstring
404 Error in the usual format, errors and limits

Send the events of the last days to PostHog

POST/v1/integrations/posthog/backfill

Queues the selected mail events of the last days (1 to 30, at most 50'000 events, else 422 too_many_events). An event that still has a pending delivery is skipped. PostHog drops events it already has (same event id). Unsubscribes are not part of a backfill.

Request body application/json

FieldTypeDescription
days *integer

Example

curl -X POST "https://api.sendtide.ch/v1/integrations/posthog/backfill" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"days":1}'

Responses

StatusDescription
202 Queued
Response fields
queuedinteger
409 Error in the usual format, errors and limits
422 Error in the usual format, errors and limits

Deliveries to PostHog, newest first

GET/v1/integrations/posthog/deliveries

Parameters

NameInTypeDescription
statusqueryenum: pending | delivered | failed
limitqueryintegerPage size. The default and the maximum depend on the endpoint (emails 50 up to 500, received mail 50 up to 200, audit up to 200, the others 100 up to 500 or 1000). Default: 100
cursorquerystringThe next_cursor of the previous page. Opaque; pass it unchanged to the same endpoint with the same filters.

Example

curl "https://api.sendtide.ch/v1/integrations/posthog/deliveries" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
200 Deliveries
Response fields
dataarray<WebhookDelivery>
data[].idinteger
data[].event_idstring | nullExample: evt_1042
data[].eventenum: email.queued | email.sent | email.delivered | email.delayed | email.opened | email.machine_opened | email.clicked | email.bounced | email.complained | email.rejected | email.failed | email.suppressed | email.canceled | email.held | email.unsubscribed | email.received
data[].statusenum: pending | delivered | failed
data[].sourceenum: event | retry | replay
data[].attemptsinteger
data[].last_statusinteger | null
data[].last_errorstring | null
data[].duration_msinteger | null
data[].next_attempt_atstring | null (date-time)
data[].created_atstring (date-time)
next_cursorstring | null

Send the event of a delivery to PostHog again

POST/v1/integrations/posthog/deliveries/{delivery_id}/retry

Parameters

NameInTypeDescription
delivery_id *pathinteger

Example

curl -X POST "https://api.sendtide.ch/v1/integrations/posthog/deliveries/42/retry" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
202 Queued
Response fields
idinteger
statusenum: pending
404 Error in the usual format, errors and limits
409 Error in the usual format, errors and limits