> For the complete documentation index, see [llms.txt](https://doc.batch.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.batch.com/developer/api/mep/transactional/stats.md).

# GET - Get stats

The stats endpoint allows you to track the result transactional messages using its group id.

### Request structure

#### Route

The transactional API exposes a GET endpoint at: `https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/GROUP_ID`

Here are examples of valid cURL, PHP or Python requests syntax:

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X GET "https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/GROUP_ID?since=2018-03-01&until=2018-03-10" \
-H "Content-Type: application/json" \
-H "X-Authorization: BATCH_REST_API_KEY"
```

{% endtab %}

{% tab title="PHP" %}

```php
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/GROUP_ID?since=2018-03-01&until=2018-03-10", [
	"headers" => [
		"Content-Type" => "application/json",
		"X-Authorization" => "BATCH_REST_API_KEY"
	]
]);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests, json
response = requests.request("GET", "https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/GROUP_ID?since=2018-03-01&until=2018-03-10",
	headers={
		'Content-Type': 'application/json'
		'X-Authorization': 'BATCH_REST_API_KEY'
	}
)
```

{% endtab %}
{% endtabs %}

The `GROUP_ID` value is the id you set when you [create](/developer/api/mep/transactional/send.md) a transactional message.

> **Note**: Only LIVE API Keys are supported by this API

#### Get parameters

<table><thead><tr><th width="176">Id</th><th>Description</th></tr></thead><tbody><tr><td><code>since</code></td><td><strong>String</strong> - <em>Required. Must be lower than 'until' parameter.</em><br>Value that indicates the first date of the window over which stats are fetched. The maximum window size is 6 months.<br><em>E.g.</em><code>"/transactional/stats/GROUP_ID?since=2018-03-01"</code></td></tr><tr><td><code>until</code></td><td><strong>String</strong> - <em>Required, Default : today's date (GMT)</em><br>Value that indicates the last date of the window over which stats are fetched.<br><em>E.g.</em><code>"/transactional/stats/GROUP_ID?since=2018-03-01&#x26;until=2018-03-10"</code></td></tr></tbody></table>

Here is an example of a valid cURL CLI request, which would return daily stats about the group id **welcome** from 1 to 10 March 2018 :

```
curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X GET
"https://api.batch.com/1.1/BATCH_API_KEY/transactional/stats/welcome?since=2018-03-01&until=2018-03-10"
```

#### Headers

In order to authenticate with the API, you need to provide your **company REST API Key** as the value of the `X-Authorization` header.

### Responses

#### Success

If the GET to the API endpoint is successfull you will receive an HTTP 200 confirmation and information on your campaign.

```json
{
    "group_id": "welcome",
    "detail": [
        {
            "date": "2018-03-05",
            "sent": 754,
            "direct_open": 102,
            "influenced_open": 98,
            "reengaged": 12,
            "errors": 0
        },
        {
            "date": "2018-03-07",
            "sent": 582,
            "direct_open": 96,
            "influenced_open": 85,
            "reengaged": 12,
            "errors": 1
        }
    ]
}
```

You can use this information to show the results of your transactional messages in your business intelligence tools.

Also, you can easily calculate the **open-rate** by using the following formula:\
**open-rate** = (`direct_open` + `influenced_open`) / `sent`

#### Failure

If the GET data does not meet the API requirements you will receive an actionable error message. Contact us at <support@batch.com> if you need further support.

* `AUTHENTICATION_INVALID` (Http status code: 401, Error code: 10)
* `API_MISUSE` (Http status code: 403, Error code: 12)
* `ROUTE_NOT_FOUND` (Http status code: 404, Error code: 20)
* `SERVER_ERROR` (Http status code: 500, Error code: 0)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://doc.batch.com/developer/api/mep/transactional/stats.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
