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": [
{}
]
}Retrieve all clients for the authenticated user
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": [
{}
]
}curl -X GET https://your-domain.com/api/clients \
-H "Cookie: next-auth.session-token=..."
const response = await fetch('/api/clients');
const clients = await response.json();
[
{
"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": []
}
]
{
"error": "Unauthorized"
}
{
"error": "Failed to fetch clients"
}
reports array[] is returned if user has no clients