Skip to main content

Portal Sessions

The SDK gives you four methods for managing customer portal links. These are the one-time URLs your customers click to see their own billing. This page covers:
  1. Creating a portal session
  2. Getting one portal session
  3. Listing portal sessions
  4. Revoking a portal session
If you’re new to portal sessions, start with the Portal Sessions API reference for a plain-English explanation of what they are and why you’d use them.

Setup

All four portal-sessions methods require a secret key (mf_sk_...). The SDK throws an AuthenticationError immediately if you initialize the client with a publishable key.

portalSessions.create

Mints a one-time portal link for a customer. The returned url is what you send to your customer.

Signature

Example

Pass either customerExternalId (your system’s ID) or customerId (MarginFront’s UUID). returnUrl is optional and informational. See the Portal Sessions API reference for the full field list and error codes.

portalSessions.get

Looks up one portal session by ID. Useful for checking whether a link has been opened or has expired.

Signature

Example

The token and url fields are NOT included in this response. Those are only returned by create. The return type is ListedPortalSession, the same shape returned by list. If you need the URL again, mint a new session with create.

portalSessions.list

Lists portal sessions your organization has created. Optionally filter to one customer.

Signature

Example

By default, expired and already-used sessions are filtered out. Set includeExpired: true to see them all.

portalSessions.revoke

Immediately invalidates a portal session. Use this if you sent a link to the wrong customer or need to cut access early.

Signature

Example

Once revoked, the link stops working immediately. This is a hard delete. The session can’t be brought back.