curl --request PUT \
--url https://api.example.com/api/clients/:id \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"domain": "<string>",
"contactName": "<string>",
"contactEmail": "<string>"
}
'{
"id": "<string>",
"name": "<string>",
"domain": "<string>",
"contactName": "<string>",
"contactEmail": "<string>",
"userId": "<string>",
"googleSearchConsoleConnected": true,
"googleAnalyticsConnected": true,
"createdAt": "<string>",
"updatedAt": "<string>",
"reports": [
{}
],
"error": "<string>",
"details": [
{}
]
}Update an existing client’s information
curl --request PUT \
--url https://api.example.com/api/clients/:id \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"domain": "<string>",
"contactName": "<string>",
"contactEmail": "<string>"
}
'{
"id": "<string>",
"name": "<string>",
"domain": "<string>",
"contactName": "<string>",
"contactEmail": "<string>",
"userId": "<string>",
"googleSearchConsoleConnected": true,
"googleAnalyticsConnected": true,
"createdAt": "<string>",
"updatedAt": "<string>",
"reports": [
{}
],
"error": "<string>",
"details": [
{}
]
}curl -X PUT https://your-domain.com/api/clients/clx1a2b3c4d5e6f7g8h9i0j1k \
-H "Content-Type: application/json" \
-H "Cookie: next-auth.session-token=..." \
-d '{
"name": "Acme Corp (Updated)",
"contactEmail": "[email protected]"
}'
const response = await fetch('/api/clients/clx1a2b3c4d5e6f7g8h9i0j1k', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Acme Corp (Updated)',
contactEmail: '[email protected]'
})
});
const updatedClient = await response.json();
{
"id": "clx1a2b3c4d5e6f7g8h9i0j1k",
"name": "Acme Corp (Updated)",
"domain": "https://acme.com",
"contactName": "John Doe",
"contactEmail": "[email protected]",
"userId": "clx0a1b2c3d4e5f6g7h8i9j0k",
"googleSearchConsoleConnected": true,
"googleAnalyticsConnected": true,
"searchConsolePropertyUrl": "https://acme.com",
"googleAnalyticsPropertyId": "123456789",
"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-21T16:45:00.000Z",
"reports": [
{
"id": "clx9z8y7x6w5v4u3t2s1r0q",
"title": "March 2024 Report",
"status": "COMPLETED",
"pdfUrl": "https://blob.vercel-storage.com/...",
"createdAt": "2024-03-20T14:30:00.000Z"
}
]
}
{
"error": "Validation error",
"details": [
{
"code": "invalid_string",
"validation": "email",
"message": "Must be a valid email",
"path": ["contactEmail"]
}
]
}
{
"error": "Client not found or unauthorized"
}
{
"error": "Unauthorized"
}
updatedAt timestamp is automatically updated on each change