Retrieves authenticated user’s account details, subscription status, and usage statistics.
Authentication
Requires authentication. User must be signed in via NextAuth.
Response
User profile information
ISO 8601 timestamp of account creation
List of connected OAuth providers (e.g., [“github”, “google”])
Subscription and plan details
Current tier: “free” or “pro”
Polar.sh customer ID (if subscribed)
Polar.sh subscription ID (if subscribed)
ISO 8601 timestamp when plan expires (null if no expiration)
Usage statistics
Number of analyses performed today
Daily analysis limit for current tier
Remaining analyses for today
Total analyses performed by user
Available features for current tier
Access to priority analysis queue
Access to advanced AI insights
Ability to export PDF reports
Example request
const response = await fetch('/api/auth/account', {
credentials: 'include'
});
if (response.ok) {
const data = await response.json();
console.log(data.user.name);
console.log(data.usage.remaining);
}
Example response
{
"user": {
"id": "clx1234567890",
"name": "John Doe",
"email": "[email protected]",
"image": "https://avatars.githubusercontent.com/u/123456",
"createdAt": "2024-01-15T10:30:00.000Z",
"providers": ["github"]
},
"subscription": {
"tier": "free",
"plan": "free",
"polarCustomerId": null,
"polarSubscriptionId": null,
"expiresAt": null
},
"usage": {
"todayCount": 2,
"dailyLimit": 3,
"remaining": 1,
"totalAnalyses": 15
},
"features": {
"priorityQueue": false,
"advancedInsights": false,
"exportPDF": true
}
}
Updates the authenticated user’s profile information.
Authentication
Requires authentication. User must be signed in via NextAuth.
Request body
New display name (1-50 characters)
Response
Example request
const response = await fetch('/api/auth/account', {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'Jane Smith' }),
credentials: 'include'
});
const data = await response.json();
console.log(data.name); // "Jane Smith"
Example response
Get usage statistics
Retrieves current usage statistics for authenticated or anonymous users.
Authentication
This endpoint works for both authenticated and anonymous users. Anonymous users are tracked by IP address.
Response
Whether the request is from an authenticated user
Current tier: “anonymous”, “free”, or “pro”
Daily analysis limit for current tier
Remaining analyses for today
User information (null for anonymous users)
Example request
curl https://repolyze.ossium.live/api/auth/usage
Example response (authenticated)
{
"authenticated": true,
"tier": "free",
"limit": 3,
"remaining": 1,
"user": {
"name": "John Doe",
"email": "[email protected]",
"image": "https://avatars.githubusercontent.com/u/123456"
}
}
Example response (anonymous)
{
"authenticated": false,
"tier": "anonymous",
"limit": 1,
"remaining": 0,
"user": null
}
Error responses
401 Unauthorized - Not authenticated
Returned by GET /api/auth/account and PATCH /api/auth/account when user is not signed in.{
"error": "Not authenticated"
}
404 Not Found - User not found
Returned when authenticated user doesn’t exist in database.{
"error": "User not found"
}
400 Bad Request - Invalid name
Returned by PATCH /api/auth/account when name validation fails.{
"error": "Name is required"
}
Or:{
"error": "Name is too long"
}
500 Internal Server Error - Update failed
Returned when database update fails.{
"error": "Failed to update profile."
}
Plans & Pricing
Learn about tier limits and features
Rate Limits
Understand how rate limiting works