Skip to content
Menu

Integrations

RevenueCat, Stripe, App Store and Google Play

BetaMarkdown version

Send purchases, renewals and refunds from RevenueCat, Stripe, the App Store or Google Play to Herald as events, and use a revenue event as an agent goal.

Note

Built and tested against each vendor's documented API; tell us if anything differs in your account.

Revenue events reach Herald from RevenueCat, Stripe, the App Store or Google Play as ordinary events, so an agent can learn from them. Every revenue event carries revenue (in major units: 9.99, not 999) and currency, so a goal tier can weight by value.

What you'll need

  • An admin of the account. Integrations are set up in Settings → Integrations.
  • RevenueCat: access to the project's webhooks.
  • Stripe: access to Developers → Webhooks, to add an endpoint and copy its signing secret.
  • App Store: access to the app's App Store Server Notifications in App Store Connect.
  • Google Play: a Google Cloud project for Pub/Sub, and a service account with View financial data on the app in Play Console.
  • Purchases tagged with your own user id, as described under each store.

Use a revenue event as a goal

Pick subscription_started (or purchase for a one-off sale) as an agent's goal. The agent then learns which messages lead to paying. The goal picker lists the event names seen for the app, so a name appears once the first webhook arrives.

RevenueCat

  1. In Settings → Integrations, connect RevenueCat and copy the URL and secret.
  2. In RevenueCat, open Integrations → Webhooks and add a webhook. Paste the URL.
  3. Set the Authorization header value to the secret. It must equal the secret, with or without a Bearer prefix.
  4. Set RevenueCat's App User ID to the same user id your app sends Herald.

Option: Include sandbox purchases (off by default).

RevenueCat typeEventsubscription_status attribute
INITIAL_PURCHASE with period_type TRIALtrial_startedactive
INITIAL_PURCHASEsubscription_startedactive
RENEWAL with is_trial_conversion: truetrial_convertedactive
RENEWALsubscription_renewedactive
NON_RENEWING_PURCHASEpurchaseunchanged
CANCELLATIONsubscription_cancelledcancelled
UNCANCELLATIONsubscription_uncancelledactive
EXPIRATIONsubscription_expiredexpired
BILLING_ISSUEbilling_issuebilling_issue
PRODUCT_CHANGEsubscription_changedactive
TESTNothing ingested; answers 200, counted in skipped
Any other typeSkipped
  • Properties: revenue is RevenueCat's price, currency is USD (its price is always USD), plus product_id, store, environment and period_type. price can be 0 (trials) or negative (refunds).
  • Anonymous ids ($RCAnonymousID:…) are skipped. Sandbox events are skipped unless the option is on.
  • The event id is revenuecat:<event.id>, so RevenueCat's retries count as duplicates.
  • subscription_status is set on the user with the event, so segments can target it.

Common errors

MessageCauseFix
Unauthorized401: the Authorization header value isn't the secret, or the integration is pausedPaste the secret again, with or without Bearer
Expected a JSON object400: the body isn't a JSON objectUse RevenueCat's webhook, not a custom body

Stripe

  1. In Settings → Integrations, connect Stripe to get the URL.
  2. In Stripe, open Developers → Webhooks and add an endpoint with that URL. Choose checkout.session.completed, invoice.paid, invoice.payment_failed, customer.subscription.deleted and charge.refunded.
  3. Paste the endpoint's signing secret (whsec_…) into the console. Stripe makes this secret. Until it is set, deliveries answer 401.
  4. Put your user id in metadata.herald_user_id on checkout sessions or subscriptions, or in client_reference_id on checkout.

Options: Include test mode events (off by default). After rolling the secret in Stripe, paste the new one with Rotate secret.

Stripe eventEventrevenue from
checkout.session.completedpurchaseamount_total
invoice.paid with billing_reason: subscription_createsubscription_startedamount_paid
invoice.paid, other reasonssubscription_renewedamount_paid
invoice.payment_failedbilling_issueamount_due
customer.subscription.deletedsubscription_cancellednone
charge.refundedrefundamount_refunded
Any other typeSkipped: answers 200, counted in skipped
  • revenue is the minor-unit amount divided by the currency's exponent: 100 for most currencies, no division for zero-decimal currencies such as JPY and KRW, 1000 for BHD, JOD, KWD, OMR and TND. currency is lower case, as Stripe sends it. There is no currency conversion.
  • The signature is Stripe-Signature, checked against the signing secret, and its timestamp must be within 5 minutes of now.
  • An event with no user id is skipped and counted. Herald never calls Stripe's API.
  • The event id is stripe:<event.id>.

Common errors

MessageCauseFix
Unauthorized401: no signing secret is set, it doesn't match, or the Stripe-Signature timestamp is more than 5 minutes oldPaste the endpoint's whsec_… secret; after rolling it in Stripe, use Rotate secret

App Store and Google Play

For apps that don't use RevenueCat: Apple and Google tell Herald about purchases directly. The events and the subscription_status attribute are the same as RevenueCat's, so goals work unchanged: pick subscription_started (or trial_started, purchase) as the agent's goal.

