GET /api/me
Retrieve current user information and application configuration.
Overview
The /api/me endpoint returns detailed information about the currently authenticated user, including:
- User profile information (ID, name, email, roles)
- Application configuration settings
- Pusher/WebSocket connection details
- Accounting and business settings
- Staff list, task types, and activity types
- Currency and regional settings
Authentication Required: This endpoint requires a valid access token obtained from
/api/login-token.
Endpoint Details
| URL | /api/me |
|---|---|
| Method | GET |
| Authentication | Required (access token) |
| Content-Type | application/json |
Request
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
access_token |
string | Yes | Your API access token obtained from /api/login-token |
Example Request
curl -X GET "https://backoffice.ddev.site/api/me?access_token=YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json"
JavaScript Example
const API_BASE_URL = 'https://backoffice.ddev.site';
const ACCESS_TOKEN = localStorage.getItem('access_token');
fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => response.json())
.then(data => {
console.log('User info:', data.data[0]);
console.log('Config:', data.data[0].config);
})
.catch(error => {
console.error('Error fetching user data:', error);
});
Response
Response Structure
The response contains a data array with a single user object containing profile and configuration information.
Key Response Fields
| Field Path | Type | Description |
|---|---|---|
| data[0].id | string | User ID |
| data[0].label | string | Username/label |
| data[0].mail | string | User email address |
| data[0].roles | array | User roles (e.g., "administrator", "clerk") |
| data[0].full_name | string | Full name of the user |
| data[0].sale_context | string | Current sale context ID |
| data[0].config | object | Configuration object (see below) |
Configuration Object Fields
| Field Path | Type | Description |
|---|---|---|
| config.pusherConfig | object | Pusher Configuration - Contains key, cluster, and privateChannel for Pusher |
| config.pusherConfig.key | string | Pusher App Key - Your Pusher application key |
| config.pusherConfig.cluster | string | Pusher Cluster - Pusher cluster region (e.g., "eu", "us2") |
| config.pusherConfig.privateChannel | string | Private Channel Name - The private channel to subscribe to |
| config.bidServer | string | WebSocket server URL for real-time events |
| config.bidServerAccessToken | string | Bid server access token (for bidding operations, not used for Pusher) |
| config.websiteBasePath | string | Base URL for the website/backoffice |
| config.accountingCountry | string | Accounting country code (e.g., "DE", "US") |
| config.staff | array | List of staff members with ID, name, email, UUID |
| config.task_types | array | Available task types for the system |
| config.activity_types | array | Available activity types for tracking |
| config.currency | object | Currency settings (symbol, format, decimal places) |
| config.contentLanguages | object | Available content languages |
| config.itemPageSettings | object | Item page configuration and display settings |
Example Response (Abbreviated)
{
"data": [{
"id": "1",
"label": "admin",
"mail": "admin@circuitauction.com",
"roles": [
"authenticated user",
"administrator",
"clerk"
],
"picture": null,
"full_name": "Administrator",
"sale_context": "309",
"config": {
"bidServer": "https://circuit-bid.ddev.site:4443",
"bidServerAccessToken": "7wESvKVQW5EljtvylmW2eNlS8nrVgdJt0uRXQAoNya4",
"websiteBasePath": "https://backoffice.ddev.site",
"accountingCountry": "DE",
"pusherConfig": {
"key": "e589860bfd6885f493bf",
"cluster": "eu",
"privateChannel": "private-general@backoffice-hk-eu-local"
},
"currency": {
"key": "eur",
"symbol": "€",
"template": "@amount @symbol",
"decimal_sign": ",",
"decimal_amount": 2,
"thousands_sign": "."
},
"contentLanguages": {
"en": "en",
"de": "de"
},
"staff": [
{
"id": "30",
"label": "John Doe",
"mail": "john@example.com",
"value": "30",
"uuid": "efed71c0-fba6-42e2-bd3d-8287638df2b1"
}
],
"task_types": [
{
"id": 3922,
"label": "Call customer",
"weight": "0",
"value": "3922"
}
],
"activity_types": [
{
"id": 90,
"label": "Sent to buyer",
"weight": "0"
}
]
}
}]
}
Common Use Cases
1. Get Pusher Configuration
Extract WebSocket/Pusher settings for real-time event subscriptions:
const ACCESS_TOKEN = localStorage.getItem('access_token'); // From /api/login-token
fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => response.json())
.then(data => {
const config = data.data[0].config;
const pusherKey = config.pusherConfig.key;
const pusherCluster = config.pusherConfig.cluster;
const privateChannel = config.pusherConfig.privateChannel;
// Use these for Pusher initialization
console.log('Pusher Key:', pusherKey);
console.log('Pusher Cluster:', pusherCluster);
console.log('Private Channel:', privateChannel);
// Note: Use ACCESS_TOKEN (from /api/login-token) for Pusher auth
});
2. Display User Profile
fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => response.json())
.then(data => {
const user = data.data[0];
console.log('User:', user.full_name);
console.log('Email:', user.mail);
console.log('Roles:', user.roles.join(', '));
});
3. Get Currency Settings
fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => response.json())
.then(data => {
const currency = data.data[0].config.currency;
console.log('Currency:', currency.key);
console.log('Symbol:', currency.symbol);
console.log('Format:', currency.template);
// Format a price
const price = 1234.56;
const formatted = price.toFixed(currency.decimal_amount)
.replace('.', currency.decimal_sign)
.replace(/\B(?=(\d{3})+(?!\d))/g, currency.thousands_sign);
console.log('Formatted price:', `${formatted} ${currency.symbol}`);
// Output: "1.234,56 €"
});
4. Load Staff List for Dropdowns
fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => response.json())
.then(data => {
const staff = data.data[0].config.staff;
// Populate a select dropdown
const select = document.getElementById('staffSelect');
staff.forEach(member => {
const option = document.createElement('option');
option.value = member.id;
option.textContent = member.label;
select.appendChild(option);
});
});
5. Check User Roles
fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => response.json())
.then(data => {
const roles = data.data[0].roles;
// Check if user is administrator
const isAdmin = roles.includes('administrator');
console.log('Is administrator:', isAdmin);
// Show/hide admin features
if (isAdmin) {
document.getElementById('adminPanel').style.display = 'block';
}
});
Integration with Pusher Events
The /api/me endpoint provides the necessary configuration to connect to Pusher for real-time events.
Complete Example: Initialize Pusher with /api/me
const API_BASE_URL = 'https://backoffice.ddev.site';
const ACCESS_TOKEN = localStorage.getItem('access_token'); // From /api/login-token
// Step 1: Get configuration from /api/me
fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => response.json())
.then(data => {
const config = data.data[0].config;
// Step 2: Extract Pusher configuration from pusherConfig object
const PUSHER_KEY = config.pusherConfig.key;
const PUSHER_CLUSTER = config.pusherConfig.cluster;
const PRIVATE_CHANNEL = config.pusherConfig.privateChannel;
// Step 3: Initialize Pusher with regular access token
const pusher = new Pusher(PUSHER_KEY, {
cluster: PUSHER_CLUSTER,
encrypted: true,
forceTLS: true,
authEndpoint: `${API_BASE_URL}/api/v1.0/pusher_auth?access_token=${ACCESS_TOKEN}`
});
// Step 4: Subscribe to channel and bind events
const channel = pusher.subscribe(PRIVATE_CHANNEL);
channel.bind('entity_update', function(eventData) {
console.log('Entity updated:', eventData);
});
channel.bind('advanced_queue__post_execute', function(eventData) {
console.log('Queue task completed:', eventData);
});
})
.catch(error => {
console.error('Error initializing Pusher:', error);
});
See Also: Pusher Events Documentation for complete details on real-time event handling.
Error Responses
401 Unauthorized
Returned when the access token is invalid or expired.
{
"error": "Unauthorized",
"message": "Invalid or expired access token"
}
403 Forbidden
Returned when the user doesn't have permission to access this endpoint.
{
"error": "Forbidden",
"message": "You do not have permission to access this resource"
}
Handling Errors
fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => {
if (!response.ok) {
if (response.status === 401) {
// Token expired, redirect to login
window.location.href = '/login';
throw new Error('Unauthorized');
}
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
// Process data
console.log('User data:', data);
})
.catch(error => {
console.error('Error fetching user data:', error);
});
Best Practices
1. Cache the Response
Cache the /api/me response to avoid repeated API calls:
// Cache user data in localStorage or sessionStorage
const cacheKey = 'user_config';
const cacheExpiry = 3600000; // 1 hour in milliseconds
function getUserConfig() {
const cached = localStorage.getItem(cacheKey);
if (cached) {
const data = JSON.parse(cached);
if (Date.now() - data.timestamp < cacheExpiry) {
return Promise.resolve(data.value);
}
}
// Fetch fresh data
return fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`)
.then(response => response.json())
.then(data => {
localStorage.setItem(cacheKey, JSON.stringify({
value: data,
timestamp: Date.now()
}));
return data;
});
}
2. Load Configuration on App Startup
Fetch user configuration once when the application starts:
// In your app initialization
async function initializeApp() {
try {
const response = await fetch(`${API_BASE_URL}/api/me?access_token=${ACCESS_TOKEN}`);
const data = await response.json();
// Store globally or in state management
window.appConfig = data.data[0].config;
window.currentUser = data.data[0];
// Initialize Pusher, load UI, etc.
initializePusher(window.appConfig);
loadUserInterface(window.currentUser);
} catch (error) {
console.error('Failed to initialize app:', error);
}
}
// Call on page load
initializeApp();
3. Refresh on Token Change
Re-fetch /api/me when the user's access token changes:
// When user logs in or token refreshes
function onAccessTokenChange(newToken) {
localStorage.setItem('access_token', newToken);
// Clear cached config
localStorage.removeItem('user_config');
// Fetch fresh configuration
getUserConfig().then(data => {
console.log('Configuration refreshed');
});
}