Warteliste offen: Hol dir früh Zugang

API-Referenz: Integrationen

7 Endpunkte der Gruppe «Integrationen». Die Referenz stammt aus der englischen OpenAPI-Spezifikation und ist nicht übersetzt.

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.

Beispiel

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

Antworten

StatusBeschreibung
200 The integration (configured false when not set up) PostHogIntegration
Felder der Antwort
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

FeldTypBeschreibung
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

Beispiel

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"}'

Antworten

StatusBeschreibung
200 Updated PostHogIntegration
Felder der Antwort
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
Felder der Antwort
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 Fehler im üblichen Format, Fehler und 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.

Beispiel

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

Antworten

StatusBeschreibung
204 Removed
404 Fehler im üblichen Format, Fehler und 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.

Beispiel

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

Antworten

StatusBeschreibung
200 Result
Felder der Antwort
deliveredboolean
statusinteger
duration_msinteger
errorstring
404 Fehler im üblichen Format, Fehler und 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

FeldTypBeschreibung
days *integer

Beispiel

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

Antworten

StatusBeschreibung
202 Queued
Felder der Antwort
queuedinteger
409 Fehler im üblichen Format, Fehler und Limits
422 Fehler im üblichen Format, Fehler und Limits

Deliveries to PostHog, newest first

GET/v1/integrations/posthog/deliveries

Parameter

NameOrtTypBeschreibung
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.

Beispiel

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

Antworten

StatusBeschreibung
200 Deliveries
Felder der Antwort
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

Parameter

NameOrtTypBeschreibung
delivery_id *pathinteger

Beispiel

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

Antworten

StatusBeschreibung
202 Queued
Felder der Antwort
idinteger
statusenum: pending
404 Fehler im üblichen Format, Fehler und Limits
409 Fehler im üblichen Format, Fehler und Limits