Skip to main content
PUT
Update User

Update User

Update an existing user account with new information.

Endpoint

Description

This endpoint allows administrators to update an existing user account. You can modify user details such as name, email, role, license tier, and other account settings.

Authentication

Required: API Key with admin privileges

Path Parameters

Request Body

Example Request

Success Response

Status Code: 200 OK

Response Fields

Example Usage

JavaScript

Python

cURL

Error Responses

400 Bad Request

401 Unauthorized

403 Forbidden

404 Not Found

409 Conflict

Validations and Business Rules

  • License value: Must be in allowed licenses (Essential, Growth, Ultra, Early Access). Invalid values return 400.
  • License capacity: Enforced via checkLicenseCapacity; returns 400 when the selected tier is full.
  • License downgrade guard: If changing to a lower tier reduces personal index quota, the change is blocked when current personal index count exceeds INDEX_QUOTAS[new_license]; returns 400 with explicit guidance.
  • Email normalization: Lowercased and trimmed before validation and storage.
  • Username normalization: Lowercased and trimmed before validation and storage.
  • Email format: Simple regex validation; invalid emails return 400.
  • Username format: Must match ^[a-z0-9.-]{3,30}$; invalid usernames return 400.
  • Uniqueness: email, username, and name must remain unique; conflicts return 409.

Normalization and Storage

  • email and username are always stored lowercased and trimmed.

Typical Error Shapes

400 Invalid License

400 License Unavailable

400 License Downgrade Exceeds Quota

400 Invalid Email

400 Invalid Username

409 Conflict (Uniqueness)

User Roles

License Tiers

Account Status

Use Cases

  • Role Management: Updating user roles for access control
  • License Upgrades: Changing user license tiers
  • Account Maintenance: Updating user information and metadata
  • Status Management: Activating or suspending user accounts
  • Profile Updates: Modifying user names, emails, or other details

Rate Limits

  • Default: 100 requests per minute
  • Daily: 10,000 requests per day
  • Monthly: 300,000 requests per month

Notes

  • Only administrators can update user accounts
  • Email addresses must be unique across all users
  • Password updates are optional and will only be applied if provided
  • Metadata updates are merged with existing metadata
  • The updatedAt timestamp is automatically updated on successful operations

Authorizations

Authorization
string
header
required

API key authentication using Bearer token format. Example: Authorization: Bearer sk-your-api-key-here

Path Parameters

userId
string
required

User ID to update

Body

application/json
name
string

User's full name

Example:

"John Doe Updated"

username
string

Unique username

Example:

"johndoe_updated"

email
string<email>

User's email address

Example:

"john.updated@example.com"

password
string

User's new password (optional)

Example:

"newsecurepassword123"

role
enum<string>

User's role

Available options:
admin,
user,
globalReader
Example:

"user"

license
enum<string>

User's license tier

Available options:
Essential,
Growth,
Ultra,
Early Access
Example:

"Growth"

status
enum<integer>

User status (0=inactive, 1=active)

Available options:
0,
1
Example:

1

roleId
string

Custom role ID (MongoDB ObjectId)

Example:

"60a7c8f5e8b4f5001f7a8c24"

setupCompleted
boolean

Whether user setup is completed

Example:

true

isVerified
boolean

Whether user is verified

Example:

true

Response

User updated successfully

success
boolean
Example:

true

message
string
Example:

"User updated successfully"

user
object