Skip to main content

Prerequisites

  • PostHog project with a workflow (or a new one)
  • API key created in PNTA Dashboard (project API Keys page)
  • Platform keys configured in PNTA Dashboard (see Platform Keys Setup)
  • Devices registered via a PNTA client SDK, with the user ID stored in device metadata (e.g. user_id)
To see the metadata of a device, open Devices in the PNTA Dashboard, then open one device.

Setup Steps

1. Add an HTTP Webhook Step

  1. In PostHog, open your workflow
  2. Add an HTTP Webhook step
  3. Set the URL to https://app.pnta.io/api/v1/notifications
  4. Set the method to POST
PostHog HTTP Webhook step with the PNTA URL and POST method

2. Set the Headers

  1. In Headers, add Content-Type: application/json
  2. In Secret headers, add Authorization: Bearer <PNTA API key>
Put the API key in Secret headers, not in Headers. PostHog encrypts secret headers and hides them after you save.

3. Set the JSON Body

Replace user_id with the metadata key your app sets on devices. PostHog fills {event.distinct_id} from the event that triggered the workflow. link_to is optional. It sets what opens when the user taps the notification: an in-app route such as /orders/123 (a deep link), or a URL such as https://example.com. Your app handles the tap, see Flutter or React Native. For all body fields, see Send Notification. Each entry in targets can be:
  • A metadata match, such as { "metadata": { "user_id": "123" } }. PNTA sends to every active device whose metadata contains all the given keys and values.
  • A device ID, such as "dev_V7pNZf2B"
  • A topic ID, such as "top_..."
  • A raw device push token
If some targets match no device, PNTA skips them and sends to the rest.

4. Test and Enable

  1. In the HTTP Webhook step, turn on Log responses. The step logs then show the request body and the PNTA response.
  2. In the test panel, turn off mocking. If mocking is on, PostHog does not send the request.
  3. Run a test with an event whose distinct_id is the user ID on your test device. Check that the push arrives on the device.
  4. Turn off Log responses, then publish and enable the workflow. A draft workflow does not run.
Before PostHog identifies a user, event.distinct_id is an anonymous ID and matches no device. The metadata value on the device must match the identified distinct_id. If your user ID is in a person property, use {person.properties.<property>} instead.

Troubleshooting

The step fails with 401. The API key is wrong. Check the Authorization value in Secret headers. The step fails with 422. The body is not valid, or no target matched a device or topic. The step logs show the PNTA error. “Delivery targets did not match any devices or topics” usually means the metadata key or value does not match the device. PostHog does not retry a failed step. By default, the workflow continues to the next step.

Resources

PostHog Workflows

Learn more about PostHog workflows

API Reference

All body fields for sending a notification