AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AhaSend/ahasend-go/api"
"github.com/AhaSend/ahasend-go/models/requests"
"github.com/google/uuid"
)
func main() {
client := api.NewAPIClient(api.WithAPIKey(os.Getenv("AHASEND_API_KEY")))
accountID := uuid.MustParse(os.Getenv("AHASEND_ACCOUNT_ID"))
ctx := context.Background()
response, _, err := client.SuppressionsAPI.GetSuppressions(ctx, accountID, requests.GetSuppressionsParams{})
if err != nil {
log.Fatalf("Error getting suppressions: %v", err)
}
for _, suppression := range response.Data {
fmt.Printf("%s until %s: %s\n", suppression.Email, suppression.ExpiresAt, suppression.Reason)
}
}
import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const page = await client.suppressions.list({ limit: 20 });
console.log("Suppressions listed.", { count: page.data.length });
curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/suppressions \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/suppressions"
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}/suppressions",
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}/suppressions")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/suppressions")
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": [
{
"object": "suppression",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"email": "jsmith@example.com",
"domain": "<string>",
"reason": "<string>",
"protected": true,
"expires_at": "2023-11-07T05:31:56Z"
}
],
"pagination": {
"has_more": true,
"next_cursor": "eyJpZCI6MTIzNH0="
}
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Suppressions
List Suppressed Addresses via the API
List the addresses on your AhaSend suppression list through the API, filtered by email, domain or creation time, to find out why an email was not sent.
GET
/
v2
/
accounts
/
{account_id}
/
suppressions
AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AhaSend/ahasend-go/api"
"github.com/AhaSend/ahasend-go/models/requests"
"github.com/google/uuid"
)
func main() {
client := api.NewAPIClient(api.WithAPIKey(os.Getenv("AHASEND_API_KEY")))
accountID := uuid.MustParse(os.Getenv("AHASEND_ACCOUNT_ID"))
ctx := context.Background()
response, _, err := client.SuppressionsAPI.GetSuppressions(ctx, accountID, requests.GetSuppressionsParams{})
if err != nil {
log.Fatalf("Error getting suppressions: %v", err)
}
for _, suppression := range response.Data {
fmt.Printf("%s until %s: %s\n", suppression.Email, suppression.ExpiresAt, suppression.Reason)
}
}
import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const page = await client.suppressions.list({ limit: 20 });
console.log("Suppressions listed.", { count: page.data.length });
curl --request GET \
--url https://api.ahasend.com/v2/accounts/{account_id}/suppressions \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/suppressions"
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}/suppressions",
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}/suppressions")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/suppressions")
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": [
{
"object": "suppression",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"email": "jsmith@example.com",
"domain": "<string>",
"reason": "<string>",
"protected": true,
"expires_at": "2023-11-07T05:31:56Z"
}
],
"pagination": {
"has_more": true,
"next_cursor": "eyJpZCI6MTIzNH0="
}
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}The AhaSend API returns a list of suppressions for the account.
Query Parameters:
domain: Filter by domain (optional)email: Filter by email (optional)from_time: Filter suppressions created after this time (RFC3339 format, optional)to_time: Filter suppressions created before this time (RFC3339 format, optional)limit: Maximum number of items to return (1-100, default: 100)after: Pagination cursor for the next pagebefore: Pagination cursor for the previous page
Related Guides
- API authentication, Permission scopes, Suppression CLI.
- Suppression durations, API errors, API rate limits.

