User

Get current user profile from OAuth token

Overview

The User API lets OAuth apps retrieve and manage the current user's profile information using their access token.

Authentication: OAuth token only (API keys not supported)
Required Scopes: user:read, user:write

Important: Personal Team Context

Every user has a personal team that represents their individual account:

  • Billing - All credits and spending are tied to the user's personal team
  • Developer Profile - Published under the user's personal team (for apps in marketplace)
  • Default Context - Used when no specific team is selected

When you get a user with /api/user/me, the slug field is their personal team slug. Use this for building URLs like /settings/{slug}.


Get Current User

Get the authenticated user's profile.

Endpoint: GET /api/user/me

const response = await fetch('https://hypery.ai/api/user/me', {
  headers: {
    'Authorization': `Bearer ${oauthAccessToken}`
  }
})
 
const user = await response.json()
console.log(user.email)

Response:

{
  "id": "507f1f77bcf86cd799439011",
  "email": "user@example.com",
  "name": "John Doe",
  "image": "https://...avatar.jpg",
  "slug": "johndoe"
}

Output Fields

FieldTypeDescription
idstringUser ID
emailstringUser's email address
namestringUser's display name
imagestring | nullAvatar URL
slugstringUser's URL slug for settings

Update Profile

Modify user profile information.

Endpoint: PUT /api/user/profile

const response = await fetch('https://hypery.ai/api/user/profile', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${oauthToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'John Doe',
    bio: 'Software engineer',
    username: 'johndoe'
  })
})
 
const result = await response.json()

Input Parameters

ParameterTypeRequiredDescription
namestringNoDisplay name
emailstringNoEmail address (must be unique)
biostringNoUser biography
usernamestringNoUsername (URL slug)

Update Preferences

Modify user preferences.

Endpoint: PUT /api/user/preferences

await fetch('https://hypery.ai/api/user/preferences', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${oauthToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    theme: 'dark',
    notifications: true
  })
})

Input Parameters

ParameterTypeDescription
themestringlight or dark
notificationsbooleanEnable notifications
languagestringLanguage code (e.g., en)
timezonestringIANA timezone

Upload Avatar

Update user avatar image.

Endpoint: POST /api/user/avatar

const formData = new FormData()
formData.append('image', fileInput.files[0])  // Note: field name is 'image'
 
const response = await fetch('https://hypery.ai/api/user/avatar', {
  method: 'POST',
  headers: { 'Authorization': `Bearer ${oauthToken}` },
  body: formData
})
 
const { imageUrl } = await response.json()
console.log('Avatar URL:', imageUrl)

Image Requirements:

  • Max size: 5 MB
  • Formats: JPG, PNG, WebP, GIF
  • Recommended: 512x512px square

Get Connected Accounts

List linked OAuth providers (GitHub, Google).

Endpoint: GET /api/user/connected-accounts

const response = await fetch('https://hypery.ai/api/user/connected-accounts', {
  headers: { 'Authorization': `Bearer ${oauthToken}` }
})
 
const { accounts } = await response.json()

Set Password

Set or update password.

Endpoint: POST /api/user/set-password

await fetch('https://hypery.ai/api/user/set-password', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${oauthToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    currentPassword: 'old123',
    newPassword: 'new456'
  })
})

Error Responses

Unauthorized

{
  "success": false,
  "error": "Missing or invalid Authorization header"
}

Status Code: 401

Token Expired

{
  "success": false,
  "error": "Invalid or expired access token"
}

Status Code: 401


Next Steps