Identity (required). A store notification doesn't say who the person is unless the app put it on the purchase. Herald never creates people from store notifications: an unmatched purchase answers 200 and is counted in skipped.

  • Apple: set appAccountToken when the app starts a purchase. If the user id your app sends Herald is a UUID, use it. Otherwise create a UUID, store it with the user, and send it to Herald as the app_account_token attribute. Herald matches the person whose user id equals the token (case-insensitive), then the person whose app_account_token attribute equals it.
  • Google: set obfuscatedAccountId (BillingFlowParams.setObfuscatedAccountId) to the user id your app sends Herald. Herald matches it exactly.

App Store

  1. In Settings → Integrations, connect App Store with the app's Bundle ID. Option: Include sandbox purchases (off by default).
  2. In App Store Connect, open your app → App Information → App Store Server Notifications. Paste the URL as the Production Server URL (and as the Sandbox URL if sandbox is on). Choose Version 2.

There is no secret: Apple's signature is the authentication. A notification with a missing or invalid signature answers 401 and nothing is ingested. Test can't sign anything for Apple: request a test notification with the App Store Server API and watch the event count (a TEST notification counts in skipped). A notification for another bundle id answers 200 (skipped) and shows as the last error. environment: Sandbox is skipped unless sandbox is on.

Apple notificationType / subtypeEventsubscription_status attribute
SUBSCRIBED / INITIAL_BUY, transaction offerDiscountType: FREE_TRIALtrial_startedactive
SUBSCRIBED / INITIAL_BUY or RESUBSCRIBEsubscription_startedactive
DID_RENEWsubscription_renewedactive
DID_CHANGE_RENEWAL_STATUS / AUTO_RENEW_DISABLEDsubscription_cancelledcancelled
EXPIREDsubscription_expiredexpired
DID_FAIL_TO_RENEWbilling_issuebilling_issue
REFUNDrefundunchanged
ONE_TIME_CHARGE (consumables, non-consumables, non-renewing)purchaseunchanged
TEST, any other typeSkipped: answers 200, counted in skipped
  • revenue is the transaction's price / 1000 (Apple's price is in milliunits), plus currency, product_id, store: "app_store" and environment.
  • The event id is app_store:<notificationUUID> (Apple's retries reuse it) and the event time is signedDate.

Common errors

MessageCauseFix
Unauthorized401: the notification's Apple signature is missing or invalidUse the URL as a Version 2 notification URL
Notification for bundle id <id>, not this integration'sShown as the last error; the notification is skippedSet the integration's Bundle ID to the app's

Google Play

  1. In Google Cloud, create a Pub/Sub topic and give google-play-developer-notifications@system.gserviceaccount.com the Publisher role.
  2. Add a push subscription with the URL from the console, turn on authentication and pick a service account. Enter that account's email in the console (pushServiceAccount).
  3. In Play Console → Monetize → Monetization setup, enter the topic.
  4. Create a service account with access to your app in Play Console (Users and permissions → View financial data) and paste its JSON key as the secret.

Config: packageName (required) and the option Include test purchases (off by default). Test signs in with the key and reads the app's subscriptions to prove access.

The push request must carry a Google-signed token for your push service account and the exact webhook URL as its audience; otherwise it answers 401. A notification only says something changed, so Herald reads the purchase from the Play Developer API before anything counts. Play answering 404 or 410 answers 200 (skipped); any other Play failure answers 503 so Pub/Sub retries, and shows as the last error. A notification for another package answers 200 (skipped) and shows as the last error.

Google Play notificationEventsubscription_status attribute
subscription PURCHASED, line item with a free trialtrial_startedactive
subscription PURCHASEDsubscription_startedactive
subscription RENEWED, RECOVEREDsubscription_renewedactive
subscription CANCELEDsubscription_cancelledcancelled
subscription EXPIRED, REVOKEDsubscription_expiredexpired
subscription IN_GRACE_PERIOD, ON_HOLDbilling_issuebilling_issue
one-time ONE_TIME_PRODUCT_PURCHASEDpurchaseunchanged
voidedPurchaseNotificationrefundunchanged
testNotification, any other typeSkipped: answers 200, counted in skipped
  • Test purchases are skipped unless the option is on.
  • revenue and currency come from the line item's recurring price when present; there is none for a free trial or a one-time product (the API gives no price). Also product_id and store: "google_play".
  • The event id is google_play:<message.messageId> (Pub/Sub redeliveries reuse it) and the event time is eventTimeMillis.

Common errors

MessageCauseFix
Unauthorized401: the push request has no Google-signed token for pushServiceAccount, or its audience isn't the exact URLTurn on authentication on the push subscription and enter that account's email
Expected a Pub/Sub push message400: the body isn't a Pub/Sub pushUse a push subscription on the Play topic
Notification for package <got>, not <package>Shown as the last error; the notification is skippedSet packageName to the app's
Google's keys are unavailable; try again or Google Play is unavailable; try again503: Google couldn't confirm the notification nowNone: Pub/Sub retries
Google Play answered HTTP <status>Shown as the last error: Google Play refused the purchase lookupCheck the service account's access in Play Console
Google Play doesn't know the app <package>Test: the service account can't see the appGrant it access to the app, or fix packageName

Troubleshooting

  • No goal to pick. Event names appear in the picker after the first webhook arrives. Use Send test in the vendor, or make a sandbox purchase with the sandbox option on.
  • Events are skipped. Check that the vendor's user id matches the id your app sends Herald. For the App Store and Google Play, check that the purchase carries appAccountToken or obfuscatedAccountId as described above.

See Herald decide live →