Skip to main content
GET
/
api
/
v1
/
payments
/
stripe
/
my-subscription
Get My Subscription
curl --request GET \
  --url https://api.devkit4ai.com/api/v1/payments/stripe/my-subscription \
  --header 'Authorization: Bearer <token>'
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "is_test_mode": true,
  "subscription_id": "<string>",
  "status": "<string>",
  "quantity": 123,
  "created_at": "2023-11-07T05:31:56Z",
  "user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "customer_id": "<string>",
  "plan_name": "<string>",
  "current_period_start": "2023-11-07T05:31:56Z",
  "current_period_end": "2023-11-07T05:31:56Z",
  "cancel_at": "2023-11-07T05:31:56Z",
  "cancelled_at": "2023-11-07T05:31:56Z"
}
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

test_mode
boolean
default:"true"
Use test mode data. Set to false for production subscriptions.

Response

Returns the subscription object if active, or null if no subscription exists.
id
string (UUID)
Internal subscription record ID
project_id
string (UUID)
Project the subscription belongs to
user_id
string (UUID)
User who owns the subscription
is_test_mode
boolean
Whether this is a test mode subscription
subscription_id
string
Stripe subscription ID (e.g., sub_ABC123)
customer_id
string
Stripe customer ID
status
string
Subscription status: active, trialing, past_due, canceled, incomplete
plan_name
string
Name of the subscribed plan
quantity
integer
Number of subscription seats/units
current_period_start
datetime
Start of current billing period
current_period_end
datetime
End of current billing period (renewal date)
cancel_at
datetime
Scheduled cancellation date (if set)
cancelled_at
datetime
When cancellation was requested
created_at
datetime
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

null

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 CaseImplementation
Show upgrade buttonCheck if subscription is null
Display plan nameUse subscription.plan_name
Show renewal dateFormat current_period_end
Warn about cancellationCheck if cancel_at is set
Handle payment issuesCheck for past_due status

Error Responses

StatusDescription
401Unauthorized - Invalid or missing authentication
404Project not found or Stripe not configured

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

test_mode
boolean
default:true

Use test mode

Response

StripeSubscriptionResponse · object | null

Successful Response

Stripe subscription details.

id
string<uuid>
required
project_id
string<uuid>
required
is_test_mode
boolean
required
subscription_id
string
required
status
string
required
quantity
integer
required
created_at
string<date-time>
required
user_id
string<uuid> | null
customer_id
string | null
plan_name
string | null
current_period_start
string<date-time> | null
current_period_end
string<date-time> | null
cancel_at
string<date-time> | null
cancelled_at
string<date-time> | null