Retrieve the current authenticated user’s active subscription for the project. Use this to display subscription status in your application.
Authentication
This endpoint requires end user authentication via HTTP Bearer Token with project scope.
Query Parameters
Use test mode data. Set to false for production subscriptions.
Response
Returns the subscription object if active, or null if no subscription exists.
Internal subscription record ID
Project the subscription belongs to
User who owns the subscription
Whether this is a test mode subscription
Stripe subscription ID (e.g., sub_ABC123)
Subscription status: active, trialing, past_due, canceled, incomplete
Name of the subscribed plan
Number of subscription seats/units
Start of current billing period
End of current billing period (renewal date)
Scheduled cancellation date (if set)
When cancellation was requested
When subscription was created
Example Request
curl -X GET "https://api.devkit4ai.com/api/v1/payments/stripe/my-subscription?test_mode=true" \
-H "Authorization: Bearer {end_user_jwt}"
Example Response
Active Subscription
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"project_id": "660e8400-e29b-41d4-a716-446655440000",
"user_id": "770e8400-e29b-41d4-a716-446655440000",
"is_test_mode": true,
"subscription_id": "sub_1ABC123def456",
"customer_id": "cus_XYZ789",
"status": "active",
"plan_name": "Pro Plan",
"quantity": 1,
"current_period_start": "2026-01-01T00:00:00Z",
"current_period_end": "2026-02-01T00:00:00Z",
"cancel_at": null,
"cancelled_at": null,
"created_at": "2025-12-15T10:30:00Z"
}
No Subscription
Subscription Status Flow
Integration Example
// React hook for subscription status
import { useQuery } from '@tanstack/react-query';
export function useSubscription() {
return useQuery({
queryKey: ['subscription'],
queryFn: async () => {
const response = await fetch('/api/subscription');
if (!response.ok) throw new Error('Failed to fetch subscription');
return response.json();
}
});
}
// Usage in component
function SubscriptionBadge() {
const { data: subscription, isLoading } = useSubscription();
if (isLoading) return <Spinner />;
if (!subscription) return <Badge>Free</Badge>;
return <Badge variant={subscription.status}>{subscription.plan_name}</Badge>;
}
Common Use Cases
| Use Case | Implementation |
|---|
| Show upgrade button | Check if subscription is null |
| Display plan name | Use subscription.plan_name |
| Show renewal date | Format current_period_end |
| Warn about cancellation | Check if cancel_at is set |
| Handle payment issues | Check for past_due status |
Error Responses
| Status | Description |
|---|
401 | Unauthorized - Invalid or missing authentication |
404 | Project not found or Stripe not configured |
Related Pages
Create Checkout
Start a new subscription
Cancel Subscription
Cancel user’s subscription
Update Subscription
Change subscription plan
Customer Portal
Let user manage billing
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
StripeSubscriptionResponse · object | null
Stripe subscription details.
created_at
string<date-time>
required