PaymentPulse API
Reference

Everything you need to integrate Stripe billing into your SaaS. Authenticate with your project API key, make a few calls, and you're live.

Authentication

All API requests (except health check and webhooks) require a project API key sent via the X-API-Key header.

API keys are generated in the PaymentPulse dashboard and are scoped per project. Each key uses the format pp_live_xxx.

Request Header
X-API-Key: your_project_api_key

Base URL

All API endpoints are relative to:

Base URL
https://www.paymentpulse.co.uk

All requests must use HTTPS. HTTP requests are redirected automatically.

Health Check

GET /api/health

Returns service status. No authentication required. Returns JSON by default, or redirects to the status page if the client accepts HTML.

Response

200 OK
{ "status": "ok", "service": "paymentpulse", "time": "2026-03-13T20:00:00+00:00", "stripe": "configured", "db": "connected" }

Create Checkout Session

POST /api/checkout

Creates a Stripe Checkout session for a subscription. Automatically creates or reuses a Stripe customer record.

Request Body

Field Type Required Description
external_user_id string Yes Your application's user ID
email string Yes Customer email address
plan_slug string Yes Your plan identifier (e.g. professional)
stripe_price_id string Yes Stripe Price ID (e.g. price_1AB2CD...)
success_url string Yes Redirect URL after successful payment
cancel_url string Yes Redirect URL if user cancels
interval string No monthly or yearly (default: monthly)
trial_days integer No Number of trial days before billing starts

Example Request

POST /api/checkout
POST /api/checkout Content-Type: application/json X-API-Key: your_project_api_key { "external_user_id": "42", "email": "jane@example.com", "plan_slug": "professional", "stripe_price_id": "price_1AB2CD...", "success_url": "https://yourapp.com/success", "cancel_url": "https://yourapp.com/pricing" }

Response

200 OK
{ "url": "https://checkout.stripe.com/c/pay/...", "session_id": "cs_live_...", "customer_id": 1 }

Redirect the user to the url to complete payment. Stripe handles the checkout UI.

Create Portal Session

POST /api/portal

Creates a Stripe Customer Portal session. Lets customers manage subscriptions, update payment methods, and view invoices.

Request Body

Field Type Required Description
external_user_id string Yes Your application's user ID
return_url string Yes URL to return to after managing billing

Response

200 OK
{ "url": "https://billing.stripe.com/p/session/..." }

Get Subscription Status

GET /api/subscription?external_user_id={id}

Returns the current subscription status for a user. Use this to gate features in your application.

Query Parameters

Parameter Type Required Description
external_user_id string Yes Your application's user ID

Response

200 OK
{ "has_subscription": true, "plan_slug": "professional", "status": "active", "interval": "monthly", "current_period_end": "2026-04-13 20:00:00", "cancelled_at": null, "stripe_customer_id": "cus_...", "stripe_subscription_id": "sub_..." }

Subscription Statuses

Status Description
activeSubscription is active and paid
cancellingWill cancel at end of current period
cancelledSubscription has ended
past_duePayment failed โ€” retry pending
unpaidAll payment retries exhausted
trialingIn free trial period

Export Customers

GET /api/customers/export

Exports all customers and their subscription data for your project. Supports JSON and CSV formats.

Query Parameters

Parameter Type Required Description
format string No json (default) or csv

Response (JSON)

200 OK
{ "project_slug": "companypulse", "exported_at": "2026-03-13T20:00:00+00:00", "count": 42, "customers": [...] }

Webhook Events

POST /api/webhook

PaymentPulse automatically receives and processes Stripe webhook events. You don't need to call this endpoint โ€” Stripe sends events directly. All events are verified via Stripe signature and logged for audit.

Processed Events

Event Action
checkout.session.completed Creates subscription record, links customer
customer.subscription.updated Syncs status, period end, cancellation
customer.subscription.deleted Marks subscription as cancelled
invoice.payment_failed Marks subscription as past_due

All webhook events are idempotent โ€” replaying the same event has no effect.

Error Handling

All errors return a consistent JSON structure:

Error Response
{ "error": true, "message": "Missing required field: email" }

HTTP Status Codes

Code Meaning
200Success
400Bad request / invalid input
401Missing or invalid API key
403Forbidden (e.g. cross-project access)
404Resource not found
413Request body exceeds 1MB
422Validation error โ€” missing required field
429Rate limited
502Stripe API error
503Service unavailable (Stripe not configured)

Rate Limits

Rate limits protect the service from abuse. Authenticated requests have higher limits.

Type Limit Window
Authenticated (per project) Higher Per minute
Unauthenticated (per IP) Stricter Per minute

When rate limited, the API returns 429 Too Many Requests. Back off and retry after a short delay.

Ready to integrate?

Get your API key from the dashboard and start accepting payments in minutes.