Skip to main content

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
curl -X GET https://your-domain.com/api/team \
  -H "Cookie: session=your-session-token"
fetch
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.
id
number
required
The unique identifier for the team
name
string
required
The name of the team
createdAt
string
required
ISO 8601 timestamp of when the team was created
updatedAt
string
required
ISO 8601 timestamp of when the team was last updated
stripeCustomerId
string | null
Stripe customer ID for billing
stripeSubscriptionId
string | null
Stripe subscription ID for the active subscription
stripeProductId
string | null
Stripe product ID for the subscribed plan
planName
string | null
Human-readable name of the subscription plan
subscriptionStatus
string | null
Current status of the subscription (e.g., “active”, “canceled”, “past_due”)
teamMembers
array
required
Array of team member objects with user details

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.

Build docs developers (and LLMs) love