API docs

Demo data + live PayPal sandbox

The same engine the app uses is open over a small REST API, so agents and scripts can read subscription health, scan stores and ask for recovery drafts. Everything returns JSON. Errors look like {"error":{"code","message","details"}}.

Agents can read, scan and propose. A person approves before any email is sent. Without an API key, data is synthetic and every response carries the header X-PayFlow-Data: synthetic.

Signed-in owners can create a read-only key in Settings. Send it as Authorization: Bearer pf_live_... to the summary, high-risk and events endpoints and they return your real PayFlow data with X-PayFlow-Data: live. Never put a key in a URL. A bad or revoked key gets a 401, not demo data. The limit is 120 requests per minute per key. A key cannot send email, and the drafting endpoint stays on demo data.

The machine-readable spec is at /openapi.json (OpenAPI 3.1), ready for Postman or APIMatic. A ready-made Postman collection is in the repository under docs/postman.

For AI agents there is a plain-text summary at /llms.txt and a tool manifest at /.well-known/agent.json. Neither has a send tool: the API only reads, scans and drafts.

  • GET/api/lifecycle/summary

    Subscription health snapshot: active count, MRR, 30-day churn, high-risk count.

    curl https://payflow.ameliorlabs.ca/api/lifecycle/summary
  • GET/api/subscriptions/high-risk

    Subscriptions that need attention, with a plain-language riskReason. Query: limit (default 50).

    curl 'https://payflow.ameliorlabs.ca/api/subscriptions/high-risk?limit=5'
  • GET/api/subscriptions/{id}/events

    Normalized event history for one subscription.

    curl https://payflow.ameliorlabs.ca/api/subscriptions/sub_001/events
  • POST/api/playbooks/recover-failed-payments

    Draft recovery emails for 1 to 25 subscriptions. Drafts only: a person approves before anything is sent.

    curl -X POST https://payflow.ameliorlabs.ca/api/playbooks/recover-failed-payments -H 'Content-Type: application/json' -d '{"subscriptionIds":["sub_001"]}'
  • GET/api/playbooks/{id}

    Status and drafted emails for a playbook.

    curl https://payflow.ameliorlabs.ca/api/playbooks/pb_abc123
  • POST/api/readiness/scan

    Scan a store for agent readiness: score, per-dimension scores, findings and fix snippets.

    curl -X POST https://payflow.ameliorlabs.ca/api/readiness/scan -H 'Content-Type: application/json' -d '{"storeUrl":"https://example-store.com"}'
  • GET/api/readiness/audits

    Past readiness audits. Empty in demo mode.

    curl https://payflow.ameliorlabs.ca/api/readiness/audits
  • GET/api/dev/scenarios

    Available sandbox scenarios with event counts.

    curl https://payflow.ameliorlabs.ca/api/dev/scenarios
  • GET/api/dev/scenarios/{name}/events

    Event timeline and agent decisions for a scenario.

    curl https://payflow.ameliorlabs.ca/api/dev/scenarios/subscription_churn_storm/events