Skip to main content
GET
/
api
/
clients
List Clients
curl --request GET \
  --url https://api.example.com/api/clients
{
  "id": "<string>",
  "name": "<string>",
  "domain": "<string>",
  "contactName": "<string>",
  "contactEmail": "<string>",
  "googleSearchConsoleConnected": true,
  "googleAnalyticsConnected": true,
  "searchConsolePropertyUrl": "<string>",
  "googleAnalyticsPropertyId": "<string>",
  "ga4PropertyId": "<string>",
  "ga4PropertyName": "<string>",
  "gscSiteUrl": "<string>",
  "gscSiteName": "<string>",
  "lastReportGenerated": "<string>",
  "totalReportsGenerated": 123,
  "googleConnectedAt": "<string>",
  "createdAt": "<string>",
  "updatedAt": "<string>",
  "reports": [
    {}
  ]
}

Authentication

Requires authenticated user session.

Response

Returns an array of client objects, ordered by creation date (newest first).
id
string
Unique client identifier
name
string
Client name
domain
string
Client website URL
contactName
string
Contact person name
contactEmail
string
Contact email address
googleSearchConsoleConnected
boolean
Whether Google Search Console is connected
googleAnalyticsConnected
boolean
Whether Google Analytics is connected
searchConsolePropertyUrl
string
Selected Search Console property URL
googleAnalyticsPropertyId
string
Selected Google Analytics 4 property ID
ga4PropertyId
string
GA4 property ID (alternative field)
ga4PropertyName
string
GA4 property display name
gscSiteUrl
string
Search Console site URL
gscSiteName
string
Search Console site display name
lastReportGenerated
string
ISO 8601 timestamp of last report generation
totalReportsGenerated
number
Total number of reports generated for this client
googleConnectedAt
string
ISO 8601 timestamp when Google was connected
createdAt
string
ISO 8601 timestamp when client was created
updatedAt
string
ISO 8601 timestamp when client was last updated
reports
array
Array containing the most recent report (includes full report object)

Example Request

cURL
curl -X GET https://your-domain.com/api/clients \
  -H "Cookie: next-auth.session-token=..."
JavaScript
const response = await fetch('/api/clients');
const clients = await response.json();

Example Response

200 Success
[
  {
    "id": "clx1a2b3c4d5e6f7g8h9i0j1k",
    "name": "Acme Corporation",
    "domain": "https://acme.com",
    "contactName": "John Doe",
    "contactEmail": "[email protected]",
    "googleSearchConsoleConnected": true,
    "googleAnalyticsConnected": true,
    "searchConsolePropertyUrl": null,
    "googleAnalyticsPropertyId": null,
    "gscSiteUrl": "https://acme.com",
    "gscSiteName": "Acme Corporation",
    "ga4PropertyId": "123456789",
    "ga4PropertyName": "Acme GA4 Property",
    "googleConnectedAt": "2024-03-15T11:00:00.000Z",
    "lastReportGenerated": "2024-03-20T14:30:00.000Z",
    "totalReportsGenerated": 5,
    "createdAt": "2024-03-15T10:30:00.000Z",
    "updatedAt": "2024-03-20T14:30:00.000Z",
    "userId": "clx0a1b2c3d4e5f6g7h8i9j0k",
    "reports": [
      {
        "id": "clx9z8y7x6w5v4u3t2s1r0q",
        "title": "March 2024 Report",
        "status": "COMPLETED",
        "pdfUrl": "https://blob.vercel-storage.com/...",
        "createdAt": "2024-03-20T14:30:00.000Z"
      }
    ]
  },
  {
    "id": "clx2b3c4d5e6f7g8h9i0j1k2l",
    "name": "Beta Industries",
    "domain": "https://betaindustries.com",
    "contactName": "Jane Smith",
    "contactEmail": "[email protected]",
    "googleSearchConsoleConnected": false,
    "googleAnalyticsConnected": false,
    "searchConsolePropertyUrl": null,
    "googleAnalyticsPropertyId": null,
    "gscSiteUrl": null,
    "gscSiteName": null,
    "ga4PropertyId": null,
    "ga4PropertyName": null,
    "googleConnectedAt": null,
    "lastReportGenerated": null,
    "totalReportsGenerated": 0,
    "createdAt": "2024-03-14T09:15:00.000Z",
    "updatedAt": "2024-03-14T09:15:00.000Z",
    "userId": "clx0a1b2c3d4e5f6g7h8i9j0k",
    "reports": []
  }
]
401 Unauthorized
{
  "error": "Unauthorized"
}
500 Server Error
{
  "error": "Failed to fetch clients"
}

Notes

  • Clients are automatically filtered to only include those owned by the authenticated user
  • Results are ordered by creation date in descending order (newest first)
  • Each client includes their most recent report (if any) via the reports array
  • Empty array [] is returned if user has no clients

Build docs developers (and LLMs) love