Skip to main content
Glama
test-api-flags.cjs2.78 kB
const axios = require('axios'); async function testApiFlags() { const BASE_URL = 'https://api.dev.umbrellacost.dev/api'; const USERNAME = 'elisha+testmcpdev@anodot.com'; const PASSWORD = 'Test123!'; const ACCOUNT_KEY = '111111639'; const DIVISION_ID = '0'; try { console.log('🔐 Authenticating...\n'); const authResponse = await axios.post(`${BASE_URL}/v1/users/signin`, { username: USERNAME, password: PASSWORD }); const token = authResponse.data.jwtToken; const tokenPayload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString()); const userKey = tokenPayload.sub; console.log('✅ Authenticated\n'); const startDate = '2025-09-01'; const endDate = '2025-10-07'; const apiKey = `${userKey}:${ACCOUNT_KEY}:${DIVISION_ID}`; // Test different flag combinations to find the right one const tests = [ { name: 'isNet=true only', params: { isNet: true } }, { name: 'isNet=true + isAmortized=true', params: { isNet: true, isAmortized: true } }, { name: 'isNet=true + isUnblended=true', params: { isNet: true, isUnblended: true } }, { name: 'isAmortized=true + isNet=true (order swap)', params: { isAmortized: true, isNet: true } }, { name: 'Just check raw response structure', params: { isNetAmortized: true } } ]; for (const test of tests) { console.log('═'.repeat(80)); console.log(`TEST: ${test.name}`); console.log('═'.repeat(80)); try { const response = await axios.get(`${BASE_URL}/v2/invoices/cost-and-usage`, { params: { startDate, endDate, ...test.params, costType: ['cost', 'discount'], periodGranLevel: 'month', groupBy: 'none' }, headers: { 'Authorization': token, 'apikey': apiKey } }); const totalCost = response.data.data.reduce((sum, item) => sum + (item.total_cost || 0), 0); console.log(`Total Cost: $${totalCost.toFixed(2)}`); // Show what fields are in the response if (response.data.data.length > 0) { console.log('Available fields:', Object.keys(response.data.data[0])); } console.log(''); } catch (error) { console.log(`❌ Error: ${error.message}`); if (error.response?.data) { console.log(`Data: ${JSON.stringify(error.response.data, null, 2)}`); } console.log(''); } } } catch (error) { console.error('❌ Error:', error.message); if (error.response) { console.error('Status:', error.response.status); console.error('Data:', JSON.stringify(error.response.data, null, 2)); } } } testApiFlags();

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