Skip to main content
Glama
discover-endpoints.tsβ€’5.44 kB
#!/usr/bin/env node import dotenv from 'dotenv'; import { UmbrellaAuth } from './auth.js'; import { UmbrellaApiClient } from './api-client.js'; import { getTestCredentialSets } from './auth-helper.js'; dotenv.config(); async function discoverWorkingEndpoints() { console.log('πŸ” ENDPOINT DISCOVERY FOR MSP ACCOUNT'); console.log('===================================='); const baseURL = process.env.UMBRELLA_API_BASE_URL || 'https://api.umbrellacost.io/api/v1'; const credentialSets = getTestCredentialSets(); if (!credentialSets || credentialSets.length === 0) { console.error('❌ No test credentials available'); return; } // Use the MSP account (first credential set) const mspCreds = credentialSets[0]; console.log(`\nπŸ” Discovering endpoints for MSP Account: ${mspCreds.username}`); console.log('='.repeat(60)); const auth = new UmbrellaAuth(baseURL); const apiClient = new UmbrellaApiClient(baseURL); try { // Authenticate with MSP account console.log('πŸ” Authenticating MSP account...'); await auth.authenticate(mspCreds); apiClient.setAuthToken(auth.getAuthHeaders()); console.log('βœ… MSP authentication successful'); // Test all known working endpoints first const workingEndpoints = [ '/recommendations/report', '/recommendationsNew/views', '/anomaly-detection', '/invoices/service-names/distinct' ]; console.log('\nπŸ“‹ Testing Known Working Endpoints:'); for (const endpoint of workingEndpoints) { try { const response = await apiClient.makeRequest(endpoint); if (response.success) { console.log(` βœ… ${endpoint}`); } else { console.log(` ❌ ${endpoint}: ${response.error}`); } } catch (error: any) { console.log(` ❌ ${endpoint}: ${error.message}`); } } // Test potential customer management endpoints with variations const customerEndpointVariations = [ // Direct customer endpoints '/customers', '/customer', '/customer-management', '/customer-management/customers', '/customer/list', '/msp/customers', '/msp-customers', // User management variations '/user-management', '/user-management/customers', '/user-management/organizations', '/user-management/accounts', '/user-management/clients', // Organization endpoints '/organizations', '/organization', '/orgs', '/org', // Account management endpoints '/accounts', '/account', '/account-management', '/account-management/customers', // Partner/MSP specific endpoints '/partners', '/partner', '/partner-management', '/msp', '/msp/organizations', '/msp-management', // Billing/rebilling endpoints that might contain customer info '/billing', '/billing/customers', '/rebilling', '/rebilling/customers', // Admin endpoints '/admin', '/admin/customers', '/admin/organizations' ]; console.log('\nπŸ” Testing Customer Management Endpoint Variations:'); const workingCustomerEndpoints: string[] = []; for (const endpoint of customerEndpointVariations) { try { console.log(` Testing: ${endpoint}`); const response = await apiClient.makeRequest(endpoint); if (response.success) { console.log(` βœ… FOUND: ${endpoint}`); workingCustomerEndpoints.push(endpoint); // Show some details about the response if (response.data) { if (Array.isArray(response.data)) { console.log(` β†’ Array with ${response.data.length} items`); if (response.data.length > 0) { console.log(` β†’ Sample keys: ${Object.keys(response.data[0]).slice(0, 5).join(', ')}`); } } else if (typeof response.data === 'object') { console.log(` β†’ Object with keys: ${Object.keys(response.data).slice(0, 8).join(', ')}`); } } } else { console.log(` ❌ ${endpoint}: ${response.error}`); } } catch (error: any) { console.log(` ❌ ${endpoint}: ${error.message}`); } // Small delay to be nice to the API await new Promise(resolve => setTimeout(resolve, 100)); } console.log('\nπŸ“Š DISCOVERY RESULTS:'); console.log('==================='); if (workingCustomerEndpoints.length > 0) { console.log(`βœ… Found ${workingCustomerEndpoints.length} working customer-related endpoints:`); workingCustomerEndpoints.forEach(endpoint => { console.log(` - ${endpoint}`); }); } else { console.log('❌ No customer management endpoints found'); console.log(' This could mean:'); console.log(' - The MSP account lacks customer management permissions'); console.log(' - Customer data is accessed through different endpoints'); console.log(' - Customer management is handled via a different API version'); console.log(' - The account is not actually an MSP account'); } } catch (error: any) { console.error(`❌ Authentication failed: ${error.message}`); } } discoverWorkingEndpoints().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