# Get All Single Sends Stats

## API Overview

As a Marketing Campaigns customer, you have access to rich statistics about your Single Sends and Automations. The Marketing Campaigns Statistics API allows you to retrieve these statistics programmatically. for detailed information about the statistics available, see the [**Marketing Campaigns Stats Overview**](/docs/sendgrid/ui/analytics-and-reporting/marketing-campaigns-stats-overview).

> \[!NOTE]
>
> These endpoints provide stats for Marketing Campaigns only. For stats related to event tracking, please see the [**Stats API**](/docs/sendgrid/api-reference/stats).

## Operation overview

```json
{"path":"https://api.sendgrid.com/v3/marketing/stats/singlesends","method":"get","servers":[{"url":"https://api.sendgrid.com","description":"The Twilio SendGrid v3 API"}]}
```

**This endpoint allows you to retrieve stats for all your Single Sends.**

By default, all of your Single Sends will be returned, but you can specify a selection by passing in a comma-separated list of Single Send IDs as the value of the query string parameter `singlesend_ids`.

Responses are paginated. You can limit the number of responses returned per batch using the `page_size` query string parameter. The default is 25, but you specify a value between 1 and 50.

You can retrieve a specific page of responses with the `page_token` query string parameter.

## Operation details

### Authentication

API Key

### Headers

```json
[{"in":"header","name":"Authorization","required":true,"default":"Bearer <<YOUR_API_KEY_HERE>>","schema":{"type":"string"}}]
```

### Query string

```json
[{"name":"singlesend_ids","in":"query","description":"This endpoint returns all Single Send IDs if no IDs are included in `singlesend_ids`.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":25}},{"name":"page_size","in":"query","description":"The number of elements you want returned on each page.","schema":{"type":"integer","minimum":1,"maximum":50,"default":25},"refName":"#/components/parameters/PaginationPageSize","modelName":"__components_parameters_PaginationPageSize"},{"name":"page_token","in":"query","description":"The stats endpoints are paginated. To get the next page, call the passed `_metadata.next` URL. If `_metadata.prev` doesn't exist, you're at the first page. Similarly, if `_metadata.next` is not present, you're at the last page.","schema":{"type":"string"},"refName":"#/components/parameters/PaginationPageToken","modelName":"__components_parameters_PaginationPageToken"}]
```

### Responses

```json
[{"responseCode":"200","schema":{"description":"","content":{"application/json":{"schema":{"title":"SinglesendsResponse","type":"object","required":["results","_metadata"],"refName":"SinglesendsResponse","modelName":"SinglesendsResponse","properties":{"results":{"type":"array","items":{"type":"object","required":["id","ab_variation","ab_phase"],"properties":{"id":{"type":"string","description":"This is the ID of the Single Send you require stats for.","format":"uuid"},"ab_variation":{"type":"string","default":"a14dcc63-d651-4c57-9826-4a3705f5c78d","description":"This is the A/B variation of the Single Send stat returned. If the `group_by` parameter doesn't include `ab_variation` in the request, then the value is \"all\".","format":"uuid"},"ab_phase":{"type":"string","default":"all","description":"This is the A/B phase of the Single Send stat returned. If the `group_by` parameter doesn't include `ab_phase` in the request, then the value is \"all\".","enum":["send","test","all"],"refName":"AbPhase","modelName":"AbPhase"},"aggregation":{"type":"string","description":"This describes the time unit to which the stat is rolled up. It is based on the `aggregated_by` parameter included in the request. It can be \"total\" or the date (in YYYY-MM-DD format) the stats are for.","default":"total"},"stats":{"title":"metrics","type":"object","required":["bounce_drops","bounces","clicks","delivered","invalid_emails","opens","requests","spam_report_drops","spam_reports","unique_clicks","unique_opens","unsubscribes"],"refName":"Metrics","modelName":"Metrics","properties":{"bounce_drops":{"type":"integer"},"bounces":{"type":"integer"},"clicks":{"type":"integer"},"delivered":{"type":"integer"},"invalid_emails":{"type":"integer"},"opens":{"type":"integer"},"requests":{"type":"integer"},"spam_report_drops":{"type":"integer"},"spam_reports":{"type":"integer"},"unique_clicks":{"type":"integer"},"unique_opens":{"type":"integer"},"unsubscribes":{"type":"integer"}}}}}},"_metadata":{"title":"metadata","type":"object","refName":"Metadata","modelName":"Metadata","properties":{"prev":{"type":"string","format":"uri","description":"The URL of the previous page of results. If this field isn't present, you're at the start of the list."},"self":{"type":"string","format":"uri","description":"The URL of the current page of results."},"next":{"type":"string","format":"uri","description":"The URL of the next page of results. If this field isn't present, you're at the end of the list."},"count":{"type":"number","description":"The number of items in the entire list, i.e., across all pages."}}}}}}}}},{"responseCode":"400","schema":{"description":"","content":{"application/json":{"schema":{"type":"object","example":{"errors":[{"field":"field_name","message":"error message"}]},"refName":"ErrorResponse","modelName":"ErrorResponse","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"An error message."},"field":{"description":"When applicable, this property value will be the field that generated the error.","nullable":true,"type":"string"},"help":{"type":"object","description":"When applicable, this property value will be helper text or a link to documentation to help you troubleshoot the error."}}}},"id":{"type":"string","description":"When applicable, this property value will be an error ID."}}}}},"refName":"#/components/responses/Stats400","modelName":"__components_responses_Stats400"}}]
```

Get All Single Sends Stats

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

const request = {
  url: `/v3/marketing/stats/singlesends`,
  method: "GET",
};

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"))


response = sg.client.marketing.stats.singlesends.get()

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 response = await client.RequestAsync(
            method: SendGridClient.Method.GET, urlPath: "marketing/stats/singlesends");

        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("/marketing/stats/singlesends");
            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/marketing/stats/singlesends", host)
	request.Method = "GET"
	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);

try {
    $response = $sg->client
        ->marketing()
        ->stats()
        ->singlesends()
        ->get();
    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'])

response = sg.client.marketing.stats.singlesends.get()
puts response.status_code
puts response.headers
puts response.body
```

```bash
curl -X GET "https://api.sendgrid.com/v3/marketing/stats/singlesends" \
--header "Authorization: Bearer $SENDGRID_API_KEY"
```
