GET /api/team
Retrieves the team data for the currently authenticated user, including team members, subscription status, and billing information.
Authentication
This endpoint requires a valid session cookie. The user must be authenticated and a member of a team.
Request
No request body or query parameters required.
curl -X GET https://your-domain.com/api/team \
-H "Cookie: session=your-session-token"
const response = await fetch('/api/team', {
method: 'GET',
credentials: 'include'
});
const team = await response.json();
Response
Returns the team object with nested team members data, or null if the user is not authenticated or not part of a team.
The unique identifier for the team
ISO 8601 timestamp of when the team was created
ISO 8601 timestamp of when the team was last updated
Stripe customer ID for billing
Stripe subscription ID for the active subscription
Stripe product ID for the subscribed plan
Human-readable name of the subscription plan
Current status of the subscription (e.g., “active”, “canceled”, “past_due”)
Array of team member objects with user details
The unique identifier for the team member record
The user ID of the team member
The team ID this member belongs to
The role of the team member (e.g., “owner”, “member”, “admin”)
ISO 8601 timestamp of when the member joined the team
User details for the team member
The user’s unique identifier
Response Examples
{
"id": 1,
"name": "Acme Corporation",
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-03-01T14:20:00.000Z",
"stripeCustomerId": "cus_ABC123XYZ",
"stripeSubscriptionId": "sub_DEF456UVW",
"stripeProductId": "prod_GHI789RST",
"planName": "Pro",
"subscriptionStatus": "active",
"teamMembers": [
{
"id": 1,
"userId": 5,
"teamId": 1,
"role": "owner",
"joinedAt": "2024-01-15T10:30:00.000Z",
"user": {
"id": 5,
"name": "John Doe",
"email": "[email protected]"
}
},
{
"id": 2,
"userId": 7,
"teamId": 1,
"role": "member",
"joinedAt": "2024-02-10T09:15:00.000Z",
"user": {
"id": 7,
"name": "Jane Smith",
"email": "[email protected]"
}
}
]
}
Error Handling
The endpoint returns null in the following cases:
- User is not authenticated (no valid session cookie)
- User session has expired
- User is not a member of any team
No explicit error responses are returned; authentication failures result in a null response.