# Retrieves Inbound Parse Webhook statistics.

## API Overview

The SendGrid Event Webhook sends email event data as SendGrid processes it. This means you can receive data in nearly real-time, making it ideal to integrate with logging or monitoring systems.

Because the Event Webhook delivers data to your systems, it is also well-suited to backing up and storing event data within your infrastructure to meet your own data access and retention needs.

## Event types

You can think about the types of events provided by the Event Webhook in two categories: deliverability events and engagement events.

* Deliverability events such as "delivered," "bounced," and "processed" help you understand if your email is being delivered to your customers.
* Engagement events such as "open," and "click" help you understand if customers are reading and interacting with your emails after they arrive.

Both types of events are important and should be monitored to understand the overall health of your email program. The Webhooks API allows you to configure your Event Webhook configurations.

## Data storage

Currently, data staged to be posted through the webhooks is stored in the US.

## Operation overview

```json
{"path":"https://api.sendgrid.com/v3/user/webhooks/parse/stats","method":"get","servers":[{"url":"https://api.sendgrid.com","description":"for global users and subusers"},{"url":"https://api.eu.sendgrid.com","description":"for EU regional subusers"}]}
```

**This endpoint allows you to retrieve the statistics for your Parse Webhook usage.**

SendGrid's Inbound Parse Webhook allows you to parse the contents and attachments of incoming emails. The Parse API can then POST the parsed emails to a URL that you specify. The Inbound Parse Webhook cannot parse messages greater than 30MB in size, including all attachments.

