Endpoint
Authentication
Requires a valid Supabase authentication token in the request headers.Request Body
The subscription plan type. Must be one of:
PLAN_BASICO- Basic plan (1 month duration)PLAN_PRO- Pro plan (1 month duration)PLAN_PREMIUM- Premium plan (1 month duration)
The payment provider used for the transaction. Must be one of:
mercadopago- MercadoPago paymentwompi- Wompi payment
The payment reference ID from the payment provider (e.g., MercadoPago payment ID)
The amount paid in Colombian pesos (COP). Must match the plan price:
- PLAN_BASICO: 49900
- PLAN_PRO: 89900
- PLAN_PREMIUM: 149900
Response
The created subscription object
Unique subscription identifier (UUID)
User ID associated with the subscription
The subscription plan type (PLAN_BASICO, PLAN_PRO, or PLAN_PREMIUM)
Always
active for newly created subscriptionsISO 8601 timestamp when the subscription starts (current date/time)
ISO 8601 timestamp when the subscription expires (start date + 1 month)
Payment provider used (mercadopago or wompi)
Payment reference from the provider
Amount paid in COP
ISO 8601 timestamp when the subscription was created
ISO 8601 timestamp when the subscription was last updated
Example Request
Example Response
Error Responses
400 Bad Request
Returned when required fields are missing or invalid.401 Unauthorized
Returned when the user is not authenticated.409 Conflict
Returned when the user already has an active subscription.500 Internal Server Error
Returned when there’s a server error creating the subscription.Subscription Duration Logic
All subscription plans currently have a duration of 1 month. TheendDate is calculated as:
Database Updates
Creating a subscription performs the following database operations:-
Insert into
subscriptionstable:- Creates new subscription record with status
active - Records payment information
- Sets start and end dates
- Creates new subscription record with status
-
Update
profilestable:- Sets
has_active_subscription = true - Sets
current_planto the selected plan type - Sets
subscription_end_dateto the expiration date
- Sets
Row Level Security (RLS)
The subscription is created with proper RLS policies:- Users can only create subscriptions for themselves (verified via
auth.uid()) - Users can only view their own subscriptions
- Subscription data is protected and isolated per user
Usage in Payment Flow
This endpoint is typically called after payment confirmation:Subscription Plans Reference
| Plan Type | Duration | Price (COP) | Features |
|---|---|---|---|
| PLAN_BASICO | 1 month | 49,900 | 7-day meal plan, home workout routine, app access, email support |
| PLAN_PRO | 1 month | 89,900 | Personalized meal plan, gym + home routines, exercise videos, priority support, weekly tracking |
| PLAN_PREMIUM | 1 month | 149,900 | All Pro features + 1-on-1 coaching, monthly adjustments, VIP community access, results guarantee |
Related Endpoints
- Get Subscription Status - Check current subscription status