# Retrieve bounces by specific classification

## API Overview

An email is considered [bounced](/docs/sendgrid/glossary/bounces/) when the message is undeliverable and then returned to the server that sent it. Bounced emails can be either permanent or temporary failures to deliver the message.

For more information, see our [Bounces documentation](/docs/sendgrid/ui/sending-email/bounces/).

You can also manage bounced emails from the [Suppression settings menu in the Twilio SendGrid App](https://app.sendgrid.com/suppressions/bounces).

## Operation overview

```json
{"path":"https://api.sendgrid.com/v3/suppression/bounces/classifications/{classification}","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 will return the number of bounces for the classification specified in descending order for each day. You can retrieve the bounce classification totals in CSV format by specifying `"text/csv"` in the Accept header.

## Operation details

### Authentication

API Key

### Headers

```json
[{"in":"header","name":"Authorization","required":true,"default":"Bearer <<YOUR_API_KEY_HERE>>","schema":{"type":"string"}},{"name":"Accept","in":"header","description":"Specifies the content type to be returned by this endpoint. You can choose to receive CSV-formatted data by passing \"text/csv\" in the header.","required":true,"schema":{"type":"string","default":"application/json","enum":["application/json","text/csv"],"refName":"Accept1","modelName":"Accept1"}},{"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>`). It is important to use the Base URL that corresponds to the region of the account or Subuser you specify in the `on-behalf-of` header. 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"}]
```

### Path parameters

```json
[{"name":"classification","in":"path","description":"The classification you want to filter by. Possible values are: `Content`, `Frequency or Volume Too High`, `Invalid Address`, `Mailbox Unavailable`, `Reputation`, `Technical Failure`, `Unclassified`.","schema":{"type":"string","enum":["Content","Frequency or Volume Too High","Invalid Address","Mailbox Unavailable","Reputation","Technical Failure","Unclassified"],"refName":"Classification1","modelName":"Classification1"},"required":true}]
```

### Query string

```json
[{"name":"start_date","in":"query","description":"The start of the time range, in YYYY-MM-DD format, when a bounce was created (inclusive).","schema":{"type":"string"}},{"name":"end_date","in":"query","description":"The end of the time range, in YYYY-MM-DD format, when a bounce was created (inclusive).","schema":{"type":"string"}}]
```

### Responses

```json
[{"responseCode":"200","schema":{"description":"200 OK","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string"},"stats":{"type":"array","items":{"type":"object","properties":{"domain":{"type":"string"},"count":{"type":"integer"}}}}}}}}},"examples":{"response":{"value":{"result":[{"date":"2022-01-01","stats":[{"domain":"example.com","count":35},{"domain":"one.example.com","count":14}]},{"date":"2022-01-02","stats":[{"domain":"example.com","count":23},{"domain":"one.example.com","count":4}]}]}}}}}}}]
```

Retrieve bounces by specific classification

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

const classification = "Content";
const headers = { Accept: "application/json" };

const request = {
  url: `/v3/suppression/bounces/classifications/${classification}`,
  method: "GET",
  headers: headers,
};

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

classification = "Content"
headers = {"Accept": "application/json"}

response = sg.client.suppression.bounces.classifications._(classification).get(
    request_headers=headers
)

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 headers = new Dictionary<string, string> { { "Accept", "application/json" } };
        var client = new SendGridClient(apiKey: apiKey, requestHeaders: headers);

        var classification = "Content";

        var response = await client.RequestAsync(
            method: SendGridClient.Method.GET,
            urlPath: $"suppression/bounces/classifications/{classification}");

        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"));
            sg.addRequestHeader("Accept", "application/json");
            Request request = new Request();
            request.setMethod(Method.GET);
            request.setEndpoint("/suppression/bounces/classifications/Content");
            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/suppression/bounces/classifications/Content", host)
	request.Method = "GET"
	request.Headers["Accept"] = "application/json"
	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);
$classification = "Content";

try {
    $response = $sg->client
        ->suppression()
        ->bounces()
        ->classifications()
        ->_($classification)
        ->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'])
classification = "Content"
request_headers = JSON.parse('{
  "Accept": "application/json"
}')

response = sg.client.suppression.bounces.classifications._(classification).get(request_headers: request_headers)
puts response.status_code
puts response.headers
puts response.body
```

```bash
curl -X GET "https://api.sendgrid.com/v3/suppression/bounces/classifications/Content" \
--header "Authorization: Bearer $SENDGRID_API_KEY" \
--header "Accept: application/json"
```
