Users
The Users endpoints allow you to retrieve and manage user account information.
Get Current User
Section titled “Get Current User”Returns information about the currently authenticated user.
GET /v1/meAuthentication
Section titled “Authentication”Requires BearerAuth (session token).
Request Example
Section titled “Request Example”curl -X GET "https://api.veriglob.com/v1/me" \ -H "Authorization: Bearer your-session-token"interface UserStats { dids_created: number; credentials_issued: number; presentations_created: number; api_keys_active: number;}
interface GetUserResponse {status: string;message: string;data: {user_id: string;email: string;name?: string;tier: string;created_at: string;last_login_at: string;stats: UserStats;};}
async function getCurrentUser(sessionToken: string): Promise<GetUserResponse> {const response = await fetch('https://api.veriglob.com/v1/me', {headers: { 'Authorization': `Bearer ${sessionToken}` }});
if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}
return response.json();}
// Usageconst user = await getCurrentUser('your-session-token');console.log('Email:', user.data.email);console.log('Tier:', user.data.tier);console.log('DIDs created:', user.data.stats.dids_created);package main
import ( "encoding/json" "fmt" "net/http")
type UserStats struct { DIDsCreated int `json:"dids_created"` CredentialsIssued int `json:"credentials_issued"` PresentationsCreated int `json:"presentations_created"` APIKeysActive int `json:"api_keys_active"`}
type GetUserResponse struct { Status string `json:"status"` Message string `json:"message"` Data struct { UserID string `json:"user_id"` Email string `json:"email"` Name *string `json:"name"` Tier string `json:"tier"` CreatedAt string `json:"created_at"` LastLoginAt string `json:"last_login_at"` Stats UserStats `json:"stats"` } `json:"data"`}
func GetCurrentUser(sessionToken string) (*GetUserResponse, error) { req, _ := http.NewRequest("GET", "https://api.veriglob.com/v1/me", nil) req.Header.Set("Authorization", "Bearer "+sessionToken)
client := &http.Client{} resp, err := client.Do(req) if err != nil { return nil, err } defer resp.Body.Close()
var result GetUserResponse json.NewDecoder(resp.Body).Decode(&result) return &result, nil}
func main() { user, _ := GetCurrentUser("your-session-token") fmt.Printf("Email: %s\n", user.Data.Email) fmt.Printf("Tier: %s\n", user.Data.Tier) fmt.Printf("DIDs created: %d\n", user.Data.Stats.DIDsCreated)}import requests
def get_current_user(session_token: str) -> dict:"""Get the currently authenticated user."""response = requests.get('https://api.veriglob.com/v1/me',headers={'Authorization': f'Bearer {session_token}'})response.raise_for_status()return response.json()
# Usage
user = get_current_user('your-session-token')print(f"Email: {user['data']['email']}")print(f"Tier: {user['data']['tier']}")print(f"DIDs created: {user['data']['stats']['dids_created']}")Response
Section titled “Response”200 OK
{ "status": "success", "message": "User retrieved successfully", "data": { "user_id": "user_abc123def456", "email": "user@example.com", "name": "John Doe", "tier": "basic", "created_at": "2024-01-01T00:00:00Z", "last_login_at": "2024-01-20T14:30:00Z", "stats": { "dids_created": 5, "credentials_issued": 12, "presentations_created": 8, "api_keys_active": 2 } }}Error Responses
Section titled “Error Responses”| Status | Description |
|---|---|
| 401 | Invalid or missing session token |
Update User Profile
Section titled “Update User Profile”Updates the current user’s profile information.
PATCH /v1/meAuthentication
Section titled “Authentication”Requires BearerAuth (session token).
Request Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | User’s display name |
email | string | No | User’s email address |
Request Example
Section titled “Request Example”curl -X PATCH "https://api.veriglob.com/v1/me" \ -H "Authorization: Bearer your-session-token" \ -H "Content-Type: application/json" \ -d '{ "name": "Jane Doe" }'interface UpdateProfileRequest { name?: string; email?: string;}
interface UpdateProfileResponse {status: string;message: string;data: {user_id: string;email: string;name: string;updated_at: string;};}
async function updateProfile(sessionToken: string,updates: UpdateProfileRequest): Promise<UpdateProfileResponse> {const response = await fetch('https://api.veriglob.com/v1/me', {method: 'PATCH',headers: {'Authorization': `Bearer ${sessionToken}`,'Content-Type': 'application/json'},body: JSON.stringify(updates)});
if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}
return response.json();}
// Usageconst result = await updateProfile('your-session-token', { name: 'Jane Doe' });console.log('Updated name:', result.data.name);console.log('Updated at:', result.data.updated_at);type UpdateProfileRequest struct { Name string `json:"name,omitempty"` Email string `json:"email,omitempty"`}
type UpdateProfileResponse struct { Status string `json:"status"` Message string `json:"message"` Data struct { UserID string `json:"user_id"` Email string `json:"email"` Name string `json:"name"` UpdatedAt string `json:"updated_at"` } `json:"data"`}
func UpdateProfile(sessionToken string, updates UpdateProfileRequest) (*UpdateProfileResponse, error) { jsonData, _ := json.Marshal(updates)
req, _ := http.NewRequest("PATCH", "https://api.veriglob.com/v1/me", bytes.NewBuffer(jsonData)) req.Header.Set("Authorization", "Bearer "+sessionToken) req.Header.Set("Content-Type", "application/json")
client := &http.Client{} resp, err := client.Do(req) if err != nil { return nil, err } defer resp.Body.Close()
var result UpdateProfileResponse json.NewDecoder(resp.Body).Decode(&result) return &result, nil}from typing import Optional
def update_profile(session_token: str,name: Optional[str] = None,email: Optional[str] = None) -> dict:"""Update the current user's profile."""payload = {}if name:payload['name'] = nameif email:payload['email'] = email
response = requests.patch( 'https://api.veriglob.com/v1/me', headers={ 'Authorization': f'Bearer {session_token}', 'Content-Type': 'application/json' }, json=payload ) response.raise_for_status() return response.json()
# Usage
result = update_profile('your-session-token', name='Jane Doe')print(f"Updated name: {result['data']['name']}")print(f"Updated at: {result['data']['updated_at']}")Response
Section titled “Response”200 OK
{ "status": "success", "message": "Profile updated successfully", "data": { "user_id": "user_abc123def456", "email": "user@example.com", "name": "Jane Doe", "updated_at": "2024-01-21T10:00:00Z" }}Error Responses
Section titled “Error Responses”| Status | Description |
|---|---|
| 400 | Invalid request body |
| 401 | Invalid or missing session token |
| 409 | Email already in use |
Change Password
Section titled “Change Password”Changes the current user’s password.
POST /v1/me/passwordAuthentication
Section titled “Authentication”Requires BearerAuth (session token).
Request Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
current_password | string | Yes | Current password |
new_password | string | Yes | New password (min 8 characters) |
Request Example
Section titled “Request Example”curl -X POST "https://api.veriglob.com/v1/me/password" \ -H "Authorization: Bearer your-session-token" \ -H "Content-Type: application/json" \ -d '{ "current_password": "current-secure-password", "new_password": "new-secure-password" }'interface ChangePasswordResponse { status: string; message: string; data: { changed_at: string; };}
async function changePassword(sessionToken: string,currentPassword: string,newPassword: string): Promise<ChangePasswordResponse> {const response = await fetch('https://api.veriglob.com/v1/me/password', {method: 'POST',headers: {'Authorization': `Bearer ${sessionToken}`,'Content-Type': 'application/json'},body: JSON.stringify({current_password: currentPassword,new_password: newPassword})});
if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}
return response.json();}
// Usageconst result = await changePassword('your-session-token','current-secure-password','new-secure-password');console.log('Password changed at:', result.data.changed_at);type ChangePasswordRequest struct { CurrentPassword string `json:"current_password"` NewPassword string `json:"new_password"`}
type ChangePasswordResponse struct { Status string `json:"status"` Message string `json:"message"` Data struct { ChangedAt string `json:"changed_at"` } `json:"data"`}
func ChangePassword(sessionToken, currentPassword, newPassword string) (*ChangePasswordResponse, error) { reqBody := ChangePasswordRequest{ CurrentPassword: currentPassword, NewPassword: newPassword, } jsonData, _ := json.Marshal(reqBody)
req, _ := http.NewRequest("POST", "https://api.veriglob.com/v1/me/password", bytes.NewBuffer(jsonData)) req.Header.Set("Authorization", "Bearer "+sessionToken) req.Header.Set("Content-Type", "application/json")
client := &http.Client{} resp, err := client.Do(req) if err != nil { return nil, err } defer resp.Body.Close()
var result ChangePasswordResponse json.NewDecoder(resp.Body).Decode(&result) return &result, nil}def change_password( session_token: str, current_password: str, new_password: str) -> dict: """Change the current user's password.""" response = requests.post( 'https://api.veriglob.com/v1/me/password', headers={ 'Authorization': f'Bearer {session_token}', 'Content-Type': 'application/json' }, json={ 'current_password': current_password, 'new_password': new_password } ) response.raise_for_status() return response.json()
# Usage
result = change_password('your-session-token','current-secure-password','new-secure-password')print(f"Password changed at: {result['data']['changed_at']}")Response
Section titled “Response”200 OK
{ "status": "success", "message": "Password changed successfully", "data": { "changed_at": "2024-01-21T10:00:00Z" }}Error Responses
Section titled “Error Responses”| Status | Description |
|---|---|
| 400 | Invalid password format or requirements not met |
| 401 | Current password incorrect |
Get User Statistics
Section titled “Get User Statistics”Returns detailed usage statistics for the current user.
GET /v1/me/statsAuthentication
Section titled “Authentication”Requires BearerAuth (session token).
Request Example
Section titled “Request Example”curl -X GET "https://api.veriglob.com/v1/me/stats" \ -H "Authorization: Bearer your-session-token"interface DetailedStats { period: string; dids: { total: number; created_this_month: number; }; credentials: { total_issued: number; issued_this_month: number; total_revoked: number; total_active: number; }; presentations: { total_created: number; created_this_month: number; total_verified: number; }; api_usage: { requests_this_month: number; requests_today: number; rate_limit_hits: number; }; wallets: { total: number; credentials_stored: number; };}
interface GetStatsResponse {status: string;message: string;data: DetailedStats;}
async function getUserStats(sessionToken: string): Promise<GetStatsResponse> {const response = await fetch('https://api.veriglob.com/v1/me/stats', {headers: { 'Authorization': `Bearer ${sessionToken}` }});
if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}
return response.json();}
// Usageconst stats = await getUserStats('your-session-token');console.log('Period:', stats.data.period);console.log('Total DIDs:', stats.data.dids.total);console.log('Credentials issued this month:', stats.data.credentials.issued_this_month);console.log('API requests today:', stats.data.api_usage.requests_today);type DetailedStats struct { Period string `json:"period"` DIDs struct { Total int `json:"total"` CreatedThisMonth int `json:"created_this_month"` } `json:"dids"` Credentials struct { TotalIssued int `json:"total_issued"` IssuedThisMonth int `json:"issued_this_month"` TotalRevoked int `json:"total_revoked"` TotalActive int `json:"total_active"` } `json:"credentials"` Presentations struct { TotalCreated int `json:"total_created"` CreatedThisMonth int `json:"created_this_month"` TotalVerified int `json:"total_verified"` } `json:"presentations"` APIUsage struct { RequestsThisMonth int `json:"requests_this_month"` RequestsToday int `json:"requests_today"` RateLimitHits int `json:"rate_limit_hits"` } `json:"api_usage"` Wallets struct { Total int `json:"total"` CredentialsStored int `json:"credentials_stored"` } `json:"wallets"`}
type GetStatsResponse struct { Status string `json:"status"` Message string `json:"message"` Data DetailedStats `json:"data"`}
func GetUserStats(sessionToken string) (*GetStatsResponse, error) { req, _ := http.NewRequest("GET", "https://api.veriglob.com/v1/me/stats", nil) req.Header.Set("Authorization", "Bearer "+sessionToken)
client := &http.Client{} resp, err := client.Do(req) if err != nil { return nil, err } defer resp.Body.Close()
var result GetStatsResponse json.NewDecoder(resp.Body).Decode(&result) return &result, nil}def get_user_stats(session_token: str) -> dict: """Get detailed usage statistics for the current user.""" response = requests.get( 'https://api.veriglob.com/v1/me/stats', headers={'Authorization': f'Bearer {session_token}'} ) response.raise_for_status() return response.json()
# Usage
stats = get_user_stats('your-session-token')print(f"Period: {stats['data']['period']}")print(f"Total DIDs: {stats['data']['dids']['total']}")print(f"Credentials issued this month: {stats['data']['credentials']['issued_this_month']}")print(f"API requests today: {stats['data']['api_usage']['requests_today']}")Response
Section titled “Response”200 OK
{ "status": "success", "message": "Statistics retrieved successfully", "data": { "period": "2024-01", "dids": { "total": 5, "created_this_month": 2 }, "credentials": { "total_issued": 12, "issued_this_month": 4, "total_revoked": 1, "total_active": 11 }, "presentations": { "total_created": 8, "created_this_month": 3, "total_verified": 15 }, "api_usage": { "requests_this_month": 4521, "requests_today": 245, "rate_limit_hits": 0 }, "wallets": { "total": 2, "credentials_stored": 8 } }}