AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/AhaSend/ahasend-go"
"github.com/AhaSend/ahasend-go/api"
"github.com/AhaSend/ahasend-go/models/requests"
"github.com/google/uuid"
)
func main() {
// Create API client with authentication
client := api.NewAPIClient(
api.WithAPIKey("aha-sk-your-64-character-key"),
)
accountID := uuid.New()
// Create context for the API call
ctx := context.Background()
fromTime := time.Now().Add(-time.Hour * 24 * 30)
// Call the ping endpoint
response, httpResp, err := client.StatisticsAPI.GetBounceStatistics(
ctx,
accountID,
requests.GetBounceStatisticsParams{
FromTime: &fromTime,
SenderDomain: ahasend.String("example.com"),
RecipientDomains: ahasend.String("gmail.com"),
GroupBy: ahasend.String("week"),
},
)
if err != nil {
log.Fatalf("Error getting bounce statistics: %v", err)
}
// Check response
if httpResp.StatusCode == 200 {
fmt.Printf("✅ Status: %d\n", httpResp.StatusCode)
if response != nil {
fmt.Printf("Bounce statistics: %#v\n", response)
}
} else {
fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
}
}import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const statistics = await client.statistics.bounces({
from_time: "2026-01-01T00:00:00Z",
to_time: "2026-01-02T00:00:00Z",
});
console.log("Bounce statistics loaded.", { buckets: statistics.data.length });
curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"from_timestamp": "2023-11-07T05:31:56Z",
"to_timestamp": "2023-11-07T05:31:56Z",
"bounces": [
{
"classification": "<string>",
"count": 123
}
]
}
]
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Reports
Get Email Bounce Statistics via the API
Get email bounce statistics from the AhaSend API, grouped by bounce classification and time period, and filtered by sender domain, recipient domain or tag.
GET
/
v2
/
accounts
/
{account_id}
/
statistics
/
transactional
/
bounce
AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/AhaSend/ahasend-go"
"github.com/AhaSend/ahasend-go/api"
"github.com/AhaSend/ahasend-go/models/requests"
"github.com/google/uuid"
)
func main() {
// Create API client with authentication
client := api.NewAPIClient(
api.WithAPIKey("aha-sk-your-64-character-key"),
)
accountID := uuid.New()
// Create context for the API call
ctx := context.Background()
fromTime := time.Now().Add(-time.Hour * 24 * 30)
// Call the ping endpoint
response, httpResp, err := client.StatisticsAPI.GetBounceStatistics(
ctx,
accountID,
requests.GetBounceStatisticsParams{
FromTime: &fromTime,
SenderDomain: ahasend.String("example.com"),
RecipientDomains: ahasend.String("gmail.com"),
GroupBy: ahasend.String("week"),
},
)
if err != nil {
log.Fatalf("Error getting bounce statistics: %v", err)
}
// Check response
if httpResp.StatusCode == 200 {
fmt.Printf("✅ Status: %d\n", httpResp.StatusCode)
if response != nil {
fmt.Printf("Bounce statistics: %#v\n", response)
}
} else {
fmt.Printf("❌ Unexpected status code: %d\n", httpResp.StatusCode)
}
}import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const statistics = await client.statistics.bounces({
from_time: "2026-01-01T00:00:00Z",
to_time: "2026-01-02T00:00:00Z",
});
console.log("Bounce statistics loaded.", { buckets: statistics.data.length });
curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/statistics/transactional/bounce")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"object": "list",
"data": [
{
"from_timestamp": "2023-11-07T05:31:56Z",
"to_timestamp": "2023-11-07T05:31:56Z",
"bounces": [
{
"classification": "<string>",
"count": 123
}
]
}
]
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}The AhaSend API returns transactional bounce statistics grouped by classification.
The global statistics role can query all sender domains. A
domain-scoped key is limited to authorized domains and must authorize
every comma-separated value supplied in
sender_domain.
Query Parameters:
from_time: Filter statistics after this date (RFC3339 format)to_time: Filter statistics before this date (RFC3339 format)sender_domain: Filter by sender domainrecipient_domains: Filter by recipient domaintags: Filter by tags (comma-separated)group_by: Group by time period (hour, day, week, month)
Related Guides
- API authentication, Permission scopes, Statistics CLI.
- Delivery statistics API, API rate limits, API errors.
Authorizations
BearerAuthBearerAuth
API key for authentication. Non-empty Security Requirement values are AhaSend API-key roles. Roles listed within one requirement object are jointly required; separate requirement objects are alternatives.
Path Parameters
Account ID
Query Parameters
Filter statistics after this datetime (RFC3339 format)
Filter statistics before this datetime (RFC3339 format)
Comma-separated sender domains; the key must authorize every requested domain
Filter by a comma separated list of recipient domains
Filter by tags (comma-separated)
Group by time period
Available options:
hour, day, week, month 
