Get Available Balance

Use getConversiveBalance() to retrieve the current SMS and MMS credits available in the connected account.

When to use this API

This API is useful for:

  • validating account capacity before bulk sends
  • showing available credits in admin screens
  • pre-send checks in workflows or scheduled jobs
  • operational monitoring

Method signature

public static ConversiveAPI.BalanceResponse getConversiveBalance()

Inputs

This API takes no input parameters.

Response type

public class BalanceResponse {
public String response; // SUCCESS / ERROR
public String responseMessage;
public Double SMSCredits;
public Double MMSCredits;
}

Response fields

FieldTypeDescription
responseStringIndicates success or failure
responseMessageStringHuman-readable result
SMSCreditsDoubleRemaining SMS credits
MMSCreditsDoubleRemaining MMS credits

Example

ConversiveAPI.BalanceResponse resp =
ConversiveAPI.getConversiveBalance();
System.debug('response = ' + resp.response);
System.debug('responseMessage = ' + resp.responseMessage);
System.debug('SMSCredits = ' + resp.SMSCredits);
System.debug('MMSCredits = ' + resp.MMSCredits);

Example success response

response = 'SUCCESS'
responseMessage = 'Balance fetched successfully'
SMSCredits = 1250.0
MMSCredits = 320.0

Example error response

response = 'ERROR'
responseMessage = 'Unable to fetch account balance'
SMSCredits = null
MMSCredits = null

Error behavior

The Confluence page documents generic error behavior for this API:

  • response = 'ERROR'
  • responseMessage contains the reason for failure
  • SMSCredits and MMSCredits may be null or empty depending on the failure condition

Because this API takes no inputs, the main implementation concern is handling the returned error response and preventing downstream logic from assuming credits exist.

Best practices

  • call this API before large SMS or MMS sends
  • surface the balance in admin or monitoring screens
  • guard downstream logic against null credit values
  • log responseMessage when troubleshooting