Skip to main content
Glama
test-account-ids.ts3.52 kB
#!/usr/bin/env node import dotenv from 'dotenv'; import { UmbrellaAuth } from './auth.js'; import { UmbrellaApiClient } from './api-client.js'; dotenv.config(); async function testAccountIds() { console.log('🔍 TESTING ACCOUNT ID STRUCTURE'); console.log('=============================='); const baseURL = process.env.UMBRELLA_API_BASE_URL || 'https://api.umbrellacost.io/api/v1'; const directCustomerCreds = { username: 'elisha@umbrellacost.net', password: 'G37oi57Kp@cNzx' }; try { // Authenticate const auth = new UmbrellaAuth(baseURL); await auth.authenticate(directCustomerCreds); const apiClient = new UmbrellaApiClient(baseURL); apiClient.setAuthToken(auth.getAuthHeaders()); // Get accounts and analyze structure const accountsResponse = await apiClient.makeRequest('/user-management/accounts'); if (accountsResponse.success && accountsResponse.data) { const accounts = accountsResponse.data; console.log(`\n📊 Found ${accounts.length} accounts:\n`); accounts.forEach((account: any, index: number) => { console.log(`${index + 1}. ${account.accountName || 'Unnamed'}`); console.log(` Account ID: ${account.accountId}`); console.log(` Account Key: ${account.accountKey}`); console.log(` Cloud Type ID: ${account.cloudTypeId}`); console.log(` Is Standard Provider: ${account.isStandardProvider}`); console.log(` Is All Accounts: ${account.isAllAccounts}`); console.log(` Properties: ${Object.keys(account).join(', ')}`); console.log(''); }); // Test cost API with different account ID formats const now = new Date(); const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1); const startDate = startOfMonth.toISOString().split('T')[0]; const endDate = now.toISOString().split('T')[0]; console.log(`💰 Testing cost API with different account ID formats:`); console.log(`Date range: ${startDate} to ${endDate}\n`); // Try the first account with different ID formats const testAccount = accounts[0]; const testFormats = [ { name: 'accountId', value: testAccount.accountId }, { name: 'accountKey', value: testAccount.accountKey }, { name: 'accountName', value: testAccount.accountName }, ]; for (const format of testFormats) { console.log(`Testing with ${format.name}: "${format.value}"`); try { const costResponse = await apiClient.makeRequest('/invoices/caui', { startDate, endDate, accountId: format.value }); if (costResponse.success) { console.log(` ✅ SUCCESS with ${format.name}`); console.log(` Data type: ${typeof costResponse.data}`); if (Array.isArray(costResponse.data)) { console.log(` Items: ${costResponse.data.length}`); } } else { console.log(` ❌ FAILED with ${format.name}: ${costResponse.error}`); } } catch (error: any) { console.log(` ❌ ERROR with ${format.name}: ${error.message}`); } console.log(''); } } else { console.log(`❌ Failed to get accounts: ${accountsResponse.error}`); } } catch (error: any) { console.log(`❌ Test failed: ${error.message}`); } } testAccountIds().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