There are a number of pre-made integrations for the SendGrid Parse Webhook which make processing events easy. You can find these integrations in the [Library Index](/docs/sendgrid/for-developers/sending-email/libraries#webhook-libraries).

## Operation details

### Authentication

API Key

### Headers

```json
[{"in":"header","name":"Authorization","required":true,"default":"Bearer <<YOUR_API_KEY_HERE>>","schema":{"type":"string"}},{"name":"on-behalf-of","in":"header","description":"The `on-behalf-of` header allows you to make API calls from a parent account on behalf of the parent's Subusers or customer accounts. You will use the parent account's API key when using this header. When making a call on behalf of a customer account, the property value should be \"account-id\" followed by the customer account's ID (e.g., `on-behalf-of: account-id <account-id>`). When making a call on behalf of a Subuser, the property value should be the Subuser's username (e.g., `on-behalf-of: <subuser-username>`). See [**On Behalf Of**](/docs/sendgrid/api-reference/how-to-use-the-sendgrid-v3-api/on-behalf-of) for more information.","required":false,"schema":{"type":"string"},"refName":"#/components/parameters/OnBehalfOf","modelName":"__components_parameters_OnBehalfOf"}]
```

### Query string

```json
[{"name":"limit","in":"query","description":"The number of statistics to return on each page.","required":false,"schema":{"type":"string"}},{"name":"offset","in":"query","description":"The number of statistics to skip.","required":false,"schema":{"type":"string"}},{"name":"aggregated_by","in":"query","description":"How you would like the statistics to by grouped. ","required":false,"schema":{"type":"string","enum":["day","week","month"],"refName":"AggregatedBy","modelName":"AggregatedBy"}},{"name":"start_date","in":"query","description":"The starting date of the statistics you want to retrieve. Must be in the format YYYY-MM-DD","required":true,"schema":{"type":"string"}},{"name":"end_date","in":"query","description":"The end date of the statistics you want to retrieve. Must be in the format YYYY-MM-DD","required":false,"schema":{"type":"string","default":"The day the request is made."}}]
```

### Responses

```json
[{"responseCode":"200","schema":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","required":["date","stats"],"properties":{"date":{"type":"string","description":"The date that the stats were collected."},"stats":{"type":"array","description":"The Parse Webhook usage statistics.","items":{"type":"object","properties":{"metrics":{"type":"object","required":["received"],"properties":{"received":{"type":"number","description":"The number of emails received and parsed by the Parse Webhook."}}}}}}}}},"examples":{"response":{"value":[{"date":"2015-10-11","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-12","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-13","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-14","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-15","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-16","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-17","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-18","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-19","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-20","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-21","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-22","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-23","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-24","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-25","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-26","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-27","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-28","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-29","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-30","stats":[{"metrics":{"received":0}}]},{"date":"2015-10-31","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-01","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-02","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-03","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-04","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-05","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-06","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-07","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-08","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-09","stats":[{"metrics":{"received":0}}]},{"date":"2015-11-10","stats":[{"metrics":{"received":0}}]}]}}}}}}]
```

Retrieves Inbound Parse Webhook statistics.

```js
const client = require("@sendgrid/client");
client.setApiKey(process.env.SENDGRID_API_KEY);

const queryParams = {
  end_date: "The day the request is made.",
  start_date: "2009-07-06",
};

const request = {
  url: `/v3/user/webhooks/parse/stats`,
  method: "GET",
  qs: queryParams,
};

client
  .request(request)
  .then(([response, body]) => {
    console.log(response.statusCode);
    console.log(response.body);
  })
  .catch((error) => {
    console.error(error);
  });
```

```python
import os
from sendgrid import SendGridAPIClient


sg = SendGridAPIClient(os.environ.get("SENDGRID_API_KEY"))

params = {
    "start_date": "2009-07-06",
    "end_date": "The day the request is made.",
}

response = sg.client.user.webhooks.parse.stats.get(query_params=params)

print(response.status_code)
print(response.body)
print(response.headers)
```

```csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using SendGrid;

public class Program {
    public static async Task Main() {
        string apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
        var client = new SendGridClient(apiKey);

        var queryParams =
            @"{'start_date': '2009-07-06', 'end_date': 'The day the request is made.'}";

        var response = await client.RequestAsync(
            method: SendGridClient.Method.GET,
            urlPath: "user/webhooks/parse/stats",
            queryParams: queryParams);

        Console.WriteLine(response.StatusCode);
        Console.WriteLine(response.Body.ReadAsStringAsync().Result);
        Console.WriteLine(response.Headers.ToString());
    }
}
```

```java
import com.sendgrid.*;
import java.io.IOException;

public class Example {
    public static void main(String[] args) throws IOException {
        try {
            SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
            Request request = new Request();
            request.setMethod(Method.GET);
            request.setEndpoint("/user/webhooks/parse/stats");
            request.addQueryParam("start_date", "2009-07-06");
            request.addQueryParam("end_date", "The day the request is made.");
            Response response = sg.api(request);
            System.out.println(response.getStatusCode());
            System.out.println(response.getBody());
            System.out.println(response.getHeaders());
        } catch (IOException ex) {
            throw ex;
        }
    }
}
```

```go
package main

import (
	"fmt"
	"github.com/sendgrid/sendgrid-go"
	"os"
)

func main() {
	apiKey := os.Getenv("SENDGRID_API_KEY")
	host := "https://api.sendgrid.com"
	request := sendgrid.GetRequest(apiKey, "/v3/user/webhooks/parse/stats", host)
	request.Method = "GET"
	queryParams := make(map[string]string)
	queryParams["start_date"] = "2009-07-06"
	queryParams["end_date"] = "The day the request is made."
	request.QueryParams = queryParams
	response, err := sendgrid.API(request)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(response.StatusCode)
		fmt.Println(response.Body)
		fmt.Println(response.Headers)
	}
}
```

```php
<?php
// Uncomment the next line if you're using a dependency loader (such as Composer) (recommended)
// require 'vendor/autoload.php';

// Uncomment next line if you're not using a dependency loader (such as Composer)
// require_once '<PATH TO>/sendgrid-php.php';

$apiKey = getenv("SENDGRID_API_KEY");
$sg = new \SendGrid($apiKey);
$query_params = json_decode('{
    "start_date": "2009-07-06",
    "end_date": "The day the request is made."
}');

try {
    $response = $sg->client
        ->user()
        ->webhooks()
        ->parse()
        ->stats()
        ->get(null, $query_params);
    print $response->statusCode() . "\n";
    print_r($response->headers());
    print $response->body() . "\n";
} catch (Exception $ex) {
    echo "Caught exception: " . $ex->getMessage();
}
```

```ruby
require 'sendgrid-ruby'
include SendGrid

sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
params = JSON.parse('{
  "start_date": "2009-07-06",
  "end_date": "The day the request is made."
}')

response = sg.client.user.webhooks.parse.stats.get(query_params: params)
puts response.status_code
puts response.headers
puts response.body
```

```bash
curl -G -X GET "https://api.sendgrid.com/v3/user/webhooks/parse/stats?start_date=2009-07-06&end_date=The%20day%20the%20request%20is%20made." \
--header "Authorization: Bearer $SENDGRID_API_KEY"
```
