Skip to main content
These endpoints allow authenticated users to retrieve their profile information and update specific fields.

Get user data

Retrieve the authenticated user’s profile data with optional field filtering.

Endpoint

GET /api/user

Query parameters

fields
string
Comma-separated list of fields to retrieve. If omitted, all fields are returned.Allowed values: id, email, username, resume, created_at, isliveExample: fields=username,resume,islive

Response

Returns a user object with requested fields. The exact structure depends on which fields are requested.
id
string
User’s database ID
email
string
User’s email address
username
string
User’s unique username
resume
object or null
User’s resume data in structured format. See the Resume type for the complete schema.
created_at
string
Account creation timestamp in ISO 8601 format
islive
boolean
Whether the user’s resume is published and publicly visible

Example

curl https://wrkks.vercel.app/api/user?fields=username,islive \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

{
  "username": "johndoe",
  "islive": true
}

Error responses

404 Not Found

Returned when the user is not found or not authenticated:
{
  "msg": "User not found or unauthorized"
}

Update user data

Update one or more fields in the authenticated user’s profile.

Endpoint

POST /api/user/update

Request body

Send a JSON object with the fields to update. Only include fields you want to change.
email
string
New email address
username
string
New username. Must be unique across all users.
resume
object
Updated resume data structure
islive
boolean
Whether the resume should be publicly visible
style
string
Website style preference. Must be either "simple" or "bento".

Response

Returns the updated user object with all fields:
{
  "id": "usr_123",
  "clerk_user_id": "user_abc",
  "email": "[email protected]",
  "username": "newusername",
  "resume": { /* resume object */ },
  "islive": true,
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-02-20T14:25:00Z"
}

Example

curl -X POST https://wrkks.vercel.app/api/user/update \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "username": "newusername",
    "islive": true
  }'

Error responses

400 Bad Request

Returned when no fields are provided:
{
  "msg": "No fields provided to update"
}

401 Unauthorized

Returned when the user is not authenticated:
{
  "msg": "Unauthorized"
}

409 Conflict

Returned when trying to use a username that’s already taken:
{
  "msg": "Username is already taken"
}
Or when a race condition occurs:
{
  "msg": "This username is no longer available"
}

500 Internal Server Error

Returned when the database update fails:
{
  "msg": "Failed to update user data"
}
Or when username verification fails:
{
  "msg": "Could not verify username availability"
}
Or for unexpected errors:
{
  "error": "Internal server error"
}

Implementation details

Username uniqueness

The update endpoint checks for username conflicts before updating:
  1. Queries the database for existing users with the requested username
  2. Allows the update if no other user has that username
  3. Returns 409 Conflict if another user already has that username
  4. Handles database-level uniqueness constraint violations (error code 23505)
Source: /app/api/user/update/route.ts:32-53

Field filtering

The GET endpoint validates requested fields against an allowed list before querying:
const allowedFields: UserField[] = [
  "id",
  "email",
  "username",
  "resume",
  "created_at",
  "islive",
];
Source: /app/api/user/route.ts:14-21

Build docs developers (and LLMs) love