AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AhaSend/ahasend-go/api"
"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()
listID := uuid.MustParse("11111111-1111-4111-8111-111111111111")
// Removing drops the membership. To stop sending to the contact while
// keeping the record, set its status to unsubscribed instead.
response, _, err := client.ListsAPI.DeleteListContact(ctx, accountID, listID, "user+tag@example.com")
if err != nil {
log.Fatalf("Error removing the contact from the list: %v", err)
}
fmt.Println(response.Message)
}import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const listId = "00000000-0000-4000-8000-000000000010";
const idOrEmail = "User+Tag@Example.COM";
const result = await client.lists.contacts.delete(listId, idOrEmail);
console.log("Contact removed from list.", { message: result.message });
curl --request DELETE \
--url https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
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.delete("https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "Operation completed successfully"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}Lists
Remove a Contact from a List via the API
Remove a contact from an AhaSend list. This deletes the membership and its unsubscribe record; to stop email but keep the record, unsubscribe instead.
DELETE
/
v2
/
accounts
/
{account_id}
/
lists
/
{list_id}
/
contacts
/
{id_or_email}
AhaSend Go SDK
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/AhaSend/ahasend-go/api"
"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()
listID := uuid.MustParse("11111111-1111-4111-8111-111111111111")
// Removing drops the membership. To stop sending to the contact while
// keeping the record, set its status to unsubscribed instead.
response, _, err := client.ListsAPI.DeleteListContact(ctx, accountID, listID, "user+tag@example.com")
if err != nil {
log.Fatalf("Error removing the contact from the list: %v", err)
}
fmt.Println(response.Message)
}import { AhaSendClient } from "@ahasend/sdk";
const client = AhaSendClient.fromEnv();
const listId = "00000000-0000-4000-8000-000000000010";
const idOrEmail = "User+Tag@Example.COM";
const result = await client.lists.contacts.delete(listId, idOrEmail);
console.log("Contact removed from list.", { message: result.message });
curl --request DELETE \
--url https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
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.delete("https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ahasend.com/v2/accounts/{account_id}/lists/{list_id}/contacts/{id_or_email}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "Operation completed successfully"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}{
"message": "Error message"
}The AhaSend API removes one contact from one list. Access requires
lists:write, not lists:delete.
{id_or_email} is the contact ID or its email address. Percent-encode an email address exactly once. See Name a contact in the path.
The API deletes the membership, and with it any record that the contact unsubscribed from this list. So when you add the contact again later, nothing shows the earlier unsubscribe. To stop email from this list and keep the record, use Add or Update a List Contact with subscription_status: "unsubscribed" instead. You can undo an unsubscribe.
A membership that is complained cannot be removed and answers 409, so the contact cannot be added back as confirmed. A list, a contact or a membership that does not exist answers 404, and the message says which. The contact itself stays.
Related Guides
- API authentication, Permission scopes, Unsubscribe, remove or delete.
- Lists API overview, API errors, API rate limits.
Authorizations
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
List ID
Contact UUID or email address. Percent-encode an email exactly once as a path segment; SDK callers pass the raw email value.
Response
Contact removed from the list
Success message

