Skip to main content

Get account information

Retrieves authenticated user’s account details, subscription status, and usage statistics.
GET /api/auth/account

Authentication

Requires authentication. User must be signed in via NextAuth.

Response

user
object
User profile information
subscription
object
Subscription and plan details
usage
object
Usage statistics
features
object
Available features for current tier

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
  }
}

Update account information

Updates the authenticated user’s profile information.
PATCH /api/auth/account

Authentication

Requires authentication. User must be signed in via NextAuth.

Request body

name
string
required
New display name (1-50 characters)

Response

name
string
Updated display name

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

{
  "name": "Jane Smith"
}

Get usage statistics

Retrieves current usage statistics for authenticated or anonymous users.
GET /api/auth/usage

Authentication

This endpoint works for both authenticated and anonymous users. Anonymous users are tracked by IP address.

Response

authenticated
boolean
Whether the request is from an authenticated user
tier
string
Current tier: “anonymous”, “free”, or “pro”
limit
number
Daily analysis limit for current tier
remaining
number
Remaining analyses for today
user
object | null
User information (null for anonymous users)

Example request

cURL
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

Returned by GET /api/auth/account and PATCH /api/auth/account when user is not signed in.
{
  "error": "Not authenticated"
}
Returned when authenticated user doesn’t exist in database.
{
  "error": "User not found"
}
Returned by PATCH /api/auth/account when name validation fails.
{
  "error": "Name is required"
}
Or:
{
  "error": "Name is too long"
}
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

Build docs developers (and LLMs) love