Control Your Costs and Efficiency

You can get detailed sent messages reports and user statements for a selected period of time using TextMagic SMS API commands.

Get messaging statistics

To get detailed information about outbound and inbound messages, use:

GET /api/v2/stats/messaging

with the parameters:

NameRequired?ExampleDescription
byNo off

Indicates how to group results:

  • off to get total values per specified time interval
  • day to show values grouped by day
  • month to show values grouped by month
  • year to show values grouped by year
startNo 1430438400 (for 1 May 2015 00:00:00 UTC)Time period start in UNIX timestamp format. The default is 7 days prior.
endNo 1431648000 (for 15 May 2015 00:00:00 UTC) Time period start in UNIX timestamp format. The default is today.

The response is an array of elements in the following format:

ParameterExampleDescription
date 2014-09-19T00:00:00+0000 Time interval start, empty if the by parameter was set to off.
costs30.15Cost for sent messages during this period. The costs are in the Account currency.
deliveryRate0.95Message delivery rate:the number of delivered messages divided by the number of total messages.
replyRate0.32Reply rate: the number of incoming messages divided by the number of total messages.
messagesReceived1085Total received messages count.
messagesSentParts15080 Total sent messages parts count. Note that this is not equal to the sent messages count, because one message could consist of 1 to 6 parts and users are charged per part, not per message.
messagesSentDelivered11893Delivered messages count. As messages are retried for up to 48 hours, this value could change.
messagesSentAccepted2Messages accepted for delivery (in queue), but not yet delivered.
messagesSentBuffered0Messages buffered by endpoint cell phone operators.
messagesSentFailed3Messages that have failed for whatever reason, e.g. the destination phone was switched off for 48 hours or the recipient phone account is out of service.
messagesSentRejected50Messages that were rejected: invalid Sender ID used (e.g. you cannot use the Sender ID or your own mobile number when sending to the United States and Canada.)

Get spending statistics

To get user statements, use:

GET /api/v2/stats/spending

 with these parameters:

NameRequired?ExampleDescription
pageNo 3 Fetch the specified results page. The default is 1.
limitNo25The number of results per page. The default is 10.
startNo 1430438400 (for 1 May 2015 00:00:00 UTC)Time period start in UNIX timestamp format. The default is 7 days prior.
endNo 1431648000 (for 15 May 2015 00:00:00 UTC)Time period start in UNIX timestamp format. The default is today.

You will receive the standard paginated response:

ParameterExampleDescription
page3The current fetched page.
limit25The number of results per page.
pageCount150The total number of pages.
resourcesArray of statement.See the section below for details.

Statement response format

ParameterExampleDescription
id305User statement ID.
date 2014-09-19T00:00:00+0000User statement date.
balance 350.16User balance after this spending/top up.
delta -0.15

Balance change amount.

type sms
number
Type of statement (what you have been charged for):
  • sms for sending SMS
  • number for renewing a dedicated number
  • schedule for scheduling text messages
  • topup for adding credits to your account
value350 Value differs by type:
  • for sms, it is the sent messages amount
  • for number, it is a dedicated phone number
  • for schedule, it is a scheduled messages amount
  • for top-up, it is an invoice ID
commentnullOptional comment.

The next step

Now you’ve learned how to manage your messaging and spending statistics via the TextMagic API, in the next section, you will learn how to manage Invoices.