The customer portal endpoint allows authenticated users to access a billing portal where they can manage their subscription, update payment methods, view invoices, and cancel their subscription.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/revokslab/shipfree/llms.txt
Use this file to discover all available pages before exploring further.
Endpoint
Authentication
This endpoint requires authentication. The user must have an active session with a valid JWT token.Request Body
Optional URL to redirect the user after they’re done in the portal. Defaults to the dashboard.
Example Request
Response
The URL to redirect the user to the billing portal
Success Response (200)
Error Responses
401 Unauthorized
401 Unauthorized
404 Not Found
404 Not Found
Returned when no customer record exists for the authenticated user.
400 Bad Request
400 Bad Request
Returned when the customer’s payment provider doesn’t match the active provider or invalid request body.
500 Internal Server Error
500 Internal Server Error
Returned when an unexpected error occurs.
Implementation Details
The endpoint follows this workflow:- Authentication Check - Verifies the user has an active session
- Find Customer - Queries the database for the customer record using
userId - Provider Validation - Ensures the customer’s provider matches the currently active payment provider
- Create Portal Session - Calls the payment adapter’s
createPortal()method - Return URL - Returns the portal URL for client-side redirect
Source Code Reference
The implementation can be found insrc/app/api/payments/portal/route.ts:
Provider Support
All payment providers implement thecreatePortal() method:
- Stripe - Creates a Stripe Billing Portal session
- Polar - Returns the Polar dashboard URL
- Lemon Squeezy - Creates a customer portal session