# API reference: Integrations

> Endpoints of the Integrations group of the Sendtide API (PostHog) with parameters, request body, responses and curl examples.

URL: https://sendtide.ch/en/docs/api/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
| Status | Description |
| --- | --- |
| 200 | The integration (configured false when not set up) PostHogIntegration |
## 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
| Field | Type | Description |
| --- | --- | --- |
| api_key | string | Example: phc_abc123 |
| host | string (uri) | |
| events | array | |
| distinct_id | object | |
| distinct_id.mode | enum: hashed / plain / metadata | |
| distinct_id.metadata_key | string | Example: user_id |
| metadata_keys | array | |
| enabled | boolean | |
### 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
| Status | Description |
| --- | --- |
| 200 | Updated PostHogIntegration |
| 201 | Set up PostHogIntegration |
| 422 | Error in the usual format, [errors and limits](https://sendtide.ch/en/docs/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
| Status | Description |
| --- | --- |
| 204 | Removed |
| 404 | Error in the usual format, [errors and limits](https://sendtide.ch/en/docs/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
| Status | Description |
| --- | --- |
| 200 | Result |
| 404 | Error in the usual format, [errors and limits](https://sendtide.ch/en/docs/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
| Field | Type | Description |
| --- | --- | --- |
| 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
| Status | Description |
| --- | --- |
| 202 | Queued |
| 409 | Error in the usual format, [errors and limits](https://sendtide.ch/en/docs/errors-and-limits/) |
| 422 | Error in the usual format, [errors and limits](https://sendtide.ch/en/docs/errors-and-limits/) |
## Deliveries to PostHog, newest first

GET /v1/integrations/posthog/deliveries
### Parameters
| Name | In | Type | Description |
| --- | --- | --- | --- |
| status | query | enum: pending / delivered / failed | |
| limit | query | integer | Page 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 |
| cursor | query | string | The 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
| Status | Description |
| --- | --- |
| 200 | Deliveries |
## Send the event of a delivery to PostHog again

POST /v1/integrations/posthog/deliveries/{delivery_id}/retry
### Parameters
| Name | In | Type | Description |
| --- | --- | --- | --- |
| delivery_id * | path | integer | |
### Example

```
curl -X POST "https://api.sendtide.ch/v1/integrations/posthog/deliveries/42/retry" \
  -H "Authorization: Bearer sk_test_…"
```
### Responses
| Status | Description |
| --- | --- |
| 202 | Queued |
| 404 | Error in the usual format, [errors and limits](https://sendtide.ch/en/docs/errors-and-limits/) |
| 409 | Error in the usual format, [errors and limits](https://sendtide.ch/en/docs/errors-and-limits/) |
