FlowPrime guides
The router receives the Stripe events of your workspace's own Stripe account, verifies their signature, keeps a log of each one, and forwards them to HTTP endpoints you choose by matching a field in the event. FlowPrime already consumes the events your sales need (checkout, subscription changes, invoices, refunds), so most products never add a route. Add one when your own server must react to a Stripe event directly, and use the logs to answer "did Stripe's event arrive, and where did it go?".
| Capability | How | Status |
|---|---|---|
| List your routes | router_list_routes |
live |
| Create, edit, pause or delete a route | REST: POST, PUT, DELETE /v1/admin/routes with an org API key, via service_contract service=router; or the dashboard (Developers > Webhooks > Routes) |
live |
| See which route a payload would match, without sending | router_test_route |
live |
| Delivery log, filterable by event type, status, date, event id | router_get_logs |
live |
| Delivery status of one Stripe event | router_get_event_status |
live |
| Counts of events and routes | router_get_stats |
live |
| Send a logged event again | router_replay_webhook |
live |
| Receive the Stripe events of your own Stripe account | automatic once a Stripe account is linked (see platform_guide topic=payments) |
live |
| Verify that a forwarded event came from FlowPrime and is fresh | X-FlowPrime-Signature on every forward from a route with a destinationSecret (see "Verify a forwarded event") |
live |
Licence events about your product's customers (license.created, license.updated, license.suspended, ...) |
webhookUrl on reseller_operator_product_create; sent by license, not by the router |
live |
| Rotate the licence webhook's signing secret | reseller_operator_product_rotate_webhook_secret |
live |
| GitHub webhooks | the endpoint exists, but a workspace cannot set its GitHub signing secret | planned |
| Other sources (Shopify, arbitrary JSON) | only Stripe and GitHub signatures are accepted | planned |
| Match on anything but exact equality (prefix, wildcard, several fields) | not implemented | planned |
reseller_stripe_account_get must answer connected: true, status: active, and routerWired: true. Linking (dashboard, Business > Settings > Payment account) registers a webhook endpoint on your Stripe account that points at your router address and stores its signing secret. Nothing else gives the router your secret.checkout.session.completed, checkout.session.async_payment_succeeded, checkout.session.async_payment_failed, customer.subscription.updated, customer.subscription.deleted, customer.subscription.trial_will_end, invoice.paid, invoice.payment_failed, charge.refunded. To receive more, add them to that same endpoint in your Stripe dashboard; FlowPrime keeps extra types you add.auth_create_api_key, sent as Authorization: Bearer ffk_.... A scoped key needs the router:admin scope. A token that holds only a customer seat is refused.type = invoice.paid. Nested paths work: data.object.metadata.plan = pro.POST /v1/admin/routes:
{ "name": "invoices to billing", "matchField": "type", "matchValue": "invoice.paid",
"destinationUrl": "https://api.example.com/hooks/stripe",
"destinationSecret": "a-long-random-string", "priority": 10, "active": true }
router_list_routes to confirm it is there and active. The secret is never read back (hasDestinationSecret says one is set).router_test_route with a sample event, for example {"id":"evt_test","type":"invoice.paid","data":{"object":{}}}. The answer names the route that matched and the value it extracted, or every route it checked when nothing matched.POST with the raw Stripe event as JSON and verify X-FlowPrime-Signature (below). The router also sends Authorization: Bearer <destinationSecret>, X-FlowPrime-Event-Id, X-Stripe-Event-Id, X-Stripe-Event-Type, X-Tenant-Id and X-Forwarded-By. Answer 2xx fast.router_list_routes for the route id.PUT /v1/admin/routes/{id} with only the fields to change. "active": false pauses it; "destinationSecret": "" clears the secret, and omitting it keeps the current one.DELETE /v1/admin/routes/{id} removes it. Its past log rows stay.Every forward from a route that has a destinationSecret carries:
X-FlowPrime-Signature: t=1731150000,v1=5f2b...
X-FlowPrime-Event-Id: evt_1QabcXYZ
t is the Unix time (seconds) the attempt was sent. Every attempt, retries included, is signed again with a fresh t.v1 is the lowercase hex HMAC-SHA256, keyed by the route's destinationSecret, of the bytes <t>.<raw body>: the timestamp, a dot, then the request body exactly as received. Compute it over the raw bytes, never over re-serialized JSON.t more than 5 minutes from your clock: that is what stops a captured request from being replayed later.X-FlowPrime-Event-Id stays the same across retries of one event, but a replay (router_replay_webhook) prefixes it with replay_: de-duplicate on the event's own id in the body, which never changes.Authorization: Bearer <destinationSecret> header is still sent, so receivers written before the signature keep working. Checking the bearer alone proves only that the sender knows the secret; the signature also proves the body was not changed and is recent.# FastAPI
import hashlib, hmac, json, os, time
from fastapi import FastAPI, Header, HTTPException, Request
app = FastAPI()
SECRET = os.environ["ROUTE_SECRET"].encode() # the route's destinationSecret
TOLERANCE = 300 # seconds
seen: set[str] = set() # use your database in production
def verify(raw: bytes, header: str) -> None:
parts = [p.split("=", 1) for p in header.split(",") if "=" in p]
t = next((v for k, v in parts if k == "t"), "")
sigs = [v for k, v in parts if k == "v1"]
if not t.isdigit() or abs(time.time() - int(t)) > TOLERANCE:
raise HTTPException(401, "stale or missing timestamp")
expected = hmac.new(SECRET, t.encode() + b"." + raw, hashlib.sha256).hexdigest()
if not any(hmac.compare_digest(expected, s) for s in sigs):
raise HTTPException(401, "bad signature")
@app.post("/hooks/stripe")
async def stripe_hook(request: Request,
x_flowprime_signature: str = Header(""),
x_flowprime_event_id: str = Header("")):
raw = await request.body()
verify(raw, x_flowprime_signature)
event_id = json.loads(raw)["id"] # the body's id: the same for retries AND replays
if event_id in seen: # an event you already handled
return {"ok": True}
event = await request.json()
if event["type"] == "invoice.paid":
... # your work, kept short
seen.add(event_id)
return {"ok": True} # 2xx, also for types you ignore
The body is the Stripe event object exactly as Stripe sent it (id, type, data.object, ...). A replay carries the original body; only the event id headers gain the replay_ prefix, so key your de-duplication on the body's id if a replay must not run twice. Keep the de-duplication record for at least the 24 hours retries can last.
To change a route's secret, accept both the old and the new secret on your server first, then PUT /v1/admin/routes/{id} with the new destinationSecret, then drop the old one: the router signs with one secret at a time, and retries already queued are signed with the secret the route had when the event arrived.
router_get_event_status with the Stripe event id (evt_...): latest status, delivery status, attempts, response code, error, destination.router_get_logs with eventType, status (forwarded, failed, no_match), dateFrom/dateTo or eventIdSearch. Each row has a numeric id: that is the logId replay takes.router_get_stats for totals.router_replay_webhook with the logId of the received event.replay_.router_get_event_status with the evt_... id from your Stripe dashboard. "No logs found" means the event never reached the router: check that the Stripe endpoint carries that event type and that reseller_stripe_account_get shows routerWired: true.no_match: the event arrived and no route matched. Compare your matchField and matchValue with the event using router_test_route and the real payload.failed with a response_code: your server answered it. A 401 means your server refused the bearer or the signature: check the secret and that you compute the HMAC over the raw body; a 404 means the path is wrong. Fix it. The background retries keep going for 24 hours on their own; router_replay_webhook resends now, or after they gave up.failed with no response code: the destination did not answer (timeout, DNS, TLS). Check that the URL is public and serves valid HTTPS.type = invoice.* matches nothing. Numbers and booleans compare as their JSON text.router_test_route stops at the first match (highest priority first), so it shows one route even when several will receive the event.X-FlowPrime-Signature instead, which is keyed by destinationSecret. Set a secret on every route: a route without one is forwarded unsigned.destinationUrl must be an absolute public http(s) URL: no IP literals, no localhost, no internal or single-label host names, no user:password@. Redirects are never followed. The router refuses such a destination when you create the route (a development environment may allow private hosts for testing).no_match in the log means the event arrived and no route matched. FlowPrime's own processing of your sales is separate and still happened.webhookUrl on a product is a different channel: license POSTs licence events once, with no retry, signed with webhookSecret in the same X-FlowPrime-Signature scheme (and the older X-Webhook-Signature: sha256=<hmac of the body>). Its secret rotates with reseller_operator_product_rotate_webhook_secret. Router tools do not show those deliveries; platform_guide topic=payments has its receiver.router_list_routes - every route: match field and value, destination, priority, active, whether a secret is set.router_test_route - which route a JSON payload would match, without forwarding.router_get_logs - received and delivered events, filterable and paginated.router_get_event_status - one Stripe event's delivery: status, attempts, response code, error.router_get_stats - event and route counts.router_replay_webhook - forward a logged event again to the routes that match now.service_contract service=router (routes CRUD, logs by event id)platform_guide topic=payments (Stripe account, product webhookUrl), platform_guide topic=auth (API keys)platform_guide)platform_guide topic=ai)platform_guide topic=analytics)platform_guide topic=auth)platform_guide topic=feedback)platform_guide topic=mail)platform_guide topic=marketing)platform_guide topic=marketplace)platform_guide topic=newsletter)platform_guide topic=observability)platform_guide topic=payments)platform_guide topic=pilot)platform_guide topic=reporting)platform_guide topic=storage)