Skip to main content
Create a Stripe Customer Portal session where users can manage their subscription, including cancellation, updating payment methods, and viewing invoices.
This endpoint doesn’t directly cancel the subscription. Instead, it creates a portal session URL where users can manage their subscription themselves through Stripe’s hosted portal.

Authentication

Requires a valid JWT token in the Authorization header.
Authorization: Bearer YOUR_JWT_TOKEN

Response

url
string
The URL to redirect the user to access the Stripe Customer Portal. This URL is valid for a limited time.
message
string
Success message.

Portal Features

The Customer Portal allows users to:
  • Cancel their subscription
  • Update payment methods
  • View billing history and invoices
  • Change subscription plans
  • Update billing information

Example Request

cURL
curl -X POST https://api.tresacontafy.com/api/subscription/create-portal-session \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json"

Example Response

{
  "url": "https://billing.stripe.com/p/session/test_abc123",
  "message": "Sesión del portal creada exitosamente"
}

Usage Flow

  1. Call this endpoint to get the portal URL
  2. Redirect the user to the returned URL
  3. User manages their subscription in the Stripe portal
  4. After completion, user is redirected back to your app
  5. Webhook updates are automatically processed

Error Responses

401
error
Unauthorized - Invalid or missing JWT token.
400
error
Bad request - No active subscription found. Only users with paid subscriptions can access the portal.Error message: “No hay suscripción activa” - User must have an active subscription to access the portal.
500
error
Internal server error or Stripe API error.
Users on the FREE plan cannot access the Customer Portal since they don’t have a Stripe subscription. They need to upgrade to a paid plan first.

Build docs developers (and LLMs) love