User API
User routes manage the authenticated user's profile and usage metadata.
API call order
- Complete auth flow (
/signup,/verify,/login). - Use
access_tokeninAuthorizationheader. - Call user routes (
/users/me,/users/me/token-usage,/userspatch).
Shared request setup is documented once in API index.
Get current user profile
GET /users/me
Return the authenticated user's profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
User
|
Authenticated user injected by dependency. |
Depends(get_current_user)
|
Returns:
| Type | Description |
|---|---|
User
|
Current user. |
Usage
resp = requests.get(
f"{BASE_URL}/users/me",
headers=headers,
timeout=30,
)
resp.raise_for_status()
print(resp.json())
Explanation
Returns the authenticated user's profile document.
Notes
- Requires
Authorization: Bearer <access_token>.
Get token usage
GET /users/me/token-usage
Usage
resp = requests.get(
f"{BASE_URL}/users/me/token-usage",
headers=headers,
timeout=30,
)
resp.raise_for_status()
print(resp.json())
Explanation
Returns token budget and usage information for the current user.
Notes
- Useful for client-side quota indicators.
Update current user
PATCH /users
Update the authenticated user's profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
UpdateUserRequest
|
New user attributes to set. |
required |
user
|
User
|
Authenticated user injected by dependency. |
Depends(get_current_user)
|
Returns:
| Type | Description |
|---|---|
User
|
Updated user. |
Usage
resp = requests.patch(
f"{BASE_URL}/users",
json={"first_name": "Astro", "last_name": "User"},
headers=headers,
timeout=30,
)
resp.raise_for_status()
print(resp.json())
Explanation
Updates mutable profile fields for the authenticated user.
Notes
- Route updates only the current authenticated user.
Full API reference
For exhaustive schema details, use Swagger API.