> ## Documentation Index
> Fetch the complete documentation index at: https://docs.searchcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Architecture for the Get Team Members endpoint

## Purpose

Returns all team members and pending invitations for an organization. Uses caching to reduce Clerk API calls.

## Architecture

```mermaid theme={null}
flowchart TD
    Request["GET /organization/{org_id}/members"]
    
    subgraph cache [Cache Check]
        CheckCache["Check DB cache (5 min TTL)"]
    end
    
    subgraph clerk [Clerk API]
        FetchMembers["Fetch memberships"]
        FetchInvites["Fetch pending invitations"]
    end
    
    subgraph db [Database]
        SyncDB["Sync to clerk_organization_details"]
    end
    
    Request --> CheckCache
    CheckCache -->|"Cache hit"| Response
    CheckCache -->|"Cache miss"| FetchMembers
    FetchMembers --> FetchInvites
    FetchInvites --> SyncDB
    SyncDB --> Response
```

## Query Parameters

| Parameter         | Type   | Default | Description                 |
| ----------------- | ------ | ------- | --------------------------- |
| `limit`           | `int`  | 100     | Max members to return       |
| `offset`          | `int`  | 0       | Pagination offset           |
| `include_pending` | `bool` | true    | Include pending invitations |
| `force_refresh`   | `bool` | false   | Bypass cache                |

## Response Format

```json theme={null}
{
  "organization_id": "org_abc123",
  "members": [
    {
      "membership_id": "mem_...",
      "user_id": "user_...",
      "first_name": "John",
      "last_name": "Doe",
      "email": "john@acme.com",
      "image_url": "https://...",
      "role": "org:admin",
      "created_at": 1702234567
    }
  ],
  "pending_invitations": [...],
  "total_members": 5,
  "from_cache": false
}
```

## Code Location

```
src/app/apis/settings_team/members/routes.py
```
