Skip to main content

Overview

Retrieve basic information about your project and its active subscriptions.

Endpoint

curl --request GET \
  "https://sms.lamah.com/api/project/details" \
  --header "Authorization: Bearer YOUR_API_TOKEN"

Response

Success Response (200 OK)

{
  "project_name": "RealEstate SMS",
  "description": "Property notifications and OTPs",
  "company": "Lamah Co",
  "status": "active",
  "type": "production",
  "subscription": [
    {
      "plan_name": "Business",
      "started_at": "2024-01-01T00:00:00Z",
      "expired_at": "2024-12-31T23:59:59Z",
      "status": "active"
    }
  ]
}

Response Fields

FieldTypeDescription
project_namestringProject name
descriptionstringProject description
companystringCompany name
statusstringProject status
typestringProject type
subscriptionarrayActive subscriptions with plan information

Subscription Array Items

FieldTypeDescription
plan_namestringPlan name for this subscription
started_atstringStart date of subscription
expired_atstringExpiration date
statusstringSubscription status

Error Responses

401 Unauthorized

{ "message": "Unauthenticated." }

403 Forbidden

{ "message": "Forbidden" }

404 Not Found

{ "message": "Not Found" }

Use Cases

Dashboard Overview

Display project statistics and usage in your dashboard

Usage Monitoring

Monitor API usage and SMS consumption

Billing Information

Check subscription status and billing details

Configuration Check

Verify project settings and limits

Implementation Examples

Dashboard Integration

class ProjectDashboard {
  constructor(apiToken) {
    this.apiToken = apiToken;
    this.baseUrl = 'https://sms.lamah.com/api';
  }

  async loadProjectDetails() {
    try {
      const response = await fetch(`${this.baseUrl}/project/details`, {
        headers: {
          'Authorization': `Bearer ${this.apiToken}`,
          'Accept': 'application/json'
        }
      });

      if (!response.ok) {
        throw new Error('Failed to load project details');
      }

      const project = await response.json();
      this.renderDashboard(project);
      return project;

    } catch (error) {
      console.error('Error loading project details:', error);
      this.showError('Failed to load project information');
    }
  }

  renderDashboard(project) {
    // Update dashboard elements
    document.getElementById('project-name').textContent = project.name;
    document.getElementById('project-status').textContent = project.status;
    
    // Usage statistics
    const monthlyUsage = project.usage.current_month;
    document.getElementById('monthly-sent').textContent = monthlyUsage.sms_sent;
    document.getElementById('monthly-delivered').textContent = monthlyUsage.sms_delivered;
    document.getElementById('monthly-cost').textContent = `$${monthlyUsage.total_cost}`;
    
    // Limits and progress
    const smsUsagePercent = (monthlyUsage.sms_sent / project.limits.monthly_sms_limit) * 100;
    document.getElementById('sms-usage-bar').style.width = `${smsUsagePercent}%`;
    document.getElementById('sms-usage-text').textContent = 
      `${monthlyUsage.sms_sent} / ${project.limits.monthly_sms_limit} SMS`;
    
    // Subscription info
    document.getElementById('plan-name').textContent = project.subscription.plan_name;
    document.getElementById('next-billing').textContent = 
      new Date(project.subscription.next_billing_date).toLocaleDateString();
  }

  showError(message) {
    document.getElementById('error-message').textContent = message;
    document.getElementById('error-banner').style.display = 'block';
  }
}

// Usage
const dashboard = new ProjectDashboard('YOUR_API_TOKEN');
dashboard.loadProjectDetails();

Usage Monitoring

const checkUsageLimits = async (apiToken) => {
  try {
    const response = await fetch('https://sms.lamah.com/api/project/details', {
      headers: {
        'Authorization': `Bearer ${apiToken}`,
        'Accept': 'application/json'
      }
    });

    const project = await response.json();
    const monthlyUsage = project.usage.current_month;
    const limits = project.limits;

    // Check SMS usage
    const smsUsagePercent = (monthlyUsage.sms_sent / limits.monthly_sms_limit) * 100;
    
    if (smsUsagePercent > 90) {
      console.warn('🚨 Critical: 90% of monthly SMS limit reached');
      // Send alert to admin
    } else if (smsUsagePercent > 75) {
      console.warn('⚠️ Warning: 75% of monthly SMS limit reached');
    }

    // Check delivery rate
    const deliveryRate = (monthlyUsage.sms_delivered / monthlyUsage.sms_sent) * 100;
    
    if (deliveryRate < 95) {
      console.warn(`⚠️ Low delivery rate: ${deliveryRate.toFixed(1)}%`);
    }

    return {
      smsUsagePercent,
      deliveryRate,
      withinLimits: smsUsagePercent < 90 && deliveryRate >= 95
    };

  } catch (error) {
    console.error('Failed to check usage limits:', error);
    return null;
  }
};

// Run every hour
setInterval(() => {
  checkUsageLimits('YOUR_API_TOKEN');
}, 60 * 60 * 1000);

Best Practices

Cache Results

Cache project details to reduce API calls

Monitor Usage

Regularly check usage to avoid hitting limits

Handle Errors

Implement proper error handling for API failures

Update Settings

Keep project settings updated through the dashboard

Caching Strategy

class ProjectDetailsCache {
  constructor(apiToken, cacheTimeMs = 5 * 60 * 1000) { // 5 minutes
    this.apiToken = apiToken;
    this.cacheTimeMs = cacheTimeMs;
    this.cache = null;
    this.lastFetch = null;
  }

  async getProjectDetails(forceRefresh = false) {
    const now = Date.now();
    
    if (!forceRefresh && this.cache && this.lastFetch && 
        (now - this.lastFetch) < this.cacheTimeMs) {
      return this.cache;
    }

    try {
      const response = await fetch('https://sms.lamah.com/api/project/details', {
        headers: {
          'Authorization': `Bearer ${this.apiToken}`,
          'Accept': 'application/json'
        }
      });

      const project = await response.json();
      
      this.cache = project;
      this.lastFetch = now;
      
      return project;

    } catch (error) {
      console.error('Failed to fetch project details:', error);
      // Return cached data if available
      return this.cache;
    }
  }
}