Portal Sessions
A portal session is a temporary, customer-scoped access pass that lets one of YOUR customers log into a MarginFront-hosted page to see their own billing information. Think of it like Stripe’s customer portal: you generate a short-lived URL on the backend, hand it to your customer, and they click through to a MarginFront page that shows their invoices, usage, subscription status, etc. You never share your API key with your customers. Instead, the portal session is the safe, scoped way to show them their data without giving them keys to the kingdom.Heads up: Portal sessions are a newer feature and the exact UI that customers land on is still evolving. The API shape described here is current, but the rendered portal experience will keep improving. If you’re building a customer-facing integration, check in with the team about what’s live before committing to the UX.
How portal sessions work, in 30 seconds
- Your customer clicks “View billing” inside your app
- Your backend calls
POST /v1/portal-sessionswith the customer’s external ID - MarginFront returns a short-lived URL
- Your backend redirects the customer to that URL (or embeds it in an iframe)
- The customer lands on a MarginFront page showing their billing info
- The session expires after a configurable time window (usually 15-60 minutes)
- If they try to use the URL after expiry, they’re bounced out
The endpoints
Create a portal session
Method & URL:customerExternalId(string) — Which of your customers this portal session is for. Scoped data — they’ll only see their own invoices, usage, etc.returnUrl(string) — Where to send the customer after they close the portal. Usually back to your app.
apps/api-nest/src/modules/sdk/dto/ for the current full list.
What you get back (201 Created):
404 Not Found— ThecustomerExternalIddoesn’t match any customer in your org.400 Bad Request— Missing required field.
List portal sessions
Method & URL:Read one portal session
Method & URL:Delete (revoke) a portal session
Method & URL:Using the Node SDK
Security notes
- Portal session URLs are one-time-ish: they work for as long as the session is valid, but each URL is tied to exactly one customer. Don’t share them across customers.
- Sessions expire automatically. You don’t need to clean them up yourself.
- Never return your API key from your own backend to the customer’s browser. The whole point of portal sessions is you generate them on the server, the customer only ever sees the portal URL.
- If you’re embedding the portal in an iframe, check with the team first — iframe embedding may require additional CORS or CSP configuration.

