View Categories

Credits API

1 min read

Credits API #

Monitor your credit balance and usage history through the API.

Get Credit Balance #

Endpoint: GET /api/v1/credits

curl -X GET "https://app.voxpria.com/api/v1/credits" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response #

{
  "success": true,
  "data": {
    "balance": 1500,
    "currency": "credits",
    "lastUpdated": "2025-02-09T12:00:00Z"
  }
}

Get Usage History #

Endpoint: GET /api/v1/credits/usage

curl -X GET "https://app.voxpria.com/api/v1/credits/usage?startDate=2025-02-01&endDate=2025-02-09" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response #

{
  "success": true,
  "data": {
    "usage": [
      {
        "date": "2025-02-09",
        "calls": 45,
        "creditsUsed": 135,
        "cost": "$13.50"
      },
      {
        "date": "2025-02-08",
        "calls": 38,
        "creditsUsed": 114,
        "cost": "$11.40"
      }
    ],
    "total": {
      "calls": 83,
      "creditsUsed": 249,
      "cost": "$24.90"
    }
  }
}

Credit Costs #

Action Credit Cost
Voice Call (per minute) 3 credits
SMS Message 1 credit
Transcription (per minute) 1 credit
AI Processing Included

Code Example #

JavaScript #

async function checkCredits() {
  const response = await axios.get(
    'https://app.voxpria.com/api/v1/credits',
    {
      headers: {
        'Authorization': `Bearer ${process.env.VOXPRIA_API_KEY}`
      }
    }
  );
  
  const balance = response.data.data.balance;
  console.log(`Current balance: ${balance} credits`);
  
  // Alert if low
  if (balance < 100) {
    console.warn('⚠️ Low credit balance!');
  }
  
  return balance;
}

Python #

def check_credits():
    response = requests.get(
        'https://app.voxpria.com/api/v1/credits',
        headers={
            'Authorization': f'Bearer {os.getenv("VOXPRIA_API_KEY")}'
        }
    )
    
    balance = response.json()['data']['balance']
    print(f'Current balance: {balance} credits')
    
    # Alert if low
    if balance < 100:
        print('⚠️ Low credit balance!')
    
    return balance

Usage Monitoring #

Set up automated monitoring:

  • Check balance before launching campaigns
  • Alert when credits fall below threshold
  • Track usage trends over time
  • Budget forecasting based on usage patterns
💡 Pro Tip: Set up a daily cron job to check your credit balance and send alerts when it's low. This prevents campaigns from failing due to insufficient credits.

Leave A Comment

Go to Top