POST /customer-portal
/api/store/[slug]/customer-portalCreates a Stripe Customer Portal session URL for the signed-in storefront customer, who must have at least one active, trialing, or past_due subscription.
Path parameters
slugstringrequiredBusiness store slug (non-empty string); 404 if no business matches.
Body parameters
return_urlstringrequiredAbsolute URL Stripe redirects to when the customer leaves the portal (validated as URL).
Responses
The request succeeded.
A field failed validation. The response names the fields that failed, not just the first.
The key or customer token is missing, malformed, or no longer valid.
The credential is valid but is not allowed to do this.
No such store, or no such record inside it.
Too many requests. Back off and retry after the window in the response.
Something failed on our side. The response carries no detail; retry is safe on a GET.
What comes back
200: { portal_url } (Stripe-hosted portal session URL). Errors: { error } with 400 (validation, business has no Stripe account, customer has no active subscriptions, or customer missing Stripe ID), 401 (missing/invalid token), 403 (token belongs to another business), 404 (business not found, or no billing customer matches the session email for this business), 429 (rate limited), 500. return_url is sanitized beyond z.string().url(): a non-http(s) value is rejected 400 with { error: 'Invalid input', details: [{ path: ['return_url'], message: 'Must be an http or https URL' }] }. The 429 body is { error, retryAfter } and carries a Retry-After header.