Skip to main content
Glama
check-all-available-data.cjsβ€’4.26 kB
#!/usr/bin/env node /** * Check what data is available across all accounts */ const axios = require('axios'); async function checkAllData() { console.log('πŸ” CHECKING ALL AVAILABLE DATA\n'); console.log('===============================\n'); try { // Step 1: Authenticate console.log('1️⃣ Authenticating...\n'); const authResponse = await axios.post('https://api.umbrellacost.io/api/v1/users/signin', { username: 'david+allcloud@umbrellacost.com', password: 'B4*zcI7#F7poEC' }); const token = authResponse.data.jwtToken; const userKey = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString()).sub; console.log('βœ… Authentication successful\n'); console.log(` User Key: ${userKey}\n`); // Step 2: Get all divisions console.log('2️⃣ Getting all customer divisions...\n'); const tempApiKey = `${userKey}:15808:0`; const divisionsResponse = await axios.get('https://api.umbrellacost.io/api/v1/users/plain-sub-users', { headers: { 'Authorization': token, 'apikey': tempApiKey } }); const customerDivisions = divisionsResponse.data.customerDivisions; console.log('πŸ“‹ All Customers and Divisions:\n'); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); for (const [customerName, divisions] of Object.entries(customerDivisions)) { console.log(`\n🏒 ${customerName}:`); if (Array.isArray(divisions)) { divisions.forEach((div, i) => { console.log(` Division ${i + 1}:`); console.log(` Account Key: ${div.accountKey}`); console.log(` Division ID: ${div.divisionId}`); console.log(` Account ID: ${div.accountId}`); }); } } console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'); // Step 3: Try to get data for the main account console.log('3️⃣ Testing main account data (without customer filter)...\n'); const mainApiKey = `${userKey}:15808:0`; const dateRanges = [ { start: '2025-01-01', end: '2025-12-31', label: 'All of 2025' }, { start: '2024-01-01', end: '2024-12-31', label: 'All of 2024' }, { start: '2023-01-01', end: '2023-12-31', label: 'All of 2023' } ]; for (const range of dateRanges) { console.log(`πŸ“… Testing ${range.label}...`); try { const response = await axios.get('https://api.umbrellacost.io/api/v1/invoices/caui', { params: { startDate: range.start, endDate: range.end, groupBy: 'none', costType: ['cost', 'discount'] }, headers: { 'Authorization': token, 'apikey': mainApiKey, 'commonParams': JSON.stringify({ isPpApplied: false }) } }); if (response.data && Array.isArray(response.data) && response.data.length > 0) { console.log(` βœ… Found ${response.data.length} records!`); // Get unique accounts const accounts = new Set(); response.data.forEach(row => { if (row.linkedaccid) accounts.add(row.linkedaccid); if (row.accountId) accounts.add(row.accountId); }); console.log(` πŸ“Š Unique accounts: ${accounts.size}`); if (accounts.size > 0) { console.log(` Accounts: ${Array.from(accounts).slice(0, 5).join(', ')}${accounts.size > 5 ? '...' : ''}`); } // Calculate total const total = response.data.reduce((sum, row) => sum + parseFloat(row.cost || 0), 0); console.log(` πŸ’° Total: $${total.toFixed(2)}\n`); } else { console.log(` ⚠️ No data found\n`); } } catch (error) { console.log(` ❌ Error: ${error.response?.status} - ${error.response?.statusText || error.message}\n`); } } } catch (error) { console.error('❌ Error:', error.response?.data || error.message); } } // Run the check checkAllData().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daviddraiumbrella/invoice-monitoring'

If you have feedback or need assistance with the MCP directory API, please join our Discord server