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:
Name | Required? | Example | Description |
---|---|---|---|
by | No | off | Indicates how to group results:
|
start | No | 1430438400 (for 1 May 2015 00:00:00 UTC) | Time period start in UNIX timestamp format. The default is 7 days prior. |
end | No | 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:
Parameter | Example | Description |
---|---|---|
date | 2014-09-19T00:00:00+0000 | Time interval start, empty if the by parameter was set to off. |
costs | 30.15 | Cost for sent messages during this period. The costs are in the Account currency. |
deliveryRate | 0.95 | Message delivery rate:the number of delivered messages divided by the number of total messages. |
replyRate | 0.32 | Reply rate: the number of incoming messages divided by the number of total messages. |
messagesReceived | 1085 | Total received messages count. |
messagesSentParts | 15080 | 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. |
messagesSentDelivered | 11893 | Delivered messages count. As messages are retried for up to 48 hours, this value could change. |
messagesSentAccepted | 2 | Messages accepted for delivery (in queue), but not yet delivered. |
messagesSentBuffered | 0 | Messages buffered by endpoint cell phone operators. |
messagesSentFailed | 3 | Messages 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. |
messagesSentRejected | 50 | Messages 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:
Name | Required? | Example | Description |
---|---|---|---|
page | No | 3 | Fetch the specified results page. The default is 1. |
limit | No | 25 | The number of results per page. The default is 10. |
start | No | 1430438400 (for 1 May 2015 00:00:00 UTC) | Time period start in UNIX timestamp format. The default is 7 days prior. |
end | No | 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:
Parameter | Example | Description |
---|---|---|
page | 3 | The current fetched page. |
limit | 25 | The number of results per page. |
pageCount | 150 | The total number of pages. |
resources | Array of statement. | See the section below for details. |
Statement response format
Parameter | Example | Description |
---|---|---|
id | 305 | User statement ID. |
date | 2014-09-19T00:00:00+0000 | User statement date. |
balance | 350.16 | User balance after this spending/top up. |
delta | -0.15 | Balance change amount. |
type | sms number | Type of statement (what you have been charged for):
|
value | 350 | Value differs by type:
|
comment | null | Optional 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.